Tesla Integration to Query Status and Send Commands to Your Car

weird that you tire pressures seemed to be in your debuggin in psi.. that is not what was comning out in my test of your code.. check it.. mine was coming out in bar instead of psi so i addeded conversion and fixed a typo..

are you sure the code you are using is what you sent me..

anyway

  • new version fix misspelling of tpms vs tmps and notice tire pressures were in bar so convert to psi

yet another iteration the code sent to me by brad had mismatch driver and app code for the field names for the tire pressures.. new version on github.

and as before it is in bar converted to psi.. if someone really really needs it in bar instead i will add a parameter for it otherwise livef with it .. lol

1 Like

Thanks, @kahn-hubitat… this looks great. Thanks for reviewing and fixing my errors. I did notice the pressure null issue when not driving, but was just going to work around it… but I like your solution. Thanks again!

For some reason the last_known attributes aren't remaining permanent. It looks like they are zeroing out when the current pressures zero out. Perhaps the attribute isn't reading as null and the != null condition isn't applying correctly? Below are the logs and what I'm seeing. I'll play around with it as well and see what I can figure out. Also, feel free to remove my info and any explanation of my mistakes in the comments, since I just threw in some code and you're the one who's doing the real work :upside_down_face:
_
Both current and last_known set as expected:

2022-04-21 20:36:37.594 debug processData: [state:online, ... ..., tire_pressure_front_left:3.25, tire_pressure_front_right:3.225, tire_pressure_rear_left:3.2, tire_pressure_rear_right:3.225]
last_known_tire_pressure_rear_right	46.8 DEVICE 2022-04-21 20:36:28.319 EDT
           tire_pressure_rear_right	46.8 DEVICE 2022-04-21 20:36:28.319 EDT

_
Both current and last_known zeroed out:

2022-04-21 20:40:40.594 debug processData: [state:online, ... ..., tire_pressure_front_left:0.0, tire_pressure_front_right:0.0, tire_pressure_rear_left:0.0, tire_pressure_rear_right:0.0]
last_known_tire_pressure_rear_right 0.0 DEVICE 2022-04-21 20:40:40.616 EDT
           tire_pressure_rear_right 0.0 DEVICE 2022-04-21 20:40:40.615 EDT

I changed the if conditions to != 0.0 and I'm now getting the n/a results tire_pressure_front_left : n/a ... so I'll go for a drive tomorrow to test this out with actual pressure values coming through.

Mine are working fine..fo you have the latest version

Yeah... I'm using HPM, and I have the one from 18-Apr

I just touched it pull it and try. I made another change that day like an hour later and forgot to touch the main file. You can see in the log if you are are getting null or 0 when parked.

Hmmm... I just updated to the most recent version via HPM, and I don't see any difference in the logic. I'm going to revert to the below locally, because that is working for me. if null is working for you, perhaps an OR statement for null or 0?

if (data.vehicleState.tire_pressure_front_left != 0)

Show.me the.logs about what your.car is reporting when not in motion.

here is mine and as you can see it is obviously null?

dev:1932022-04-22 10:45:41.153 pm infoBasement Freezer: temperature is 4.1°F

dev:12122022-04-22 10:45:13.534 pm debugprocessData: [state:online, motion:inactive, speed:0, vin:*******, thermostatMode:off, chargeState:[battery:60, batteryRange:174.33, chargingState:Disconnected, chargeLimit:84, minutes_to_full_charge:0], driveState:[latitude:27.740799, longitude:-82.756355, method:wgs, heading:246, lastUpdateTime:Fri Apr 22 22:45:09 EDT 2022], vehicleState:[presence:not present, lock:locked, odometer:32836.221162, sentry_mode:On, front_drivers_window:Closed, front_pass_window:Closed, rear_drivers_window:Closed, rear_pass_window:Closed, valet_mode:Off, tire_pressure_front_left:null, tire_pressure_front_right:null, tire_pressure_rear_left:null, tire_pressure_rear_right:null], climateState:[temperature:78.62, thermostatSetpoint:69.98, seat_heater_left:0, seat_heater_right:0, seat_heater_rear_left:0, seat_heater_rear_right:0, seat_heater_rear_center:0]]

if i see the logging truly coming back as zero i will add the or but for now i think something else is going on?

That appears to be the difference. In the logs below you can see I'm getting 0.0 instead of null. I didn't realize you were actually getting null back. If I hit the API endpoint outside of Hubitat here are my results:

"tpms_pressure_fl": 0,
"tpms_pressure_fr": 0,
"tpms_pressure_rl": 0,
"tpms_pressure_rr": 0,

I'm in a Model Y on 2022.4.5.21 a912b0d64483 which is the most recent FSD beta, so if you're on another version, maybe that's the difference.

