Radar van Elk Solutions

Tweakers · Technology

DIY Geofencing for Your Smart Lock with Home Assistant

A smart door lock can automatically unlock when you arrive home, but this often requires sharing location data with the manufacturer. This article describes how you can achieve this yourself with Home Assistant, keeping your location data local.

The geofencing function uses the Home Assistant Companion app to share your location and broadcast a Bluetooth beacon (Android-only). Home Assistant detects your proximity and activates the beacon. An ESP32 board near the door receives this signal and unlocks the door.

You will need Home Assistant, a smart lock, the Companion app, and an ESP32 microcontroller with Bluetooth/Wi-Fi (e.g., ESP32, C3, C6, S3). Avoid ESP32-S2/H2 and ESP8266.

Place the ESP32 close to the front door for accurate timing. Configure the Companion app with active location sharing and beacon function (low latency, high transmit power).

Prevent power saving on Android for the Companion app. The app also needs permission for 'Nearby devices'.

Install a proximity sensor in Home Assistant for the 'Home' zone. Flash the ESP32 with ESPHome firmware via USB (Chrome/Edge).

Create a YAML automation in Home Assistant per user, with the correct entities for the proximity sensor, ESP32, and lock. Set geofencing parameters.

Security: Beacon signals are not encrypted and can be cloned. Random IDs reduce risk. Accurate tuning is crucial.

AI-samenvatting op basis van de bron.

Tweakers