Simple lighting rule but I'm stil RM challenged

Been a while since I wrote a rule (and why I don't comment on RM much, lol) So here is what I need.,..

I have a rule to turn on an outlet at sunset +40

I want to turn it off at 11:00pm unless a virtual switch (called patio delay) is turned on. If it's turned on then turn off at 1:am instead.

My brain turned mushy when trying to wrap my head around it. Any help is appreciated.

1 Like
Wait for event: When time is 11:00 PM
IF (virtual switch is on) Wait for event: When time is 01:00 AM
OFF: outlet
4 Likes

Hmm, can't find Wait as a trigger or condition

Trigger is sunset +40. Wait is at the bottom of the action list

So combine the on/off in one rule?

Yes, all in one rule. Not that I'm suggesting the simple condition for the IF action.

Hows this look?

Looks good, but my anal retentive OCD side would add an end if. :wink:

4 Likes

You are using the conditional action so add an END-IF before the Off and you should be all set.

FYI a simple condition allow for single condition and a single action. Notice there isn't a THEN and no need for an END-IF.
IF (Single Condition true) Action

3 Likes

Hi @rlithgow1 ,
On a short break at work so unfortunately can’t actually write a rule but here’s an explanation of how I do the same thing in RM using a number of simple rules:
RM rule 1. Trigger is Sunset +40min >>> Action is Turn ON outlet
RM rule 2. Condition (rule only runs if following is true) - Patio Delay Off >>>>>Action is Turn OFF outlet at 11:00pm
RM rule 3. Condition (rule only runs if following is true) - Patio Delay ON >>>>>Action is Turn OFF outlet at 1am
Even though it three rules may seem cumbersome, it makes it very easy to change the parameters (Time ON and OFF) easily and at will. It also helps to make sure that it is very easy to trouble shoot if your outlet does not act in the way you expect.
This of course can be done in one rule using various delays as well. What I normally do when I may anticipate wanting to “tweak” my settings in the future is to make a local variable for each value I may wish to change in the future and use those variables in my rule. That way, the variables show up clearly and it is easy to change their values without having to actually go into the Rule itself and change the parameters by calling up each step in the Rule. This is especially true if I write a single rule to cover your use case. IOW, if you write a single rule to accomplish what you want in your example, by having all three parameters as variables (time ON, time OFF when delay OFF, and time OFF when delay ON) you can easily see in one place all the values for these times as they appear in one place and can easily alter the times by just changing their values in the variables chart, rather than having to go in and alter each step in the rule.

Sorry if this explanation does not seem so clear without a graphic example or screenshot of the actual written rule but since I do not subscribe to the Hubitat Remote Access, I can not actually do any Rules creation when away from local access to my hub. Hope this gives you some ideas!

1 Like

When ever you get a chance for a graphic example is fine with me. I appreciate it.

Updated...

More than OCD. If there isn't an END-IF before the Off the light won't turn off at 11:00. But yeah, I have the same OCD!

4 Likes

How does it look now?

Move the END-IF before the Off and you'll be set.

3 Likes

3 Likes

That'll do it!

3 Likes

Danke! Will let you know how it goes

3 Likes

@rlithgow1 One thing you might want to consider is adding the virtual switch to the Off command so you don't have to remember to turn it off after 11:00 or the next day.

2 Likes

Thanx for the remind. I had that in another rule but moved it to the main one

2 Likes