Add Siri to Your Tesla Model 3 Using Home Assistant Smart Home

May 23, 2018

Tesla Model 3 Integration

Today on the hookup I’m going to brag about my new tesla model 3!   Wait, what?  That’s a terrible intro for this video.  Lets try that again:  Today on the hookup we’re going to talk about how the tesla model 3 connects to home assistant, and how you can use home assistant to add Siri and Alexa voice controls and other automations to your tesla that aren’t available without home assistant integration.

So this is my beautiful new tesla model 3.

Okay fine, it’s actually my wife’s car, it’s her beautiful tesla model 3.  The tesla model 3 is a car of the future, so much so that many of the coolest things that this car can do will only be available… in the future…  Thankfully there is still a pretty great set of advanced features available right now.  The model 3, like all teslas, is equipped with an always on LTE cellular connection that lets it communicate with an app on your phone, and of course with the tesla mothership.  Tesla has also been so kind as to release an API to communicate with many of the sensors and switches on the car.

Like almost every piece of technology that has an API released, a tesla component is also available for home assistant.  To connect my the model 3 to home assistant all I needed to do was add “tesla” to my configuration.yaml file along with my login and password to the tesla app.

After saving my configuration.yaml file and restarting home assistant the group sensors and components that the tesla API makes available appeared in home assistant.  Here’s a list of all of the components that get automatically added.

I actually only wanted a few of these sensors to show up on my home assistant dashboard.  Specifically I chose to keep the lock switch, climate control, charging state, battery percentage sensor, range sensor, and location.  These components have long and unintelligible entity IDs when added, but you can easily change these names by going to configuration, then customization, then selecting the entity you want to change and editing the name entry.

Adding these components to home assistant didn’t automatically change much about the way I could interact with the car aside from not having to open up a separate app on my phone.  But there are a couple of things that home assistant integration allows you to do with your model 3, that wouldn’t otherwise be possible:

 

Once you install the tesla app on your phone you can use the siri voice commands “unlock my car”, or “lock my car”, or “honk the horn on my car”.  But there’s no ability to use it from your apple watch, and you can’t access the climate control at all.

It just so happens that an official homekit component was added into hassio about 2 months ago, and the updates have been rolling in since.  Home assistant’s homekit component allows you to easily expose your home assistant devices to homekit to enable functionality through iOS and siri.

To enable the homekit component you just need to add homekit to your configuration.yaml file.  If you’re like me and have literally hundreds of devices in home assistant, I would also highly recommend only including specific entities in your homekit discovery using the filter functionality.  You can either chose to filter by excluding entities or domains, or including them.  Since I only had a few things that I wanted to expose, I decided to use the include entities method.  After giving home assistant a restart I now have a temporary new card that appears in home assistant.  This card contains the pin for linking your included devices with home kit.

Next we hop over to our iOS device and open the apple home app.

Choose Add Accessory, than select “Don’t Have a Code or Can’t Scan?” and enter the pin code.

Confirm the you are adding an Uncertified Accessory by clicking on Add Anyway.

Follow the setup be clicking on Next and finally Done in the top right hand corner.

Since I exposed the tesla’s climate control system I can say  “Hey Siri, Set viserions AC to 72” and the climate system will update to 72 degrees.  But the most useful function is that you can start cooling the car remotely so the black leather interior is not blazing hot when you get in.  Being able to do this from my apple watch would greatly increase my likelihood of remembering and it’s so simple…  all I have to say is (“Hey Siri, Turn on viscerions AC”) and the…  umm.  (“Hey Siri, Turn on viscerions AC”) and that will… uh…

Nothing is ever that easy is it?  It seems that whenever the tesla integration was written it uses the commands “operation_mode: on” and “operation_mode: off”, but homekit is only able to send auto, heat, cool, and off as payloads for “operation_mode” meaning that homekit has no way of turning on the AC.  If you thought I was just going to give up there, then you’ve probably never watched one of my videos before.  The fix was actually ridiculously quick and simple.  All I did was create an input Boolean in home assistant (I called it “viserions air”) and added it to my homekit included entities.  I then went into node red and set up a quick automation where flipping the input Boolean calls the “climate.set_operation_mode” service and uses the correct values of “on” or “off” as the payload.  NOW I can say (“Hey Siri, turn on viserions air”) and the climate control kicks on remotely.

One quick note about homekit:  You can set up homekit without having to have a permanently connected device in your home wifi like a google home mini or an amazon echo dot, but if you want to be able to access your devices remotely you’ll need some kind of hub in your house to act as a go between like the mini or the dot would, your options for this are appleTV 3rd generation or higher, homepod, or an always on ipad running the latest version of iOS.

Just for fun and because it was really easy, I also set up amazon echo to have the same functionality, but as you can imagine the use cases are significantly less since I can’t talk to alexa without opening up a specific app on my phone, it’s mostly just a fun party trick… And an excuse to tell you to stay tuned next week for part 2 of my mastering node-red series where I’ll cover how to easily create amazon alexa automations using node-red.  Anyway…..

The other thing that home assistant allows me to is create some useful automations using the data from home assistant.  One neat feature of the tesla is “walk away locks”, where you just get out of the car and walk away and after your phone gets a certain distance from the car the doors will automatically lock. This is a neat feature, but also an annoying feature if you just need to pop into the garage and grab something out of the car without your phone in your pocket.

To fix this I’ve set up this simple node-red flow that uses the gps location of the tesla along with the current state of the garage door to keep the doors unlocked as long as the garage door is closed and the tesla is in the garage.

This flow starts out with an event state node for the door locks, if the doors go from unlocked to locked it will send on a payload to this current state node where the gps location is polled to check if the car is in the garage.  Luckily I don’t have to worry about the lock and gps location being out of sync because they are both updated at the same 300 second interval.  Next it will travel through another current state node where the garage door state is polled.  If the garage door is open it will halt the flow, if it’s closed it will continue on to a “call services” node to unlock the car using the lock.unlock service.

 

What about if we need to park it in the driveway, wouldn’t this automation prevent us from locking the car? Amazingly, the tesla’s GPS sensor is plenty accurate to determine if it’s in the garage or in the driveway, you just need to make sure you’ve set the zone to be small enough in home assistant, in my case I changed the default 100 meter radius of the “garage” zone to 3 meters.

Now that my wife has this cool new toy I’m feeling a little bit of tech envy…  The tesla model Y can’t come soon enough. Stay tuned next week for part 2 of my mastering node red series.  If you enjoyed this video, please consider subscribing, and as always, thanks for watching the hook up.

Links

YAML + Node-RED Flows:
https://github.com/thehookup/Tesla_Model3

Get started with Hassio:
https://amzn.to/2KOpeNN
https://amzn.to/2kiLKTN

Support my channel:
Patreon: https://www.patreon.com/thehookup

Twitter: @TheHookUp1
Music By: www.BenSound.com

Related Posts