Complex motion - light automation

Trying to set this global, to say if the light turned on via switch or the automation.

Yeah, but question is, how is the switch connected to HA.
Ah, you said Tuya right :thinking:

Can’t remember exactly how, but it is possible to check what switched the light on…

turned on triggered by service switch.turn_on
19:10:45 - 1 hour ago - Supervisor
turned on
18:53:41 - 1 hour ago

Just turned on is manually, triggered by service is from. NodeRed (motion)

Got around this by setting/unsetting with the automation only. Will test a few days and see.

Now I have a problem. If I move into the hallway then the motion sets it on. I have no opportunity to turn the light on manually. Perhaps I would change the brightness of the light but this does not trigger an automation.

The net result is that the automation will be the one that turned the light on and therefore it has the right to turn the light off.

I’m not sure there is any way around this

Thanks very much for sharing this, something to study. I am building in a VM on a laptop but integrating with an other system…yes steep learning curve!