RM4 & Presence & timers?

I'm b-a-a-a-ck again! Ugh. Well, I'm slogging thru this and I just don't understand why I'm struggling with this.. Anyway, ideally I want to turn on several lights when I come home. I work for a large TelCo and get called out in the middle of the night sometimes, too.

1a) Turn on light 1, 2, 3, 4 & 5 when I'm nearby
b) But ONLY if it is between sunset -30 and sunrise +10
c) But ONLY the lights that aren't already ON (see 2b)
2a) Turn lights OFF after waiting 10 minutes
b) But only those lights that were turned on in 1c) above. (prevents shutting lights off while family members are up / watching TV, etc. when I leave to go on a call out)

I didn't see the ability to set / clear a flag (or other way to check if the light is on already or not) so the part about leaving lights on - that were on when I was nearby - seemed not doable. At least not with jumping through hoops anyway.

I could probably live with turning all the lights off, but didnt see how to create a 10 minute timer. Is there some place with more than a page of documentation & possibly examples for RM 4.0? Thanks!

You have some sort of "broken" conditional there (the plain IF that just reports its truth value as "False"), but that is how you can check for things. You used a simple conditional, which would certainly work:

A sequence of actions like this would work:

IF (Bulb 1 Off) Dim: Bulb 1: 100 --> fade: 5
IF (Bulb 2 Off) Dim: Bulb 2: 100 --> fade: 5

...and similar. However, you'd need a way to "remember" whether each was off or on before. A local variable for each would work, but that's a lot of work. Have you considered using the "Capture" and "Restore" actions instead? You could capture the state of all the bulbs (that one action will get on/off, level, color, etc.), modify them as you see fit, then restore that state after your 10 minutes. To get the 10 minutes, something like this would work:

Trigger: Presence sensor(s) arrives

Actions:
IF (Time NOT Between sunset-30 and sunrise+10) Exit Rule
Cancel Delayed Actions
Capture State: Bulb 1, Bulb 2
On: Bulb 1, Bulb 2: 100 --> fade: 5
Delay 0:10:00 (cancelable)
Restore State: Bulb 1, Bulb 2

I'm leaving out a few of the details (you could indeed test each bulb above and not turn them on if they're already on to some level--say a dim level for relaxing or watching a movie), but I think this might answer the question you're asking about how to achieve the "timer"/delay aspect.

Also, this is probably the best documentation for Rule 4.0, though it assumes a bit of 3.0 knowledge (you can probably ignore those parts): [Released] Rule 4.0. They also uploaded a video to their YouTube recently that demonstrates simple conditionals (like the first action in my rule above), but it might be a bit too simple for your use case: YouTube

Thanks for taking the time to work this out and including details.

I'm a hold back from X-10 HA, and finally moved to Hue & Hubitat. X-10 had macros and flags and if / then / else - but was done a little differently. Trying to unlearn their way is complicating this for me I suspect. I'll try tinkering with this and let you know how I made out. Hopefully, the RM 4.0 links will help me out a great deal.

Thanks again!

1 Like

Trigger

Presence change

Action

If time is Between 30-sunset and 10 sunrise And iPhone is present then
If light a is off then
Turn on
Turn off after 10
End if
If light b is off then
Turn on
Turn off after 10
End if
If light c is off then
Turn on
Turn off after 10
End if
End if

You'll either want to add "present" to your IF or make the trigger itself "present" (since you're not doing anything when going away, it won't matter). I'd also recommend a Cancel at the beginning and "cancelable" on each of those delays so that if you leave and come back in a short time, you won't get premature "off"s. Otherwise this is definitely another way to tackle the issue!