I would like to trigger a light using both HA and binary sensor (PIR). The objective is to allow PIR sensor to turn on and off the light automatically, but allow HA to override the sensor trigger. E.g. If I turn on the light from HA, binary sensor will be disabled until I turn the light off from HA.
The challenge I’m facing right now is I won’t be able to tell who turned on the light when the light is already on. For example, PIR sensor triggered and light turned on. Then I go to the HA and turn on the light and the light will be turn off by the sensor.
Is there a way to set a flag/var when light is turned on by HA? Thanks.
This is how I do exactly what you described. I have a Sonoff Basic with a PIR to control a light. If the PIR senses movement, it turns on the light and after two minutes of not sensing any movement, it turns off the light.
But of course I can turn the light on/off at will from HA by simply having this on a glance card. If I tap on the icon it toggles the light switch.
That’s a good question. So, you are asking what happens if I turn on the light manually through HA and then the PIR is triggered, right?
I am thinking that in that case you will have to write a script to turn the light on when the PIR senses movement, waits for X minutes, and then turns off the light.
And you call the script only when the light is off.