Automating Arrival: How My Car Signals Home Assistant Before I Pull In
Table of Contents
- 1. The Problem with Naive Smart Home Geofencing
- 2. Multi-Zone Geofencing & Telemetry Stages
- 3. System Architecture & Local MQTT Ingestion
- 4. Implementation: Home Assistant Automation Logic
- 5. Failsafes and Anti-False-Positive Rules
- 6. ShVaSa Lab Homelab Takeaway: True Local Privacy
- 7. Grounding & Attribution
1. The Problem with Naive Smart Home Geofencing
Most out-of-the-box smart home arrival automations rely on a single, binary trigger: your smartphone enters a circular geofence around your house. In practice, this setup is notoriously brittle. If the radius is set too narrow (say, 50 meters), your garage door and entryway lights only trigger as you are already idling in the driveway, defeating the point of automated arrival. If you expand the radius to 500 meters or a kilometer, driving past your neighborhood to run errands or grab takeout inadvertently opens your garage and cranks up your thermostat.
True presence automation requires directional velocity, travel intent, and multi-stage state transitions. By bridging vehicle telemetry (via onboard telematics, CarPlay/Android Auto shortcuts, or OBD-II LTE trackers) directly into a self-hosted Home Assistant instance, you can prepare the house intelligently minutes before your tires hit the curb.
2. Multi-Zone Geofencing & Telemetry Stages
Rather than treating presence as a binary home or away flag, a reliable arrival pipeline decomposes transit into progressive concentric rings and directional vectors:
- Outer Ring (10-15 km out): Evaluates heading vector and current internal temperature. If the car is moving toward the home perimeter and current cabin heat/AC is running, Home Assistant ramps the home HVAC system out of eco mode toward the target setpoint.
- Inner Neighborhood Ring (1-2 km out): Signals high probability of arrival. Outdoor floodlights illuminate if dusk has fallen, driveway cameras transition to high-framerate motion tracking, and porch lighting activates.
- Approach Gate (150 meters): Verified by low vehicle speed, directional trajectory, and authenticated mobile token. Only at this stage does the garage door safety interlock disengage and raise the door.
3. System Architecture & Local MQTT Ingestion
To maintain data sovereignty, vehicle location telemetry should never pass through unvetted cloud brokers. In our homelab setup, vehicle events are dispatched via mutual TLS (mTLS) directly to our local gateway, parsed, and posted to an internal Mosquitto MQTT broker:
flowchart TD
subgraph Vehicle["Vehicle Node"]
V1["Car Telematics / Mobile Companion"] -->|Encrypted Webhook| V2["Local WireGuard Gateway"]
end
subgraph HomelabCore["Self-Hosted Homelab Infrastructure"]
V2 --> HA["Home Assistant Core"]
HA --> MQTT["Internal Mosquitto MQTT Broker"]
HA --> StateEngine["State Engine & Zone Evaluator"]
StateEngine --> DB["InfluxDB Local Metrics"]
end
subgraph Actuation["Local Actuation Mesh (Zigbee / Z-Wave)"]
StateEngine -->|10km Out| HVAC["Ecobee / Climate Setpoint"]
StateEngine -->|1.5km Out| Lights["Zigbee Exterior Lighting"]
StateEngine -->|150m Out + Safe Speed| Garage["Ratgdo / ESPHome Garage Controller"]
end
By keeping the routing local via WireGuard and Home Assistant, continuous location tracking remains entirely within your private network boundaries.
4. Implementation: Home Assistant Automation Logic
Below is a production-grade Python automation script designed for the Home Assistant pyscript integration or standalone automation daemon. It processes location coordinates, calculates distance and approach heading, and returns the appropriate staging action:
import math
from typing import Dict, Tuple
class VehicleArrivalController:
"""
Evaluates vehicle telemetry coordinates against homelab coordinates
to trigger progressive staging actions without false positives.
"""
def __init__(self, home_lat: float, home_lon: float):
self.home_lat = home_lat
self.home_lon = home_lon
def haversine_distance_km(self, lat: float, lon: float) -> float:
"""Calculates great-circle distance in kilometers."""
earth_radius_km = 6371.0
d_lat = math.radians(lat - self.home_lat)
d_lon = math.radians(lon - self.home_lon)
a = (
math.sin(d_lat / 2) ** 2
+ math.cos(math.radians(self.home_lat))
* math.cos(math.radians(lat))
* math.sin(d_lon / 2) ** 2
)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
return earth_radius_km * c
def evaluate_arrival_stage(
self,
current_lat: float,
current_lon: float,
speed_kmh: float,
is_heading_home: bool
) -> Dict[str, str]:
"""Determines the exact home automation staging directive."""
distance = self.haversine_distance_km(current_lat, current_lon)
if not is_heading_home:
return {"distance_km": f"{distance:.2f}", "stage": "TRANSIT_AWAY", "action": "MAINTAIN_ECO"}
if distance > 10.0:
return {"distance_km": f"{distance:.2f}", "stage": "OUTER_ORBIT", "action": "MONITOR"}
elif 2.0 < distance <= 10.0:
return {"distance_km": f"{distance:.2f}", "stage": "HVAC_PREHEAT", "action": "RAMP_CLIMATE"}
elif 0.3 < distance <= 2.0:
return {"distance_km": f"{distance:.2f}", "stage": "PERIMETER_LIGHTS", "action": "ILLUMINATE_EXTERIOR"}
elif distance <= 0.3 and speed_kmh < 40.0:
return {"distance_km": f"{distance:.2f}", "stage": "ARRIVAL_IMMINENT", "action": "OPEN_GARAGE"}
else:
return {"distance_km": f"{distance:.2f}", "stage": "APPROACH_RAPID", "action": "HOLD_GARAGE_SAFETY"}
if __name__ == "__main__":
controller = VehicleArrivalController(home_lat=37.7749, home_lon=-122.4194)
# Simulate inbound vehicle 1.2 km away moving at 35 km/h
result = controller.evaluate_arrival_stage(
current_lat=37.7820,
current_lon=-122.4150,
speed_kmh=35.0,
is_heading_home=True
)
print(f"Staged Directive: {result['stage']} -> Action: {result['action']} (Distance: {result['distance_km']} km)")
5. Failsafes and Anti-False-Positive Rules
Physical actuators like garage doors and motorized deadbolts require strict defense-in-depth:
- Speed Gate: If the vehicle speed is above 40 km/h, the garage door must never open, preventing accidental triggers when driving briskly down an adjacent thoroughfare.
- Directional Trend Check: The system must receive at least three consecutive telemetry pings showing decreasing distance before elevating to the next stage.
- Door State Verification: If the garage door is already open or in motion, subsequent commands are discarded to prevent bouncing the motor relay.
- Auto-Close Timer: If the garage opens but the vehicle does not cross the ultrasonic presence beam within 5 minutes, an audible alert sounds and the door automatically closes.
6. ShVaSa Lab Homelab Takeaway: True Local Privacy
Modern connected vehicles often ship telemetry directly to automaker servers, third-party analytics firms, and insurance underwriters. Building your arrival pipeline on local protocols—using an ESPHome-based garage controller (like Ratgdo) and Home Assistant—ensures that your family's daily departure and arrival timestamps are not logged in remote corporate datacenters.
True smart home sovereignty means that your house responds to your physical presence without requiring permission or telemetry leakage through external cloud silos.
7. Grounding & Attribution
- Technical Context: Inspired by architectural insights from XDA Developers Smart Home Automation Dispatches
- Implementation & Systems Architecture: Sharath Japa, Systems & AI Infrastructure Researcher
- Affiliation: ShVaSa Lab (blog.shvasa.us)
- Canonical Publication: https://blog.shvasa.us/posts/my-car-tells-home-assistant-when-im-almost-home-and-the-house-is-ready-before-i-pull-in