Not Driving:
[dev:676] 2022-04-23 08:40:17.890 processData: [state:online, motion:inactive, speed:0, vin:5YJYGDEE1MF123456, thermostatMode:off, chargeState:[battery:80, batteryRange:248.14, chargingState:Complete, chargeLimit:80, minutes_to_full_charge:0], driveState:[latitude:40.766683, longitude:-73.980743, method:wgs, heading:113, lastUpdateTime:Sat Apr 23 02:00:07 EDT 2022], vehicleState:[presence:not present, lock:unlocked, odometer:13082.020376, sentry_mode:Off, front_drivers_window:Closed, front_pass_window:Closed, rear_drivers_window:Closed, rear_pass_window:Closed, valet_mode:Off, tire_pressure_front_left:0.0, tire_pressure_front_right:0.0, tire_pressure_rear_left:0.0, tire_pressure_rear_right:0.0], climateState:[temperature:50.9, thermostatSetpoint:69.8, seat_heater_left:0, seat_heater_right:0, seat_heater_rear_left:0, seat_heater_rear_right:0, seat_heater_rear_center:0]]

Driving:
tire_pressure_front_left:3.2, tire_pressure_front_right:3.2, tire_pressure_rear_left:3.15, tire_pressure_rear_right:3.175

weird ok i will add the "or" post when the changes are ready for testing.

1 Like

ok new version on git hub with check for non zero and non null.. as a side recommend you edit your post and zero out your vin above.

im on 2022.12.3.1 as of yesterday.. model 3..
i paid for fsd but no way i am (or probably anyone) is going to get a 98 or 99 driving score driving in any kind of city traffic.. Not a bigee for me right now as the car ffs up regularly with just the normal auto drive.

Thanks. I updated and will test.
Thanks for the note on the VIN... but it's fake. Would be neat to get VIN 123456 though :grinning:
I'm in NYC, which is also almost impossible to get a good score, but I mostly drive back and forth to and nearby my country house, so I was able to get to a 98 by pretending that I'm not an impatient driver.
I also bought FSD for my 2017 Model X and never got to use it, so maybe they felt bad for me when I got my Model Y. Hope you can get FSD soon. It's actually getting quite good. The other week I was able to do a full 20 mile drive with stop signs, traffic lights, unmarked roads and had no interventions and very few foot-hovering-over-brake moments.

1 Like

Having some trouble with the Tesla Connect Hubitat app that I'm hoping someone can help me with.

For some reason, the SSO token from TeslaFi (or Tesla Tokens Android app; have tried both) is working for me (until it expires in 8 hours or whatever), but when I put in the refresh token (which apparently stays valid for 45 days?), after clicking next, nothing shows up in the drop-down menu, the one where I am able to select my vehicle name when I use the original token. Everything works, using the latest code from GitHub, until the token expires.

I'm not sophisticated enough to figure out how to self-generate tokens to a URL, and I obviously don't want to replace the token every eight hours (which generates a new "device" for the vehicle), so I'm hoping someone can shed some light on what I may be doing wrong with the refresh token.

Thank you!

Yeah I mentioned this a while back, and have been dealing with it as well starting around the beginning of April.

(Seems like you know, but to explain for others)
Tesla provides 2 types of tokens. Access token which allows control, and refresh token which allows viewing. Though, it seems the refresh token only pulls in powerwalls, and not vehicles. I am not sure if that is a configuration in the Tesla connect app (from the dev side), or provided on Tesla's end.

Unfortunately, everyone is going to hit this issue when their current token expires, so I am guessing its going to be a pretty quickly addressed issue as it leaves the app useless having to manually refresh every 8 hours.

It would be nice if we could pull the tokens from the URL (as Teslafi and others are doing now) within the tesla connect app. I signed up for the 14 day trial on Teslafi just to understand better how its done, and it seems they use the URL to pull tokens, and refresh automatically. I looked at the link a little bit, but didn't see my tokens provided in the URL. I'm no web developer, so this exceeds my abilities to help :grinning:

1 Like

Hi @kahn-hubitat… ran into something else in the driver. It looks like the windows are set to “number” attributes when they are actually reporting string open or closed. This prevents the ability to use them in triggers or conditions (example at bottom). I changed in my version as shown below, but could you review and update if you’re seeing the same thing affecting you? Thanks!

attribute "front_drivers_window" , "string"
attribute "front_pass_window" , "string"
attribute "rear_drivers_window" , "string"
attribute "rear_pass_window" , "string"
Tesla reports front_drivers_window(Closed) *contains* Open and stays that way for: 0:15:00

I’m also using TeslaFi and had an issue when I tried to update the token to Tesla Connect yesterday. The issue for me is if the token doesn’t work (unauthorized), and then I reset it and get it to work, it creates a new device and deletes the old one, which breaks all of my rules that used the deleted device. I’m trying to figure out the process that makes this NOT happen, so I’ll post an update when I figure it out.

Also for this who don’t use TeslaFi, I definitely recommend it. Aside from the auto token refresh, a bunch of cool stuff for data geeks.

1 Like

So this has been working pretty good for me, and I haven't had to fix devices for a while since figuring it out.

  1. Get access token
  2. Open settings for tesla connect
  3. Paste in URL and hit next
  4. When it prompts for devices dont touch anything and hit next again. If you deselect your device it will unpair it and you will have to repair all your automations

This seems to work well for me. If you only have 1 car (like I do) the name will show up at the beginning of step 4. If you see the correct name, everything is good. I guess if it didn't show up for some reason, you may have to reselect and repair automations.