Sunrise, Sunset, NextSunrise, etc


#1

Like most people here most of my pistons revolve around Sunset and the next morning’s Sunrise. I’ve been using the variables $sunset and $nextsunrise for most of them, but wonder if I’m making things too complicated?

Do any of the Sunset and Sunrise variables ($sunrise, $sunset) or the Presets (when Time is selected as the virtual device) take into account the date change at midnight?

For example, it’s 8pm where I’m at now and pitch black outside. However, sunrise was at 7am and sunset was at 5pm - so the time now is actually NOT between sunset and sunrise for today. It is between sunset and the next sunrise though, so the pistons that have my lights on now use $sunset and $nextsunrise. After midnight though, I want the lights to turn off on that day’s Sunrise, so the variables shift from $nextsunrise to $sunrise.

I believe my logic is accurate but wonder if there’s something in WebCoRE that takes some of the headache out of this, and I’m not taking advantage of it? Feel free to tell me if I’m just making it too complicated, too! lol


#2

webCoRE is smart enough that when you use sunrise and sunset if you’re past one of them it assumes the next. So, if you have a piston that triggers or conditions on sunrise and it’s still before midnight, it uses the sunrise of the next day.

Also, I’m not sure why you need to use variables for this. These are available as presets under the Time virtual device.

Simple example … I have a piston that checks that the time is between 15 mins after sunset and sunrise (the next morning). I just use ‘sunset’ and ‘sunrise.’


#3

I wrote my pistons using the default system variables $sunset and $sunrise before I realized Time and Presets were an option. When you select one of the $ variables, it displays their value so I could see my if statement in my original post would evaluate as false despite me wanting the lights on.

A lot of this can only be figured out by trial and error so I posted this to see if I was making things unnecessarily complicated (although they worked).

Thanks for the quick response!