automation:
- alias: Accendi Luce Corridoio se rilevato movimento
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d00015adc7c
to: 'on'
condition:
- condition: sun
after: sunset
after_offset: '00:45:00'
- condition: state
entity_id: 'light.corridoio'
state: 'off'
action:
service: homeassistant.turn_on
entity_id: light.corridoio
That would do the job.
As I understand it, you want the light to turn on when motion is detected but only if it is after sunset, right? I think you would want to turn it off after 5-10 minutes.
I am editing this because of the offset. If you want it AFTER sunset then then you should use the time without the dash. Using the dash (minus) means that you want it 45minutes BEFORE the sunset. So the correct one should be: