How does $sunrise and $nextsunrise update/work?


#1

Hi there,

I am looking at something I think is wrong in webcore.

In several pistons I am using the $sunrise, $sunset, $nextsunrise, $nextsunset. The issue I found is when I compare the today’s current $sunrise and $nextsunrise values for my location, these are the following :

$sunrise : 15/03/2018 at 07:16:00
$nextSunrise : 16/03/2018 at 07:16:00

But in the IDE, it is clearly written the the next sunrise will occur at 7:14:00 on the 16th, and not again at 7:16:00. And I can vouch for that, as I know that in March we get about 2 minutes more of sun both at sunrise and at sunset.

Several questions here :

  • Is it normal that the $nextsunrise time value is the same as the today’s $sunrise time value ?
  • If so, will it update automatically at midnight ? And in this case both $sunrise and $nextsunrise will move to 7:14:00 ?
  • And again if so, what will happen with my pistons ? For now their next scheduled time for sunrise is 7:16:00 on the 16th. Will it also change at midnight automatically to become 7:14:00 ?

Thank you in advance.


#2

I’ve never looked at it in that detail…but I can tell you that it does indeed work. WC knows when sunrise is so it’s getting it right over time. I imagine that it is changing it at midnight. But w/o looking at the code, or observing it over several days, there’s no way to know. But it does work…


#3

I haven’t looked at the WC code for this, but I can tell you the CoRE code just returned today’s sunrise/sunset w/ tomorrow’s date.


#4

ST updates sunrise time at midnight, so you’ll need to force a piston execution at 00:01 to reschedule for the next run.

I do this with a blank timer at the top of pistons that schedule for sunset / sunrise:

every 1 day’s at 00:01
DO
(Nothing)
end do
end every

I have no idea how WC could get the time of tomorrow’s sunrise today as ST don’t provide that info in their API.

My best guess is that $nextSunrise is not for the actual time but more to tell a more complex piston the date of the next sunrise (has today’s sunrise been and gone)


#5

Thank you both for your answers.

Indeed RobinWinbourne was right : my sunrise related pistons used the yesterday’s sunrise time (7:16 like yesterday instead of 7:14 for today). And now my Sunrise pistons for tomorrow are planned at 7:14. We therefore have a 1-day shift in the sunrise time when using WebCore. This may not be a huge issue for 363 days out of 365, as the shift is only a few minutes, but twice a year it will be an issue when changing time because of the daylight saving time.

I will do what you suggested and add a blank action to reset the timer at midnight.

However, FYI, ST does provide the information of tomorrow’s sunrise, and we can find it in the IDE : My Locations (in the top left corner) -> smartapps (in the table, not in the links at top) -> Weather Station -> Scheduled Jobs -> Sunrise Handler.
To be noted that the Sunrise Handler provides the sunrise time for the next sunrise, not necessarly for tomorrow. But if you wait for today’s sunrise to occur, it will then display the tomorrow’s sunrise time. I think that webcore should also be able to update it based on this.

Thank you again anyway.