So this is the first complex rule I'm creating in HE.
In my office I have:
1 Dimmer, 1 Light Switch, 1 LED Strip. I want to use the LED Strip as a motion activated night-light, but I want it to act "perfectly".
Behavior I want:
WHEN: Motion Detected
IF: (After Sunset
AND
"No other lights are on"
AND
"I am not using the LED Strip Manually"
AND
BONUS: "I haven't just turned of the lights very recently")
THEN: (Turn on the LED Strip to 50%,
WAIT FOR: (Lights to be turned on,
OR
"I manually turn on LED strip"
OR
"Motion becomes inactive")
THEN: (Turn off the LED Strip)
END IF
Here's the code I have so far.
IF (Variable Office_LEDStrip_Active(false) = false(T) AND
Office_Dimmer, Office_Lamp_Inovelli(off, off) any is off(T) AND
Time between Sunrise and Sunset(T) [TRUE]) THEN
Set color: Zooz RGBW Dimmer-color ->Custom color ->Hue: 7 ->Sat: 100 ->Level: 70
Wait for events: Upstairs inactive
Off: Zooz RGBW Dimmer-color
END-IF
The variable "Office_LEDStrip_Active", I am using by setting it to true with all of my Rules that "Turn ON" the LED Strip.
The things I cant figure out are:
-
How can I "WAIT FOR" multiple events with an "OR" condition? Rules engine seems to just overwrite WAIT rules if I try to add a new one.
-
How can I get it to not turn on the LED Strip, if I have just turned off the LED strip and I'm walking out of the room? Is there way to set a variable on a timer? Like: Turn off light: Set Variable xyz = True...for 5 minutes?
There are a few issues with the requirements you listed so let's work through those first....
At the end of your first IF statement, you set the stip to 50%. Then you have a wait for the the light to be turned on or the strip to be turned on. The strip is already on at 50%. So, how can you wait for it to be on again?
What does this mean?
Instead of trying to spell out what you think in terms of software, just use regular sentences to explain what you want to happen. Are you trying to have the LED strip come when there is motion and then not turn off again if the light is turned on? A night light is usually on all night, rather than just with motion. Motion lighting would usually just come on to the level you want.
Also, what does this mean?
If you're already checking if the lights are on, that would verify that they are not on. Do you mean if you turn them off, motion should not turn them on until some period after? This will happen anyway since your motion sensors have timeouts. The rule will not be triggered until motion goes Inactive and then Active again.
So...
If i come into the room at night, I want a LEDstrip to turn on dimly...then turn off when motion stops.
If I come into the room and then turn on the normal room lights, it shoudl turn itself off.
If I come into the room and then modify the LED Strip myself (turning it off cause I want the room fully dark OR turning it on to some other setting)...it should NOT turn itself off.
Also if I am in my room and then I turn off the lights....it should not turn itself back on from the motion of me leaving the room.
This is my similar rule, maybe steal some ideas from it? Modes sure helped streamline things here, but you could set times if that is more to your liking.
This part will be handled automatically for you. Because your motion sensor has a timeout, the motion sensor within the room will not trigger the lights to go back on because it is already active when you turn the light on.
This is what I would do:
Trigger: Motion Changing
ACTION:
IF Motion is Active THEN
Cancel Delayed Actions
IF LED strip is Off and Other light is OFF THEN
Set LED strip to Level X
END-IF
ELSE IF Motion is Inactive AND other light is OFF AND LED Strip is at Level X AND LED strip is ON
THEN
Delay Actions by Y minutes (cancelable)
Turn off LED Strip
END-IF
I think that is going to get you where you want.
Thanks guys. I kept trying to link it all in one "motion detected" codeblock. Triggering it on "motion changing" makes all the logic way easier!!!!
Thanks for all the tips, pretty sure I can get this going now (once work stops asking me to ....work)