Requirements:
- A HomeKit enabled motion sensor. I use
Aqara Motion SensorHue Motion Sensor- The update interval of Hue Motion Sensor exposes to HomeKit is 10 seconds. Far better than Aqara Motion Sensor (120 seconds). And seems more stable after testing for months.
- A HomeKit enabled accessory to be controlled
- Homebridge with homebridge-delay-switch plugin installed
Goals:
- You want to stick with local automation instead of configuring automations in vendor specific apps
- Trigger an open/turn on/start event when motion detected
- When no motion for specific minutes. Trigger another event to close/turn off/stop
Why? This method no longer depends on the buggy HomeKit built-in “Turn Off” and Stops Detecting Motion feature. Common HomeKit motion sensors only update the motion state every [latex]n[/latex] seconds. When Stops Detecting Motion triggers. It won’t be canceled or delayed when it detects another motion during the [latex]n[/latex] detection interval. That causes your accessory to be turned off even motion detects during the time you set.
With my method. Your accessory won’t be turned off if your motion sensor detects motion during the specific time you set. Make your motion sensor work more like an occupancy sensor.
First. Add a delay switch in Homebridge:
{
"name": "Living Room Delay Switch",
"delay": 300000,
"disableSensor": false,
"startOnReboot": false,
"accessory": "DelaySwitch"
},
The delay
time is in milliseconds so 300000
equals 6 minutes here.
In your Home app. Create the following automations:
First Automation
- When: Living Room Motion Sensor – Detects Motion
- Accessories:
- Turn on your accessory
- Turn on your Living Room Delay Switch
Second Automation
- When: Living Room Delay Switch Trigger – Detects Motion
- Accessories:
- Turn off your accessory
Third Automation
This automation is important. It can ensure your accessory can still be turned off at a specific time if the accessory was opened/turned on/started manually.
- When: Living Room Sensor – Stops Detecting Motion
- Accessories:
- Turn on your Living Room Delay Switch