Need help cleaning up simple lighting routine

I've built several more complicated rule machine routines but am stumped with what I feel is a very simple one. Basically I want a few switches to come on early morning, go off at sunrise, then come on at sunset and go off before midnight. I'm getting tangle up with triggers and conditions.

Thanks in advance for your help.

One suggestion that I would recommend is to break it into 2 rules, call it Lights-morning and Lights-evening. That is what I did for my outside lights and it works well. Rules are cheap. Two simple rules work better for me than one complicated rule.

You could also use Basic Rules for this, as an example.....

Basic Rule-evening:
When Time of Day is 5 minutes before sunset ...
Turn on Back Porch Lights
Wait until Time of Day is 9:15 PM, then ...
Turn off Back Porch Lights

Basic Rule- morning:
When Time of Day is 6:00 AM ...
Turn on Back Porch Lights
Wait until Time of Day is sunrise, then ...
Turn off Back Porch Lights

I don't think you need all those "time between"s. The rule gets trigger at an exact time so you can just use those exact trigger times for your conditionals. I tend to make these simple - IF (time=6:00 AM) do something ENDIF and then the next trigger time. So no ELSE_IF or ELSE - just 4 IF statements.

Here's an option

Trigger Events
When time is 6:00 AM
OR
When time is Sunset

Actions to Run
On: Gate right - plug 1, ...
Wait for events: When time is Sunrise OR When time is 11:59 PM
Off: Gate right - plug 1, ...
1 Like

Room Lighting is purpose built to do this type of automation...is there a reason you aren't using it? You could do two simple RL automations - one for the AM, one for the PM. No "coding" in RM required. :wink: If you just prefer RM, I get that. :slight_smile:

Example of a simple Room Lighting automation for your morning...took all of one minute to set up:

You could also use the Time Periods feature in RL to set up four periods in one (or two) RL instance(s):


I think your current design should work. Personally, I'm a fan of designing rules so that if they're retriggered at any point, they still do the right thing, and your IF / ELSE-IF / ELSE logic does exactly that. I would disagree with the suggestions to break into separate rules.

If I were doing this myself, though, it'd probably be as time periods in Room Lighting these days.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.