I had exactly the same problems.
I started with openhab1.8
I initially forgot to add the astro binding
I had real problems getting the syntax for creating timers based on the sunrise/sunset times.
Then discovered these were already set up as “Events” so I set up 2 switches
1 for sunrise and 1 earlier by 30 minutes to give me more useful “Darkness”
// schedules a event which starts at sunrise, updating the Switch with ON, followed by a OFF
switch sSunrise_Event {astro=“planet=sun, type=rise, property=start”}
// schedules a event which starts 30 minutes BEFORE sunrise
Switch sSunrise_EventD {astro=“planet=sun, type=rise, property=start, offset=-30”}
and 2 more for sunset.
This was then used in a simple rule, to set a switch “Darkness”, that could then be used in many other rules. You could also manually change the “Darkness” switch, for testing.
Testing cron and timers is difficult without a time machine or a 24 hour delay.
rule "Darkness start at sunset"
when
Item sSunset_Event received update ON
then
logInfo(“DMM”,"Sunset_Event occurred ")
if(sOutsideLightFAutoDelay.state == OFF) sendCommand(Darkness, ON)
sendCommand(StrTimer,sSunset_Event.state.toString)
end
rule "Darkness start delayed after sunset"
when
Item sSunset_EventD received update ON
then
logInfo(“DMM”,"Sunset_EventD occurred ")
if(sOutsideLightFAutoDelay.state == ON) sendCommand(Darkness, ON)
end
This worked correctly for months.
I tried this in Openhab2 and discovered the same problem, the “Events” are not supported.
So I ignored openHab2, for a long while.
Recently I’ve spent time to understand how to define and use timers.
So I’ve set up a 2nd switch to use timers.
I then had the same problem as you, that sunrise was before now, and so never triggered.
I just check the times to now(), and added 24 hours.
Tomorrows sunrise is near enough the same as today, at least from the point of view of turning on outside lights.
I also discovered that you need to specifically reset these on startup.
So I added a rule on startup to set the timers
rule "Set THINGS on StartUP"
when
System started
…
I also needed a rule to check if the 30minute delay, to give twilight or sunset/sunrise was required. Then if it changed, recalculate and reset the timers.
Now I’ve got all these working to replace the Sunset_Event. I will try Openhab2.
I also await the new rules engine and how Astro is going to be interpreted.