Thought I’d share. Here’s my solution for the following usecase:
hardware:
an on/off sensor (i.e. Motion )
light, scene, automation, etc to switch
use:
when light is switched on: motion activated lights = ON and they turn off after a certain period.
when light is switched off: lights OFF, motion activation OFF
when light is switched off, then on within a certain time, lights ON, motion activation OFF.
Thoughts:
I do not want to decouple the switch from the lights in case the switch loses connection to HA for whatever reason. It still needs to act as a light switch (graceful degradation)
Feel free to comment on my code, I’m not a good programmer by any stretch of the imagination.
** Edit: changed to github link & fixed a scheduler issue.