Tesla Integration to Query Status and Send Commands to Your Car

or the samsung arrival/presence sensor which i still use for our two cars in mich and my wifes car and it works very well to open/close the garage door.

However, they are no longer available and tend to break easily replacing the battery, which is why i have spares in the basement.. i also on my wifes soldiered it into a 2 aa battery case which so far lasts for over 2 yrs.

What I’m doing with Teslamate has been very reliable, the door opens as I’m pulling into my driveway every time. I have an extremely old garage door, that doesn’t even have remote capabilities (I use a zen16 to trigger it). So even if I wanted to spend the couple hundred to add home link to the car, it wouldn’t help me.

how often are you polling the api

I don't know how telsamate collects its data, but I don't believe it uses polling at all. I think there is some sort of streaming API/websocket API it uses to interact and collect data about the car without polling and constantly waking the car up from its sleep.

For example, it's collecting very precise data throughout a drive, that it wouldn't be able to do via polling at all.

no the only way to get data is via the api.. from the looks of the graph it is polling or querying the api every 30 sec.
it could be an open mqtt socket somehow to the api.. seems neat.. but there is no other way to get data.

You’re speaking in absolutes, but I don’t believe you are correct. Just looking at the code, there is a streaming API endpoint it uses, looks like a web socket.

Don’t think I suggested it wasn’t using an API.

Also incorrect, there are in some cases multiple datapoints per second. Might want to use it before trying to interpret how it works.

It’s in a language I don’t know, but it’s pretty clear that it using a Tesla streaming api of some sort provided via a web socket. Which is distinctly different from polling.

The use of MQTT is on my side, Teslamate publishes data to a MQTT topic.

1 Like

Maybe this is where I'm getting hung up. I read this as if the driver is present in the car. And not as the car is present at home. My M3 has been parked in my driveway for about an hour now and the presence is showing Not Present.
image

Am I correct in this will show present when there is a driver in the seat? If so, am I better off with something similar to your suggestion? If Lat/Lon is between X/Y (+/- a little), then the car is at home? Or is there an alternate way to know that the car is at home.

no it should show present when the car is present. turn on debuggin and try a wake and refresh and post the output.. most likely your token has expired or something.

have you set the home location in the car if under navigation.

A couple of hours ago I updated the driver to your latest and noticed that my car wasn't showing up in the app drop down. I generated a new token and reconnected the car to the app. My child device was removed and recreated. The Not Present screenshot I shared was from after the token. I'll enable debug and post the logs.

Yes - This is set correctly and to my address

Output from wake then refresh. Showing presence Not Present

[dev:1125](http://192.168.0.14/logs#dev1125)2022-04-01 03:15:47.673 pm [debug](http://192.168.0.14/device/edit/1125)climateState = [temperature:100.22, thermostatSetpoint:71.06, seat_heater_left:0, seat_heater_right:0, seat_heater_rear_left:0, seat_heater_rear_right:0, seat_heater_rear_center:0]
[dev:1125](http://192.168.0.14/logs#dev1125)2022-04-01 03:15:47.668 pm [debug](http://192.168.0.14/device/edit/1125)vehicle state = [presence:not present, lock:locked, odometer:39163.034748, sentry_mode:On, front_drivers_window:Closed, front_pass_window:Closed, rear_drivers_window:Closed, rear_pass_window:Closed]
[dev:1125](http://192.168.0.14/logs#dev1125)2022-04-01 03:15:47.665 pm [debug](http://192.168.0.14/device/edit/1125)DriveState = [latitude:33.*****, longitude:-117.*****, method:wgs, heading:18, lastUpdateTime:Fri Apr 01 15:15:47 PDT 2022]
[dev:1125](http://192.168.0.14/logs#dev1125)2022-04-01 03:15:47.662 pm [debug](http://192.168.0.14/device/edit/1125)chargeState = [battery:49, batteryRange:139.81, chargingState:Disconnected, chargeLimit:80, minutes_to_full_charge:0]
[dev:1125](http://192.168.0.14/logs#dev1125)2022-04-01 03:15:47.659 pm [debug](http://192.168.0.14/device/edit/1125)processData: [state:online, motion:inactive, speed:0, vin:5YJ************, thermostatMode:off, chargeState:[battery:49, batteryRange:139.81, chargingState:Disconnected, chargeLimit:80, minutes_to_full_charge:0], driveState:[latitude:33.*****, longitude:-117.*****, method:wgs, heading:18, lastUpdateTime:Fri Apr 01 15:15:47 PDT 2022], vehicleState:[presence:not present, lock:locked, odometer:39163.034748, sentry_mode:On, front_drivers_window:Closed, front_pass_window:Closed, rear_drivers_window:Closed, rear_pass_window:Closed], climateState:[temperature:100.22, thermostatSetpoint:71.06, seat_heater_left:0, seat_heater_right:0, seat_heater_rear_left:0, seat_heater_rear_right:0, seat_heater_rear_center:0]]
[dev:1125](http://192.168.0.14/logs#dev1125)2022-04-01 03:15:46.858 pm [debug](http://192.168.0.14/device/edit/1125)Executing 'refresh'

weird it should show like this.. it should know you are home.. try setting it to your actual address and saee if that fixes it..

does anyone elses show present without having homelink active in their car.. maybe as summizaed it is tied to that I cannot find much info on the attribute.. Tesla does not really document their api.. no suprise there.

It is set to my actual address.
As a work around, I could set my "home" based on the Lat/Lon, with a few degrees of difference. I don't need the immediate update. I only want to know if I'm charging between peak times or forgot to plug in the car.

Can confirm my Model 3 without homelink is showing not present at home. It is currently in the garage, and charging. The car seems to recognize my address well in terms of not running sentry or locking at home (which are the settings I want since it is always in a garage). Presence seems to be homelink controlled (or enabled when homelink is installed)

image

So it looks like Tesla changed the authentication token again so it resets after 8 hours instead of weeks. Anyone else seeing this? Or is it something related to the app I am using to get my token?

I'm not seeing this. I juat use teslafi and cut anf paste my token. Ive had yge same for about 2 wks now.

1 Like

@snell has logic in Pulling data out Tesla Powerwall that will get and refresh the token in the app. Any chance of incorporating that?

Good to know. I was using the Tesla Tokens app on Android and it was working good for me for a while. Though I went to update yesterday and it had a notice saying Tesla changed their token authentication time to 8 hours. Guess I'll need to look into other methods to update it.

This would be a nice addition, or even if there was a way to use that driver / app to get the token into a global variable into Hubitat which then the Tesla connect app could reference

2 Likes

@kahn-hubitat - I updated the driver and app to include valet mode indicator (my garage is valet) and tire pressure for the four tires. Will you add in for the community if I send to you?

valet_mode : On
tire_pressure_front_right : 44.0
tire_pressure_front_left : 44.0
tire_pressure_rear_left : 44.0
tire_pressure_rear_right : 44.0
1 Like

sure send me the code

ok integrated the changes above re tire pressure and valet mode with a slight change.

code was fine as is.. but noticed it would set tire pressures to NULL while parked as the car does not read tire pressures till you start moving.

So to handle this change tire presssure(s) attributrs to stirngs and set them to n/a when parked or pressures are not know.. Also related added last_known tire pressure attributes that only get set when value is not null..

new version on git hub.

1 Like