Rule Machine 4.0 Christmas Lights

Welcome to the Hubitat Community!

Further to what @razorwing posted, if you want to limit by date, this will work. It's not nessecary to evaluate again before off, since that will be done at 45 min before Sunset and at 11:30 PM. If the time is Sunset -45, and the date is between December 1 and January 6, then the lights will turn on, but if it's not either of those and it is 11:30 PM, then they are going to turn off. So you can just use ELSE in this case.

1 Like

Hi I think 2 rules are probable easier for some reason I can't seem to edit the rule I have created. So I'll try the 2 rules way. the reason I want it in rule machine is because we are away from just after Christmas until the middle of january and I don't want out lights still running after the 6th.

Jon

You should be able to edit any rule. The trick is that since you've already added actions, to get the IFs and things suggested above, you'll have to use the options like "Insert action before". You can't re-order actions after they've been added, only delete and add new ones elsewhere (before another or at the end)--a limit to the app UI model Hubitat inherited from a certain other platform many of us migrated from. :slight_smile:

Starting a new rule and creating it as above would also work. You could also manually disable your app, including the Simple Lighting automations, rather than automating the dates, though I do like the idea of automating that, which would probably be most easily done with RM (or you can delete it and re-create it next year--I'm trying not to do that this year, but I can't guarantee I won't totally re-do any of my hubs before then...).

@jon.d.tyler I think I was a little vague in my answer and I missed the dates. So SmartHomePrimer's is the way to go.
If you wanted to break it down so you can maybe understand it better then you could do this. This is the long version and maybe once you understand this then SmartHomePrimer's will be shorter but do the same thing.

IF time is sunset-45 and
between dec 1 and january 6 then
on christmas lights

elseif time is 1130 and
between dec 1 and january 6 then
off christmas lights

endif

OR

2 IF statements within the same rule.

IF time is sunset-45 and
between dec 1 and january 6 then
on christmas lights
endif

IF time is 1130 and
between dec 1 and january 6 then
off christmas lights
endif

So just to clarify, the original problem is that for either of those two times, I think the rule machine will turn the light off and then back on again. You need either the two separate rules of the if/else clause in the action.

I'll have to do this for my nightlight (still learning too). Unfortunately, some of the Christmas lights are on WiFi outlets which the Hubitat can't deal with, so I have to leave it to Alexa.

You can obviously just handle the timing from Alexa, but if you want to setup the rule logic from HE, you can. You simply need to create a virtual motion sensor that is trigged when a switch is turned on. Then share that with Alexa. When that motion is triggerd, you have an Alexa routine operate the WiFi device.

Use this code for motion sensor as a switch

Oh HO! Thank you! Alexa has seen virtual switches, but not to read only to change I think. This is a good tip. I'll try it since I WOULD like to keep everything together. I've also read about hacking WiFi outlets so I would have have to go through the outlet's web server. I'd really like to do that, but for now insufficient time and the wrong brand of outlet.

1 Like

Hi guys, thanks for all the advice I'm giving up for the night I just can't seem to get it to work properly all the drop down menus just confuse me I think it would be a lot simpler if I could input what I want as a text file or something.

I'll just get the house sitter to go into the garage on the 6th and unplug the lights, a bit rubbish but I know it works.

Thanks again.

Jon.

Your action needs to be "Conditional Actions", then you can input the condition after IF and then the action that will take place after THEN

Here's a step by step (granted, it's a lot of steps for such a simple rule, but that's the way conditional actions in RM 4 are handled). It's not hard, but it does involve more clicks than I would prefer.

Step 1.
11%20PM
Step 2.


Step 3.

Step 4.

Step 5.

Step 6.

Step 7.

Step 8.

Step 9.

Step 10.

Step 11.

Step 12.

Step 13.
33%20PM
Step 14.

Step 15.

Step 16.

Step 17.

Step 18.

Step 19.

Step 20.

Step 21.

Step 22.

Step 23.

Step 24.

Step 25.

Step 26.

Step 27.

6 Likes

@SmartHomePrimer Great job! This is how I have always imagined helping someone who is new to Hubitat. We need to carry on this method.

4 Likes

Thanks. It is a lot of work to setup and keep all the screen shots straight though. And the numbering got really screwed up. Maybe I should have put a return between lines? :thinking:

I'd like to help everyone this way, but it's often much more complex. This is a very simple rule, so generating and posting more than 27 screenshots isn't going to work. It's an unnecessary amount of images for Hubitat to host as well if we were to do this often.

Not sure what the best solution is, but I'm not convinced I've found it. :wink:

Granted it would have to be a simple rule but that is usually what they are for the guy who is a real beginner. Anything more than that I agree would be too much. Teaching them the basics by showing as many steps as you can, most times, can be an 'ah ha' moment for them.

1 Like

Thanks that’s amazing I’ll give it a go tomorrow. I’ll let you know how I get on.

Once again thanks to everyone here.

Jon.

1 Like

Very impressive! And thanks again for the hint about the motion/switch driver. I did have to modify it slightly (or at least that made it easier) but removing the action to stop seeing motion after a few seconds. By doing it that way, I can just set up two routines in Alexa, one triggered by motion to turn of lights on and one triggered by no motion to turn them off.

1 Like

Thanks very much for showing me the way with the new rule machine automation.

Does using PREDICATE CONDITION help any if I chose that for performing this rule between two dates?

1 Like

Can anyone please help me understand why my rule is NOT firing? I thought I copied what this thread showed but as you can see both conditions are true and my lights are yet to be turned on. What am I missing or have done wrong here?

Doesn’t look like youu have a trigger event defined…

1 Like

Different ways to skin this cat, but my first thought would be to make the oct-jan date range a predicate condition, then use ss-120 as the trigger to turn on the outlets, add a "wait for" SR+120, then turn off outlets.

Thanks @hydro311 and @thebearmay , I just added a trigger that will check I guess everyday....I wasn't too sure about triggering at exactly the boundary times of the main condition so I fudged it. Shall see. Maybe predicate is the way to go? I'll cogitate and adjust as needed. Thanks again for the assist!

I really oughtta go back to my corner because I'm not super smart on creating the most efficient or neatest rules, but I have a feeling your latest build there is going to be problematic (I may be wrong!)...

My approach to Rules is to KISS as much as possible, so if it helps to break an idea down into 2 or more rules (instead of trying to make it work in one rule), that's almost always OK to do.

A Trigger is well, a trigger - I try to keep those as simple, clear, and black-&-white as possible so there's no absolutely question about when it occurs. I myself would not use an "X or Y" trigger - to me, it risks unnecessary confusion (both to me and the hub!)

A Predicate condition is like a sleep/wake gate for the rule - this may be an oversimplification, but I think of it this way... When the trigger event happens, it checks the rule for a predicate -- if the predicate is true, then the rule fires; if the predicate is false, the rule doesn't fire. The predicate determines if the rule is live / in play or dormant when its trigger triggers.

A Predicate is not required to use for every rule, but it can be a powerful and easy way to help regulate a desired action.

As I said in a prev post, I'd try making the Jan-Oct date range the Predicate condition, and then use SS-120 as the trigger to turn on the outlets.

In that same rule, you can add a "Wait for" condition to wait until SR+120, then turn the outlets off.

Or you could skip that whole Wait condition in first rule and instead create a second rule that has a Predicate of those outlets being on, a trigger of SR+120, and an action to turn off those outlets.

Either option should be fine - as I understand it, there's no meaningful performance-related penalty to splitting it up into 2 rules vs just one, but someone smarter than me can hopefully confirm or elaborate on that.

1 Like