need to add some logic so HA knows how the lights were turn on by motion or Manually
you could add a Toggle helper “motion kitchen Turn On” then in the condition of the motion turn off to check toggle helper is ON then turn light off and turn the helper off to.
and or when manualy turn on . turn off that helper so motion does not kick in
What worked for me was capturing what originally turned the light on in my automation. I first have an automation which says if motion happens turn on this light.
My second automation says turn off the light if it was motion that turned it on, and turn it back off in X minutes. I stole the code from someone on here. I’ll try to find it.
Do you really not want the lights to go out based on no motion if you turn them on manually? I think that would be one of the main benefits of a motion sensor light. That they are auto-off if no one is using the room, no matter how they were turned on.
In other words, is the problem with the motion detection itself not firing reliably enough to keep the lights on when you are in the room?
Ok so here are my two automations; this works for me.
Turn On Light Automation:
trigger:
- platform: state
entity_id: binary_sensor.videosource_1_motion_alarm
from: 'off'
to: 'on'
action:
- service: switch.turn_on
target:
entity_id: switch.front_porch_entry_switch
Turn Off Automation if turned on by motion:
trigger:
- platform: state
entity_id: binary_sensor.videosource_1_motion_alarm
from: 'on'
to: 'off'
for: '00:05:00'
action:
- service: switch.turn_off
target:
entity_id: switch.front_porch_entry_switch
I have some conditions in mine for specific times of day as during some times I have my front porch light on anyways so no need to attempt to turn it on, and I don’t want to turn it off. I left those out to make it less confusing.