Hello! I have a zigbee smart light switch (to be exact: a dumb switch and a zigbee relay) and a zigbee motion sensor.
I set up an automation that turns on the light when the motion sensor detects motion.
Some family members, however, still habitually turn the light on using the switch. The problem is that sometimes the motion sensor turns the light on a split second before they flip the switch - causing the light to turn off immediately.
What I did to remedy that is create a second automation that triggers when the light is turned off and if the motion was last detected less than 1 second ago, turns the light back on.
Here is the automation:
alias: Keep the light on
description: ""
trigger:
- platform: device
type: turned_off
device_id: 34bf888dce5a361ce0edf058532b59ba
entity_id: switch.0xa4c1387246f2834b
domain: switch
condition:
- condition: template
value_template: "{{ now().timestamp() - states('sensor.motion_last_detected')|float < 1 }}"
action:
- type: turn_on
device_id: 34bf888dce5a361ce0edf058532b59ba
entity_id: switch.0xa4c1387246f2834b
domain: switch
mode: single
and here is the auxiliary sensor that records when motion was last detected
- trigger:
- platform: state
entity_id: binary_sensor.0x00124b0025306c64_occupancy
to: 'on'
sensor:
- name: motion_last_detected
state: "{{ now().timestamp() }}"
While this does work, I’m wondering if there is a better solution? I’d like to prevent turning the light off and immediately turning it back on.
In essence: is there a way to disable switching the light switch off for 1 second after being switched on by a motion sensor?