I’d like to have a motion sensor turn on a light when it’s triggered - that’s easy.
But I’d like to have the light restored to the previous state when the motion sensor later on says “no more motion”.
What’s the best way to approach that? Would previousstate give me the state it was in before we changed it? Or should I save the state to a variable before turning the light “on”? What variable type is a state?
Another way to approach this would be writing a rule, which turns the light on for a predetermined time when motion is detected.
This should also include resetting the timer everytime motion is detected.
I had a similar problem, though in my case it had to do with the lights turning on or off based on the weather.
In my rules I keep track of how the light was turned on (manually, timer, or because of the weather). It I turn on the light manually it sets a flag indicating that the light is overridden. This flag will prevent the light from being changed based on the weather.