Table of Contents
Summary
In this video, we explore the newly integrated Tesla Fleet API in Home Assistant, guiding you through the setup process and showcasing how it can enhance your Tesla experience. We demonstrate practical automations, such as automatic garage door control and custom charging reminders, that streamline your daily routine and make your smart home even smarter. Whether you’re looking to monitor your Tesla’s performance or set up advanced automations, this video provides all the insights and tools you need to get started.
Video
Blog Post
Elevate Your Tesla Experience with Home Assistant: A Step-by-Step Guide
The Tesla Model Y is already an amazing vehicle, but what if we told you there’s a way to make it even better? By integrating your Tesla with Home Assistant, you can unlock a new level of automation and convenience in your daily routine. In this post, we’ll walk you through the process of setting up the Tesla integration in Home Assistant, explore the various features it offers, and share some practical automations that can make your life easier.
What’s New with the Tesla Integration?
With the release of Home Assistant 2024.8, the Tesla integration has been significantly enhanced, thanks to the introduction of the Tesla Fleet API. This new API allows for more robust monitoring of your Tesla, although it currently only supports read-only data access. That means while you can track your Tesla’s status and metrics, you’ll need a custom integration to control features like opening the trunk or adjusting settings.
Why Integrate Tesla with Home Assistant?
If you’re a Tesla owner, you’re probably already familiar with the vehicle’s preheating and charging schedule features. But with Home Assistant, you can take things a step further. Imagine driving up to your house and having your garage door open automatically, your lights turn on, and a custom charging reminder pop up if you forget to plug in your car after a busy day. These are just a few examples of what you can achieve with the Tesla integration in Home Assistant.
Setting Up the Tesla Integration
Setting up the Tesla integration in Home Assistant is straightforward. All you need is a Tesla account and a Home Assistant instance running version 2024.8 or later. Simply follow these steps:
- Go to the Home Assistant documentation and locate the Tesla integration under the “Vehicles” section.
- Click “Add Integration to My Home Assistant,” which will guide you through the setup process.
- Log in with your Tesla credentials, and if you have two-factor authentication enabled, enter the code when prompted.
- Once completed, you’ll be redirected to the integration screen where you can explore the various devices and sensors now accessible through Home Assistant.
Exploring the Tesla Sensors
The integration offers a wide range of sensors and diagnostics that provide detailed insights into your Tesla’s performance. From battery percentage and range to more advanced metrics like inside and outside temperatures, these data points can be invaluable for creating smart automations.
For instance, you can track your car’s battery level over the past 24 hours, monitor the current charge state, and even see the estimated range based on your battery’s current percentage. Additionally, you can enable or disable specific sensors depending on your needs, allowing for a fully customized monitoring experience.
Automations You Can Set Up Today
Here are a few practical automations that you can implement using the Tesla integration:
- Charging Reminder: If your car’s battery falls below a certain percentage and it’s not plugged in, Home Assistant can send you a reminder to charge your Tesla. This is particularly useful if you prefer to keep your battery at an optimal level, around 50-70%.
- Automatic Garage Door: Imagine waking up in the morning, unplugging your Tesla, and having your garage door open automatically based on the time of day and weather conditions. This automation can streamline your morning routine and save you time.
- Arrival and Departure Automations: Set up your garage door to open when you arrive home and close automatically when you leave. You can even trigger a “Goodbye” automation that locks the doors, arms the security system, and turns off unnecessary lights when everyone has left the house.
Advanced Features and Future Plans
While the current integration only allows for monitoring, there’s also a custom Tesla integration available for those looking to control more of their vehicle’s features. If you’re interested in automating things like opening the trunk or adjusting the climate control, stay tuned—we may cover that in a future post.
We’re also working on some additional automation ideas, like launching the Waze app when you start navigating during rush hour, which could provide real-time traffic updates and alerts for speed traps.
Conclusion
The Tesla integration in Home Assistant is a powerful tool for any Tesla owner looking to enhance their smart home setup. Whether you’re automating your garage door, setting up custom notifications, or just keeping a closer eye on your car’s performance, the possibilities are endless.
If you have any questions or want to share your own automation ideas, feel free to leave a comment below or join our Discord community. We’re always excited to hear how others are leveraging smart home technology to make life a little easier.
Code Examples
Custom Charging Reminder Notification
alias: Tesla - Charge Reminder
description: ""
trigger:
- platform: time
at: "20:00:00"
- platform: state
entity_id:
- device_tracker.sparky_location_tracker
from: not_home
to: home
for:
hours: 0
minutes: 5
seconds: 0
condition: []
action:
- choose:
- conditions:
- condition: time
after: "20:00:00"
- condition: state
entity_id: device_tracker.sparky_location_tracker
state: home
for:
hours: 0
minutes: 1
seconds: 0
- condition: state
entity_id: binary_sensor.sparky_charger
state: "off"
- condition: numeric_state
entity_id: sensor.sparky_battery
below: 70
sequence:
- metadata: {}
data:
title: Charge Sparky
message: >-
It is 8pm and it looks like Sparky is unplugged and under 70%.
You might want to plug him in!
emergency: false
action: script.notification_bridge
alias: 8pm at Home Under 70%
- conditions:
- condition: state
entity_id: binary_sensor.sparky_charger
state: "off"
- condition: state
entity_id: cover.small_garage_door_door
state: closed
- condition: numeric_state
entity_id: sensor.sparky_battery
below: 70
- condition: time
after: "20:00:00"
sequence:
- metadata: {}
data:
title: Charge Sparky
message: >-
It is 8pm and it looks like Sparky is unplugged and at {{
states('sensor.sparky_battery') }}%. You might want to plug him
in!
emergency: false
action: script.notification_bridge
alias: Just Got Home Unplugged Under 70%
mode: single
Open Garage Door When Tesla Unplugged
alias: Tesla - Open Garage Unplugged
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.sparky_charge_cable
to: "off"
from: "on"
condition:
- condition: time
after: "05:30:00"
before: "09:00:00"
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
- condition: numeric_state
entity_id: sensor.lacrosse_view_temperature_2
above: 40
action:
- metadata: {}
data: {}
target:
entity_id: cover.small_garage_door_door
action: cover.open_cover
- metadata: {}
data:
title: Tesla Unplugged
message: I see you unplugged the Tesla. I opened the door for you!
emergency: false
action: script.notification_bridge
mode: single
Open Garage Door on Tesla Home
alias: Tesla - Open Garage Home
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.sparky_location_tracker
to: home
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.large_garage_door_contact
state: "off"
- condition: state
entity_id: sensor.sparky_shift_state_2
state: d
- condition: state
state: closed
for:
hours: 0
minutes: 5
seconds: 0
entity_id: cover.small_garage_door_door
action:
- data: {}
target:
entity_id: cover.small_garage_door_door
action: cover.open_cover
- metadata: {}
data:
title: Welcome Home
message: I have opened the small garage door for you.
emergency: false
action: script.notification_bridge
- metadata: {}
data: {}
target:
entity_id: switch.garage_light
action: switch.turn_on
- condition: sun
before: sunrise
after: sunset
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id:
- light.south_wall_light
- light.north_path_lights
mode: single
Open Garage Door on Tesla Away
alias: Tesla - Away Close Garage Door
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.sparky_location
from: home
to: not_home
condition: []
action:
- choose:
- conditions:
- condition: state
for:
hours: 0
minutes: 0
seconds: 30
entity_id: cover.small_garage_door_door
state: open
- condition: state
entity_id: sensor.sparky_shift_state_2
state: d
for:
hours: 0
minutes: 0
seconds: 10
sequence:
- target:
entity_id:
- cover.small_garage_door_door
data: {}
action: cover.close_cover
- metadata: {}
data:
title: Goodbye
message: I closed the garage door for you.
emergency: false
action: script.notification_bridge
- condition: state
entity_id: group.all_mobile_devices
state: Away
- action: script.away_mode_wait_and_check
metadata: {}
data: {}
alias: Check if S Garage is Open 30 Sec & In D for 15
- conditions:
- condition: state
for:
hours: 0
minutes: 0
seconds: 30
entity_id: cover.small_garage_door_door
state: open
- condition: not
conditions:
- condition: state
entity_id: sensor.sparky_shift_state_2
state: d
for:
hours: 0
minutes: 0
seconds: 15
sequence:
- action: homeassistant.update_entity
data:
entity_id:
- sensor.sparky_shift_state_2
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- condition: state
entity_id: sensor.sparky_shift_state_2
state: d
- metadata: {}
data: {}
target:
entity_id: cover.small_garage_door_door
action: cover.close_cover
- metadata: {}
data:
title: Goodbye
message: I closed the garage door for you.
emergency: false
action: script.notification_bridge
- condition: state
entity_id: group.all_mobile_devices
state: Away
- action: script.away_mode_wait_and_check
metadata: {}
data: {}
mode: single
Tesla Integration – Refresh on Camera Detection
alias: Tesla - Driveway Motion Refresh
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.driveway_vehicle
to: "on"
condition:
- condition: state
entity_id: device_tracker.sparky_location
state: not_home
action:
- action: homeassistant.update_entity
data:
entity_id:
- device_tracker.sparky_location
mode: single
Video Transcript
Full Video Transcript
So, what can make the best-selling car of 2023 even better? If you have a Tesla, you already know you can have it preheat—pretty cool—and even set the charging schedule automatically. However, if we integrate it with Home Assistant, we can add some features like having it automatically open an integrated garage door when you get home and turn on your lights at night. We can have it send you a customized charging reminder if you forget to plug it in at the end of a busy day. You can even have it automatically shut your garage door, activate your alarm, run your vacuums, and turn off your lights before you leave in the morning. So stick around as we check out the new Tesla integration for Home Assistant and show you how to make your smart home even smarter.
Hey there, neighbors. I’m Ryan, the tech guy. Welcome back to This Smart House, your source for the latest in smart home tech and great smart home projects. Starting with the 2024.8 release, Home Assistant now fully supports the Tesla integration. This change came after Tesla updated their API to the new fleet API, which added a lot of extra overhead to the existing Home Assistant Tesla integration that existed before this one.
Back in March, I picked up my new 2024 Model Y Long Range, after the unfortunate demise of my beloved Volvo S60. Just when I got my new Tesla, I found out that the Home Assistant integration had broken due to this API change. Luckily, another set of developers created a custom Tesla integration that did work with the fleet API. However, this required a whole bunch of extra steps, including setting up a dedicated domain and running an extra plugin on your Home Assistant instance.
Thankfully, in this latest edition of Home Assistant 2024.8, you can now do the basic Tesla integration. This means you can read data from your Tesla, but you can’t actually control any of the functions of the Tesla from Home Assistant. That custom integration still works today, and if you’re interested, I can do an entire setup video on it later.
So let’s head back to the office, and I will show you how to get the integration set up and take you through each of the features of this integration. The Tesla fleet integration that’s now built into Home Assistant is super powerful and a very easy way for you to monitor your car and also use your car as inputs into Home Assistant to create new automations.
Setting up the integration is super easy. All you need to do is go to the URL down below or check the links in the description. You can also go through the Home Assistant documentation, look for “vehicles,” and find the Tesla integration from there. All you really need to do is have Home Assistant 2024.8 or later, and a Tesla username and password, which you should already have if you have the Tesla app set up on your phone.
Click on “Add integration to my Home Assistant,” and that’s going to open up the My Home Assistant tool to set up the integration for you. If it’s the first time you’ve done this, you may have to enter your URL. Then once you get in, it’s going to ask you to accept, and then we’ll log into our Tesla account with our email address and password. If you have two-factor authentication activated, you’ll enter a code here. Once this goes through, Home Assistant will prompt you to save your credentials. Then you’ll be taken back to the integration screen. We can also navigate there by going to our integrations and scrolling down to Tesla Fleet. Then we’ll click on the one device.
Let’s take a quick look at all of the various items that it exposes. One quick note: if we pop over to the Tesla Fleet documentation and scroll down to the bottom, we’ll see a list of every one of the sensors that’s exposed for both a Tesla vehicle and a Tesla Powerwall. You will notice that some of these are marked as not enabled by default. If you want to enable these, it’s very simple, and I’ll show you how to do it here in just a second. Don’t be afraid if you see something on this list that’s not on yours when you first set it up.
When we get into the integration, we’ll see up here at the top right-hand corner we’ve got the battery percentage, which is attached to the device. This is your battery level for the Tesla. If I click on this, it’ll show me the battery levels for the last 24 hours. If I click on the title here, it’ll make a nice wide graph for me to take a look at. Over here to the left, we’ve got the serial number, which is actually the VIN of the Tesla. Then you’ve got a bunch of sensors and diagnostic information.
The sensors include things like battery range, which is the estimated range of the vehicle with the current battery percentage in miles. There’s also charge energy added during the last charging cycle—12.5 kWh in my case. The current charger power is also shown; it’s zero when not charging. You can see a binary indicator for whether it’s charging or not. The distance to arrival, inside and outside temperature, and current shift state (which isn’t enabled by default—I’ll show you how to turn that on) are also available. The speed, status, time to arrival, and user presence (a variable to know if someone is in the vehicle or not) are also accessible.
So, real quickly, let’s talk about the arrival time, time to arrival, and route. If you’re using the onboard navigation in the Tesla, then this will populate with whatever the address of the destination is under the route here. This means you can actually see where the vehicle is navigating to. Another cool thing for both the current location of the Tesla and where it’s going is that if you have this address as part of a zone, like “Home,” it shows up in Home Assistant as “Home” and not just an address. That’s pretty cool. The same applies to the location; it shows the current location of the vehicle, whether it’s home or away.
Back up here at the top, we’ve got time to arrival and distance to arrival. These are both variables that are only available when you’re doing navigation. In this case, the vehicle’s off, so it’s unknown, but if I were going somewhere, this would tell me how much distance is left in the trip and how much time, which is great for automations. You can set up a notification to let your loved one know you’re on the way home. That’s a cool way of doing that.
Next, there are some items that are currently not shown in Home Assistant. To activate those, we need to click on them, click on the cogwheel, click “Enable” and “OK,” then click “Update.” In about 30 seconds, that variable should show up and will now be updated going forward. Under the diagnostics section, there’s a binary to show whether the charging cable is connected or disconnected, the current charging rate in miles per hour (meaning how many miles are being added to your vehicle per hour), and of course, if you’re using metric, I believe it’ll show up as metric on the dashboard. I have mine set to Imperial, so it shows up as Imperial for me.
We’ve got charger current and voltage, and then the current status of all the front doors and windows, and the rear doors and windows. At the bottom, we have time to full charge. If it were charging, it would estimate what time it would be done during this charging cycle. Occasionally, you will notice some of these will go unknown, which happens because when it updated, it didn’t get that bit of information. A quick way to refresh would be to go back to the integration, click the three dots, and click “Reload.” This will reload that integration. I’ll show you how to programmatically do that in just a minute.
These data points can be incredibly useful to create different automations or even send notifications or monitoring alerts. For example, if you wanted to come down here into the diagnostics and activate the odometer, this would be great for tracking things like maintenance cycles. When you hit, say, every 10,000 miles, you could use this as a notification or a to-do list to go get your tires rotated, and you can set that up for yourself automatically.
Just a quick note on polling limits: the API that Tesla provides for free only gives you 200 polls per day, meaning you can only check the status of the vehicle 200 times a day. The integration does a fantastic job of managing this. On other integrations, you had to change that polling rate manually. This one adjusts it based on whether you’re in the vehicle or not. It turns the polling rate up when you’re in the vehicle and turns it down when it’s parked to save some polls.
For the most part, you can let the integration take care of it for you. But there is a way to forcibly poll the API to have it update and refresh. You may notice a slight delay sometimes when you perform an action like unplugging the car; if you want it to do something, that’s because you’re between polling times. You can set up other automations to refresh, say, for example, on motion, and we’ll go into that in the automation section.
Again, this integration only provides read-only access to your Tesla. If you want to control things like opening and closing your trunk, charging port, or modifying different parameters, you’ll have to set up the custom Tesla integration, which is a lot more complicated. If you’d like to see a full video on that, please let me know in the comments below. I did set up a pretty cool automation using the Home Assistant companion app for my Samsung Android Wear Watch 2, where I can actually open and close my frunk and trunk right from my watch. Let me know if you’d like to see a video on that.
Now that we’ve covered what this integration can do, let’s look at some real-world automations that I use every single day.
For all these automations, you don’t have to worry about following along with the video. I’ve actually got all of them on a blog post attached to the URL down below. Feel free to go there or click on the link in the description, and you can just copy and paste my automations and adapt them for your specific device.
I’ve integrated both my large and small garage doors into Home Assistant. I have MyQ garage doors, and of course, we all know how difficult those have been to work with. So, I bought the right Argos and retrofitted them, and they have been fantastic ever since. If you want a full video on how to set that up, let me know. If you’re a Mac user, I highly recommend picking up one of those boards. They’re pretty easy to set up, and then you get complete local control and even more data from your garage doors than you did before. It’s really awesome.
These are all of the various automations that I’m currently using. Some of them are not really relevant because they’re only for the custom integration. The first one let’s talk about is a simple one: the charge reminder.
I know that the Tesla app has a built-in reminder, but it only happens at a certain percentage. I think it’s 30%. If you’re below 30% and you don’t plug in, you won’t get that reminder. I’m a bit of a battery nerd because that’s my day job, and I like to keep my vehicle right around 50% state of charge, so I don’t actually charge my Tesla more than usually 65% in a day. When I get home, I have about 40%, so I usually try to charge every single day because that’s the recommendation.
I’ve set this automation up to help remind me if I happen to forget to plug it in so I don’t have to be running low on charge the next day. How I have mine set up is at 8:00 at night, or when my car returns home, this gets triggered. Under “Do,” I’ve got a choice between two different actions. The first one says if it’s 8:00 and the vehicle has been home for at least a minute, and the vehicle is unplugged and its battery is below 70%, then it’s going to send that reminder for me.
I have this reminder sent out to me saying, “Hey, go plug in the vehicle.” This has actually saved me a few times from forgetting to plug it in for the next day to drive to work. The second option is if I’ve come home and the vehicle is unplugged, the garage door is closed, and the battery’s below 70% and it’s after 8:00, then it sends me a reminder to say, “Hey, it’s after 8:00. Go ahead and make sure you plug the Tesla in.” This is a simple one, but it has saved my butt quite a few times.
Another cool one that I use pretty much every day is the “Open the garage door when the Tesla is unplugged.” This is another very simple one, but again, it’s pretty cool because it helps speed up my morning routine. When the Tesla is unplugged, so when it goes from connected to disconnected for the charging cable, and it’s between 5:30 AM and 9:00 AM, and the outside temperature is above 40 degrees, then it goes ahead and opens my garage door. Of course, it sends a notification so I know what actually triggered it.
This is super helpful because in the morning, I’ll go ahead and unplug my Tesla, and as soon as I do that, the garage door opens up, and I can go open my trunk and throw my backpack in there. Again, very simple, but I think it’s a cool automation, and it really helps out during the day.
Next up are probably the two automations that were the biggest for me: opening and closing the garage door automatically when my car either gets home or leaves for the day. I’ll start with the easier of the two, which is opening the garage door when you get home.
When the vehicle gets to “Home,” no matter what time of the day, it’s going to check if my large garage door is closed and my car is in drive. So, effectively, if I pull into the driveway and put it in park immediately, it knows that I’m not wanting the garage door opened. But if I pull in and sit there with it in drive and my large garage door is actually closed, then it knows I want the garage door to open up. It’s also going to make sure that my garage door has been closed for more than five minutes. Then it’s going to open up my garage door, send me a notification, and turn on my garage lights. This is really nice because when I pull into my parking spot, it’s very tight, and it allows the parking assist to better see objects in my garage. Plus, I get to walk out at night into a lit-up garage.
You could easily add a condition for the time of day. For example, you could say after sunset and before sunrise. So, if you got home before sunrise or after sunset, it would turn on your lights. You could select your two outdoor wall lights, customize the color and brightness if supported, but that way when you get home, you may be waiting outside for 15 to 20 seconds until the refresh interval passes, and then the garage door opens automatically. I find that most days, because my home zone is set just outside of my house, I’ll actually turn the corner into my house, and the garage door will already start to open. This is used daily, and it’s been pretty much rock solid. You can, of course, customize all sorts of other requirements or items to block it from running if you do run into problems.
Now for the second half of this, which is about closing the garage door. As you can guess, it’s pretty much the exact opposite. When the vehicle switches from “Home” to “Away,” you can set a delay in here if you wanted to. But for the most part, I find that I’m usually a half mile down the road before this kicks in. So if you’re really concerned about someone getting into your garage, you might want to use another sensor to trigger a refresh and then have it trigger when you’re away.
Here, I have a choice, which basically gives two options to check. The first one checks to see if the small garage door is open for 30 seconds and if the car has been in drive for 10 seconds. This means I’ve backed out of the driveway completely, put the car in drive, and have pretty much moved around the corner by that point. This just prevents it from accidentally closing the door if I happen to be reversing out of the garage. In my case, it’s going to close the garage door, send me a notification, and then I have another set of items here. It’s going to check and see if all the devices in my house are gone. This means my wife, the grandparents—if nobody’s home, then it actually triggers an “Away mode” script. This will wait another ten minutes, check again, and if nobody’s there, it sets the house into away mode, setting the alarm, turning off the lights, etc. You can customize this to how you want your home to work.
For my case, I ended up putting a delay in there just in case someone’s phone wasn’t updating quickly. Now for the second option: this would be if the car goes from “Home” to “Away,” but I’m not currently in drive. So if I pulled up and stopped, it’s actually going to perform a forced refresh on the entity, which will then ping the API again. It will wait five seconds, check again, and then if it doesn’t detect it, it quits. But if it does, it goes ahead and closes the garage door and starts the away mode. I added this in there because I did have a bug at one point where it would sometimes detect me as away, but then the shift status would go unavailable, so the automation wouldn’t fire. This way, I’ve got it set up to where it’ll actually wait, refresh, wait another five seconds, and then do it again.
The last thing I have to do—and I haven’t set it up yet—is a last-ditch effort where it actually sends me a text message saying, “Hey, nobody’s home, the garage door is still open. Do you want to close it?” That’s something I’ll add in later on, but so far, it’s always triggered eventually. It may have been an extra 30 to 40 seconds after I left the house, but it’s always triggered after I left the house.
All right, one quick thing I forgot to show is a specific example of forcing the Tesla integration to refresh based on something else happening. In this automation, I have it so that if my Reolink driveway camera detects a vehicle (because it has onboard vehicle detection), it triggers this action, but only if the Tesla is away. It then performs the action of a Home Assistant integration update entity. This forces an update on the location of the vehicle, which should allow my other automations to fire.
Effectively, how this would work is if the driveway camera detects a vehicle in the driveway, it will update the Tesla’s location, which should trigger the open garage door automation. You could, of course, use any other entity to trigger this. For example, you can even set up something like using your location from your Home Assistant companion app when your vehicle’s away, or if your vehicle’s home, you can use a motion detector in your garage to trigger a refresh to check and see if something happened, like unplugging your Tesla.
All right, so there you go. There’s a basic overview of the integrated Tesla fleet API in Home Assistant and some example automations that I use daily. If you have any great ideas or are looking for some advice on setting up an automation, please leave them down in the comments below. I’d love to hear what you’ve thought of and other cool things I can add to my smart home.
I am working on a few other follow-up short videos for some other automation ideas that I’ve come up with. One of them is launching the app Waze when I start navigating during rush hour. That way, I can get up-to-date traffic information and know if there are any speed traps ahead. Let me know if you’d like to see a full video on that as well.
Again, if you have any questions, feel free to leave them in the comments below or join our Discord server. I try to be on there daily to answer any questions you might have for either product review videos or project videos. Thanks for sticking around, and I’ll see you in the next video.