Tesla Integration to Query Status and Send Commands to Your Car

Hello All,

I was looking for an integration to basically alert me if the Tesla (Car) battery is below a specified % at a specific time daily. If it is either plugged-in or above that % it will not do anything.


Tesla integrates with IFTTT, right? You can create a virtual switch and turn it on with a trigger from IFTTT.

Mind Blown! I just installed the trentfoley driver and app from SmartThingsPublic/tesla.groovy at master · trentfoley/SmartThingsPublic · GitHub and SmartThingsPublic/tesla-connect.groovy at master · trentfoley/SmartThingsPublic · GitHub

Incredibly it worked with only one edit, I had to comment out line 20 in the driver, I guess Hubitat doesnt support capability Geolocation.

So now you have your car(s) as device(s) in HE, you can freely use the attributes in RM to generate notifications.


Any ideas on the child issue I am getting:

No signature of method: Script1.definition() is applicable for argument types: (java.util.LinkedHashMap) values: [[name:Tesla Connect, namespace:trentfoley, author:Trent Foley, ...]]

Did you take the quotes out around the metadata? You must have edited something incorrectly.

You really want to be able to do all this from Hubitat? Remember, this isn't happening in the cloud, it's happening on your hub. So, every resource you put to processing your car's info (while you're home I might add) means something else isn't happening as quickly. It's cool yes. But what are you going to use this for? The location part and charge part I totally get. But all the rest of the data seems a bit over kill to me.

It didnt require any edits apart from commenting the capability Geolocation line 20 in the driver.

I literally just pasted the app and driver in, commented line 20 in the driver, and ran it. It just worked.

Tesla Connect is the App, Tesla is the device driver. You run the App and log in and it creates the child device, one per vehicle.

Yeah...but that might not be what he did when he copied it. He's the one with the problem so I was asking him. :slight_smile:

I am the 4th day into Hubitat and have not added App or Drivers code yet, how can you tell which code is which.

Thank You

I got them to work by pasting them in each until they succeeded, but I still want to know how you tell App vs Driver scripts apart.

Also, is there a want to sense if the car is already plugged-in, I know that is a variable that tesla provides.

Thanks Again

And one last question: I can't seem to get the battery % to show in a dash tile for the Tesla, any ideas?


In general...

If the code has a "metatdata" section, it is a driver... The "definition" section will be inside the "metadata" section. A driver may/will also have "capability" and "command" statements in the "definition" section.

In an App, the "definition" section will not be inside a "metadata" section, and the "metadata" section will not exist. The definition will have a "category" entry, and possibly an "iconUrl" entry.

Thank you :slight_smile:

To get the battery tile, choose the car, then choose battery.


check out the attribute named chargingState, mine shows "disconnected", I would guess it might show "connected" or "charging" although I haven't tested this yet.

Edit: update, I just checked and it seems to show Complete if its plugged in and charged, Stopped if its plugged in and ready to charge but not charging, and sure enough, it says Charging when....well you get it.

1 Like

I don't understand how you can say both of those things. You can't possibly be getting an error if you haven't pasted the code into hubitat yet.

Heres a minor edit I figured out to fix the lastUpdateTime

edit line 78 of the app to say

return new Date((long)epoch * 1000);

Sorry I was testing as I was typing :slight_smile:

OK we will see if this works later tonight :slight_smile:

When time is 7:00 PM CDT
Eve becomes chargingState(?) = Stopped
Eve becomes chargingState(?) = Charging
Eve becomes battery(?) < 40.0

IF (Time between 7:00 PM CDT and 7:02 PM CDT(F) AND
Battery level of Eve() is < 40(T) AND
NOT Eve chargingState() = Stopped(T) AND
NOT Eve chargingState() = Charging(T) [FALSE]) THEN
Notify Pixel 3 and Speak on Office Speaker, Tristen Room Speaker, Garage speaker, UpstairsBath Google Mini, Laundry Room speaker, Master Bedroom Speaker, Living Room Speaker, Kitchen Display, Master Bath Speaker: 'Eve's battery is under forty percent, please plug her in.' --> delayed: 0:00:10

So cool. Just wish we could buy Tesla in Thailand and Singapore where I'm based. Shame on these governments for not supporting/allowing it...

As an update, yesterday I noticed the device was failing to update from the Tesla API saying "no data found for ", apparently they may periodically change the ID of the vehicles. I found I needed to go to the Tesla Connect App and re-login and click next, this generated the new vehicle ID in the log. I did not proceed to select the vehicle and click done, as this probably would have caused the app to try to create a new vehicle device. I then edited the DNI of the existing vehicle device to be the new ID, save prefs and refresh, and it all started working again. No idea if it would have automagically figured this out for itself eventually, or if there is another way to fix it, but this worked for me.

Download the Hubitat app