This post turned out to be long. The real question is "How to set and check a global flag? or better, how to assign “rank” to controls
Here is why I think I need this:
This is not really a technical question, more of a logical issue. The motion sensor works as it should. When motion is detected and it is dark, my “Bedroom Medium” scene is activated and the light go up to 50%. They dim way down and them go off when no motion is detected. This is what I want most of the time. But at bedtime I switch the lights off with a smart switch and take two steps to the bad and the lights go back on to 50%.
The only why right now to make it dark is to wait in bed until the sensor clears. I solved the problem of moving in bed by placing the motion senor at ankle hight, the sensor can’t “see” a person in the bed.
What I want is some kind of automation that activates my “Bedroom Dark” scene and then disables the motion sensor for a few minutes.
After I press the “bedtime” button the sensor automation should be deactivated for a few minutes, then later at night if motion is detected (because I got up out of bed at night) the sensor should activate “Bedroom Nightlight” it is about 5% power on three of the lights then after sunrise I don’t care. And the next evening we go back to motion detection trigger the “Medium” scene, untill again I pess “bedtime button” which deactivates the sensor for a while before going to “nightlight”.
I don’t need someone to write a script for me. But hints would be nice
The part I’m stuck on is how to make my “bedtime” button reprogram the sensor automation. Somehow (???) it needs to set a flag and the other automations need to check the flag and the flag needs to be reset every day. How to set and check a global flag?
+++++
Here is another us case I can’t figure out how to do.
I have a closet light and a door sensor, the light works like a refridgerator light, It comes on when the door is open. This works reliabley.
But there happens to be another light near the closet and it would be helpful if this light also came on if the door is opened. Even in the daytime this would help.
I know how to make it work just like the light in the closet but what if the light is already on based on some automation or a smart switch. Then when the closet door shuts the light would go off. This anoys the person who just turnd on the light using the switch. So the closet door-shut automation has to “know” if the light is on because of the clost door-open automation or because of any of 4 other reasons. So we have to track “who was the last agent to turn on this light”.
Or so to speak, the closet door should turn the light off ONLY if it was the closet door that turned the light on. If it was on for any other reeason the light should remain on when the door shuts.
In this case I want the light to have an attribute “Why_am_I_on” and then an automation checks this attribute before turning the light off.
++++
But still this is WRONG. The above fails to handle this case: I open the closet, I want the hellway light by the door to go to 100% and 6,000K. Then someone else turns on a set of 6 lights that includes the hall light but sets them to 50% and 2,400K. 5 of the lights should go to 50% and 2.400K but the hall light shoiuld remain at 100% and daylight until the closet door shuts, then the light goes to 50% 2,400K.
So now I see there should a “rank” attribte with sensors. and if a light gets conflicting commands it “listenes” to the highest ranking switch/sensor. then when that switch/sensor goes away, it listens to the second in command. Or said another way the door sensor should have primary control of the hall light only when it is open and revert control when the door is shut.
++++
It switch/sensor had “rank” iot was dramatically simplify automation logic.