Hello, I want to do an automation so that the light comes on (30 minutes before dark) and that it is active for 30 seconds or more if it detects movement, but I don’t know what happens that it doesn’t work for me, I don’t know what I’m doing wrong. I need help. Here I leave the code.
alias: "Sensor ENCENDIDO luz entrada "
description: >-
Detecta presencia 30 minutos antes del anochecer y enciende la luz de la
entrada durante 30 segundos
triggers:
- type: occupied
device_id: 901eac47d8be1bc8f2f0cc17adecc9e5
entity_id: a9948453cd8aeb0baa1fdb108ab2aae6
domain: binary_sensor
trigger: device
for:
hours: 0
minutes: 0
seconds: 30
conditions:
- condition: sun
after: sunset
after_offset: "-00:30:00"
before: sunset
actions:
- type: turn_on
device_id: 815c2082ba4a19fcf387ac1d86f8c5f7
entity_id: 6d7691d9e4bca9714c052a79b5ff7fb6
domain: switch
mode: single
The motion sensor is a Tuya TS0202
The smart switch is a SonOff ZBMINI
Thank you