I wonder if anyone with any JSON-based web API integration experience for HA might consider creating an integration for the TeslaFi.com website API documented here: https://teslafi.com/api.php
The API itself seems very simple - it returns a json blob with a bunch of data related to your vehicle, and can issue a few basic commands to the car.
Why is this interesting if there is already a Tesla car API integration? Two reasons: (1) the API returns not only car data, but some additional data derived by TeslaFi.com that is interesting, and more importantly (2) TeslaFi.com has some very good polling algorithms that when setup correctly donāt get in the way of the car sleeping or excessively drain the battery. Conversely, the existing Tesla integration seems to poll the car indiscriminately every 300 seconds (or what you set the poll interval to be) which can have a big impact on sleep states/battery.
Doesnāt TeslaFi require you to hand over your Tesla account credentials?
Many people prefer the HA approach as the credentials are stored locally. This is like handing over your car keys; hope you trust TeslaFi and also their ability to keep user data safe.
I agree that the current integration leaves a bit to be desired for polling, but it now has a switch entity exposed to disable polling. I have my refresh interval set at 10 minutes and a couple automations in place:
disable polling if battery is below 20 and the car is stationary and unplugged
enable polling if my juicebox EVSE is plugged in (canāt rely on the Tesla sensor since this wonāt be polled)
enable polling if any of my other device trackers show me moving > 30mph within 1/2mi of the last known position of the vehicle (assumes Iām in the car and moving)
I would love to see this done with an integration but I do have some basic data from Teslafi by using the REST sensor platform.
To counter @snicker TeslaFi does not store your password, you donāt even have to give it to them if you are capable of requesting your own API key, which isnāt all that hard especially for those who already play with HA under the hood. But even if you do put your password into their website, they donāt store it, they use it to request an API key and a refresh token (if you allow them the latter) and API key based access doesnāt allow you to remote start the car.
But anyway, the question was not āshould I use TeslaFiā but āIs there an integration for this APIā
I wrote an integration for TeslaFi in SmartThings, with a service connect SmartApp and a custom device handler (actually split into 5 separate components for better visibility in the new app): https://github.com/jhansche/st-teslafi-v2
I was also looking for a way to do the same integration in Home Assistant. It looks like creating a new component is significantly more involved than I was anticipating, but I plan on giving it a shot. If/when I have something to share, Iāll update it here.
@millercentral Have you tried this TeslaMate service, and if so were you able to integrate it in HA? Iām wondering if going the self-host+MQTT route might make for an easier integration
So, I didnāt move forward with my custom integration. But I did come across the rest and template sensor types, which kind of work great together for exactly this purposeā¦
Define teslafi_api_token inside secrets.yaml, which you can get from https://www.teslafi.com/api.php. That creates a single device with all those attributes extracted from the JSON data.
Next, you can create individual sensor entities using the template sensor type:
Teslamate has been great for integrating MQTT read-only sensors. I never actually use the official Tesla integration on HA (even before it was removed) just because I was worried about polling intervals and vampire drain, but I was considering looking into the custom integration and just setting the polling interval super high while retaining use of the MQTT sensors.