You just need to add a time condition toi this: Motion activated lights automation
So:
trigger:
- platform: state
entity_id: binary_sensor.your_motion_sensor_here # change this
to: 'on'
- platform: state
entity_id: binary_sensor.your_motion_sensor_here # change this
to: 'off'
for:
minutes: 2 # adjust as necessary
condition:
condition: time
after: "19:00:00"
before: "06:00:00"
action:
- service: "light.turn_{{ trigger.to_state.state }}"
target:
entity_id: light.your_light_here # change this
mode: single
https://www.home-assistant.io/docs/scripts/conditions/#time-condition
Time condition windows can span across the midnight threshold if both
after
andbefore
keys are used.