Sunset to Sunrise?

@josh or @James So with the rule engine is it possible to do a between sunset and sunrise and vice versa event trigger? I just can’t seem to figure it out if there is a way.


Between Sunset and Sunrise
If Door Contact == open then
Light = on

@just_jake you will be using IF condition to check the current time when the door contact open event occurs. See below for details and note that you will need to edit the IF condition to change the logic from AND (all) by default to OR (any).


  • if door contact is changed to open


  • If current time is after sunset OR before sunrise
    • Then turn light on
1 Like

Current time is (between) (time) and (time) at (location)

When I click time there is no option for sunset or sunrise but if I use

Current time is (after) (time) and (time) at (location)

When I click time I have that option.

Is this correct?

Correct, you will be using “before sunrise” OR “after sunset” in your scenario.

That’s they way I will make it work. Would it be possible to have the between condition allow sunset and sunrise. It would seem more logical.

1 Like

@just_jake, we did the before sunrise and after sunset because we think between sunset and sunrise can be ambiguous (through the midnight or noon?). But I do get your point, and encourage you to add a feature request so we can track it. :wink:

Hi @James I have the below rule that I want to change to between 12AM & Sunrise. I have to keep changing the rule every season b/c of the time change. How do I go about changing it and keeping the “AND”

You can use two separate conditions:

  • After 12:00 AM
  • Before Sunrise

When you select the time on the second one, you can tap the Sunrise option in the time picker:


1 Like

That’s what I was thinking but I saw “OR” in the example above. Thanks for your help!

It’s one of those “head scratchers” where visualizing it sometimes helps.

So in the original example, it’s not possible for the time (on a single day) to be both after sunset AND before sunrise, so we have to use OR:

In your example, the time we are looking for is between two times on the same day, so we use AND:


Awesome! thanks for the explanation. On that same though, if I wanted to do 30/60 minutes before sunset. How would the rule look in that instance?

@Robert_Bourne, the x minutes before/after sunset and sunrise is not currently supported in the if condition directly, but you can create a variable and update the variable according using an additional rule. See the example below, and please cast your vote if you’d like this offset feature to be implemented in the if condition as well.

1 Like