Hey guys this is my code that works well for the most part but there is just one little quirk I’m trying to iron out. Here is my code.
###################################
## Entry night light motion on ##
###################################
- alias: entry night light on
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0002b43d99
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: light.entry_light
state: 'off'
- condition: time
after: '22:00:00'
before: '07:00:00'
action:
- service: light.turn_on
data:
entity_id: light.entry_light
- service: homeassistant.turn_on
entity_id: input_boolean.entry_light_automation
##################################
## entry light no motion off ##
##################################
- alias: entry night light off
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0002b43d99
from: 'on'
to: 'off'
for:
minutes: 2
condition:
- condition: state
entity_id: input_boolean.entry_light_automation
state: 'on'
action:
- service: light.turn_off
data:
entity_id: light.entry_light
- service: homeassistant.turn_off
entity_id: input_boolean.entry_light_automation
The input_boolean is to stop turning the light off if for some reason it has been manually turned on. However I have a problem where in the morning I turn all the lights off and the automation won’t trigger the front door light when I’m near.
I think it’s because I’ve had the lights on walking around so the motion sensor has already been triggered on. So now when I turn the lights off I won’t get a trigger because There is no change of state with the motion sensor.
Is there a way I can code it so that If between the hours off 22:00 and 07:00 that if the light is off it will turn it on so long as the sensor has detected motion? That way as soon as I turn all the lights off it will turn the entry light on if the motion sensor is already detecting motion, It won’t have to wait for it to go off and triggered on again to trigger the automation.
Cheers