I really appreciate the new Volvo support and looking forward to other car brand supports. I’m especially interested in a support for tracking down Teslas.
I learned that Tesla has an officially undocumented API, which is somewhat documented[1].
I would love to see support for Teslas beeing build into Home Assistant!
Looks like a really straight forward API. There are already some (hackish) python packages that could be used as inspiration or even backend (e.g. pytesla, teslajson).
So if somebody lends me the hardware I am willing to implement that
I’ve created a script to poll tesla and publish to my own mqtt to get the data into hass. It works fine, and their API contains a lot of data. Only trouble so far is that when I keept asking them every 5 minute day and night, they blocked access to the vehicle (including the mobile app). Not very popular, as it isn’t my car. =)
But I’m thinking it may not be that hard to turn my script into a proper hass module. Just want to make sure no one else is working on it yet.
I’ve been looking at doing this now that I’ve gotten my car. Would you be interested in working together on this?
I was thinking of only querying for data on triggers of presence automation. Like when the vehicle gets home query it after 5 minutes and then again when it leaves. While it’s away from home I might doing it on an interval. But at least when it’s home I know it’s parked so don’t need to query that often and can work out charging as hass switches and such.
As I think about this I’m not sure which way to go. Maybe I can get some suggestions?
My first thought was to just hook into the API and not do an MQTT bridge. Really basic and can show us plenty of info and even set things.
Second thought is to go about making a VisibleTesla replacement in python. I don’t think it’d be appropriate to put that in HA though so I’d use an MQTT bridge to pass data to/from it to HA. I’m leaning this way but I’m not that great at UI work so that makes it a bit daunting.
The module should not use MQTT. That was just the easiest way for me to get something working right away.
Hadn’t seen VisibleTesla. Cool, but not really usefull in Home Assistant. I don’t think you should rewrite it in python. =)
Let’s start by picking one of the example modules, and replace stuff in it with tesla. A first goal can be to just read tesla credentials from the hass config, and show the name of the car.
And we definately need some way of limiting queries to the API, so we don’t flood them with requests and lock access to the car. I don’t know if that’s something easily done in the examples.
Limiting queries is easy enough. I’m thinking of all the fun things I can do though.
Use IFTTT to tell HA that my phone is connected to car bluetooth. Then if HA detects my car is driving and I’m not connected to bluetooth to send me an alert
There is a streaming API also, which I don’t think we’d use inside of HA. That’s what got me thinking about the VisibleTesla in python, since VT hasn’t been updated in 2 years. But it would be useful to grab running data and publish to MQTT that HA could read as it wanted.
I think the mentioned block by the api might be wakeup call issue. You can ask the api if the car is awake or not.
Since the location of the vehicle should be the trigger, like when it’s driving from the highway towards home HA can detect this as a trigger to turn on the heat and if the car is near the driveway it can enable the lights in the driveway and if the car is on the driveway it can open the garage.
This is only supported if we have triggers, like motion sensor to the driveway which then uses the last fetched car position which was near of the home but not in the garage while the mobile phone of the owner was already logged into the wifi, than it’s safe to open the garage door.
If you only poll the car status very rarely such stuff is not possible, and the polling might take a long while, so this might be not fast enough for realtime responses.
It would be nicer if polling would be possible all the time. Means that only a constant wakeup of the car would trigger these issues with the API. If the car is already moving a polling should be no issue and if the car is not already awake it’s not moving.
So the plugin would be much more helpful if we can sort out what triggers the block by the API-Server first.
Maybe possible to trigger when the car is near home and plugged in? I always plug in the car when I park the car in the garage
The things I would use the most would use the most is to see charge status, battery % and set charge level and start charge from Home Assistant. Is just great to have everything in one place.