Im having an issue setting up an automation for one of my lights and motion sensor. So i have a Tuya branded zigbee PIR sensor and switch in my laundry area and it is connected via Zigbee2MQTT via a Sonoff Dongle. What im trying to achieve is setting up a basic “on if motion is detected/off is motion cleared” automation. Now the turning on part works fine, however i run into an issue of the lights not turning off. This peculiarity only occurs when i add the additional variable of duration in the “motion clear” section. If i set the automation with the variable of “if motion sensor state clear for 5 secs”, the light turns dont off. Without that variable, the automation runs fine and lights turn off.
In the logbook i get this output:
Laundry Motion triggered by state of Laundry Motion Sensor Motion
12:14:49 PM - Now
Laundry Motion Sensor Motion cleared (no motion detected)
12:14:49 PM - Now
Laundry Motion triggered by state of Laundry Motion Sensor Motion
12:13:39 PM - 2 minutes ago
Laundry Motion Sensor Motion detected motion
12:13:39 PM - 2 minutes ago
So i can see that the automation is being triggered, however the lights only turn on. The part of turning off the lights in the automation gets ignored for some reason and the light remains on.
In traces i see this output but to be honest i dont really understand it.
Executed: February 2, 2024 at 12:14:49 PM
if
Executed: February 2, 2024 at 12:14:49 PM
Result:
result: false
if/condition/0
Executed: February 2, 2024 at 12:14:49 PM
Result:
result: false
if/condition/0/entity_id/0
Executed: February 2, 2024 at 12:14:49 PM
Result:
result: false state: ‘off’ duration: ‘2024-02-02T01:14:44.470311+00:00’
This is the configuration of the automation. Would appreciate any help pointing me in the right direction to solve this. Thank you!
alias: Laundry Motion
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.laundry_motion_sensor_occupancy
condition: []
action:
- if:
- condition: state
state: "on"
entity_id: binary_sensor.laundry_motion_sensor_occupancy
then:
- service: homeassistant.turn_on
data: {}
target:
entity_id: switch.laundry_right
else: []
- if:
- condition: state
entity_id: binary_sensor.laundry_motion_sensor_occupancy
state: "off"
for:
hours: 0
minutes: 0
seconds: 5
then:
- service: homeassistant.turn_off
metadata: {}
data: {}
target:
entity_id: switch.laundry_right
mode: restart