Automated Garage Doors with Tesla GPS

Real-time Tesla informatics and Home Assistant come together to automate the garage door

May 26, 20222 min read
Post Feature Image
I got a new car! Unlike literally every other car, it doesn't have HomeLink built in. It's an extra $350. For three cars, that's over $1000 for a feature that should have been included in the beginning.
Well, turns out, the Tesla Streaming API provides live GPS of the car at all times, so if I tap into that, I could theoretically create a geo-fence that triggers the garage to open and close based on where the car is.
I found that the Streaming API had tons of quirks, so I found the TeslaMate add-on in Home Assistant that provided basic vehicle data over MQTT. This worked great, and it made pretty graphs, which was cool.
I used the example integration on the docs page to add the reported lat/long values into a device tracker. This allowed me to use our existing 'Home' zone in Home Assistant, but in testing, the garage would close way too late to be comfortable.
I then tried to use the BLE beacons built into the car with room-assistant, but the connection was unreliable, and the garage almost shut on my car. Not good.
probably due to the fact that the BLE reciever was mounted in a metal case right behind the opener. or that the garage door was metal. metal & radio waves = not friends.
I wanted to see if it would be possible to create a 'complex' zone of sorts, or, one that wasn't a basic circle. That way, I could create a zone of just the driveway+garage, and the garage would then shut precisely where I want it to.
For whatever reason, Home Assistant doesn't currently support this, but Node-RED has a node where you can create zones out of polygons and if you feed it coordinates, it will tell you if the coordinates are inside or outside of the zone.
Perfect.
I installed the Node-RED helper integration into Home Assistant to make 'dummy' sensors that change state to match the output of the geofence node. It's a pretty basic flow, it waits for the car's GPS entity in Home Assistant to update, formats the message to what the geofence node is expecting, checks the geofence, and outputs the state back to HASS.
Then, automations are set up that trigger when the sensor changes, and tell the garage door to open or close. Two automations are used for each car, one to open on arrival, and close on departure.
The only problem is that if you park the car in a specific spot in the driveway, the garage will open and close forever.
Works well enough for me. ✅
© 2024 Aiden Vigue