Helo. I have Philips Hue motion sensor. This sensor is able to turn ON Tuya light. I prepared automation where I would like to turn the light on after movement detection and turn it off after there is nothing moving for at least 30 seconds. This should work only 30 minutes before sunset until 30 minutes after sunrise.
Here is my automation which will turn light on but won´t turn it off. I tried many variations but without success. Please help.
alias: Motion light
description: ""
trigger:
- type: motion
platform: device
device_id: c2fed70c6156d87017fd306e718c43ad
entity_id: 20025762d69061f4471ab9e331b1bcd2
domain: binary_sensor
condition:
- condition: and
conditions:
- condition: sun
before: sunset
before_offset: "00:30:00"
- condition: sun
after: sunrise
after_offset: "00:30:00"
action:
- type: turn_on
device_id: 52a50d56724524d0d71f8c8550fc0945
entity_id: 05a4e9426a9fb4d964c42d2ceb9d300d
domain: light
brightness_pct: 100
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- if:
- condition: state
entity_id: binary_sensor.pracovna_motion
state: "off"
for:
hours: 0
minutes: 0
seconds: 30
then:
- type: turn_off
device_id: 52a50d56724524d0d71f8c8550fc0945
entity_id: 05a4e9426a9fb4d964c42d2ceb9d300d
domain: light
else:
- repeat:
sequence: []
until:
- condition: device
type: is_off
device_id: 52a50d56724524d0d71f8c8550fc0945
entity_id: 05a4e9426a9fb4d964c42d2ceb9d300d
domain: light
mode: restart