OpenHAB 2.x - Astro Binding has stoped working

Hey,
I’m stuck with a problem that appeared from nowhere, to be more exactly Astro Binding is not working anymore. Does not calculate season, day period, nothing. I tried to disable it and enable it again, clear the temp folder but no results. Any sugestions are more that apreciated.

Configuration: I’m runing the latest version of OH 2.x in a docker container. All good except this Astro.

Thanks.

Would you like to share your openhab.log from last startup, if there are any Astro related messages. And from most recent midnight. How do you know its not working i.e. what are you expecting that is not there - Item states, events? How is this configured, xxx.things files - are those files loading? What does the Thing(s) status look ike in PaperUI?
What’s your latitude? (Sometimes ‘its not working’ has been about seasonal effects)

And please please

is just idleness. What version exactly?

Exact version is, 2.5.12
Astro is not working because rules based on this one are not reacting. I have also a section on my OH sitemap that shows season and other astro related info, it is december and it shows that is autumn. Other OH functions are OK so things, rules, sitemap is loading.

No errors in the log,

root@oh-main-dk:~# tail -f /home/delta04/docker/smarthome/openhab/userdata/logs/openhab.log | grep astro
2022-12-20 22:08:24.634 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘astro.rules’

and if you are asking about what is inside astro.rules, here it is.

delta04@oh-main-dk:~/docker/smarthome$ cat openhab/conf/rules/astro.rules

import java.util.Date

// Time of Day Rules
// Requires time update every 60 seconds

val String RFN = “time-of-day.rules”

rule “Get time period for right now”
when
System started
then
val now = new Date()
val dawn = new Date((DawnStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val day = new Date((DayStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val dusk = new Date((DuskStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val night = new Date((NightStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
// val sunset = new Date((SunsetStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
// val sunrise = new Date((SunriseStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)

val String initStr = "Initializing time period. The time of day is "

if(now.after(dawn) && now.before(day)) {
    logInfo(RFN, initStr + "Dawn: " + now)
    Dawn.sendCommand(ON)
    Day.sendCommand(OFF)
    Dusk.sendCommand(OFF)
    Night.sendCommand(OFF)
    TimePeriodOfDay.postUpdate("Dawn")
}
else if(now.after(day) && now.before(dusk)) {
    logInfo(RFN, initStr + "Day: " + now)
    Dawn.sendCommand(OFF)
    Day.sendCommand(ON)
    Dusk.sendCommand(OFF)
    Night.sendCommand(OFF)
    TimePeriodOfDay.postUpdate("Day")
}
else if(now.after(dusk) && now.before(night)) {
    logInfo(RFN, initStr + "Dusk: " + now)
    Dawn.sendCommand(OFF)
    Day.sendCommand(OFF)
    Dusk.sendCommand(ON)
    Night.sendCommand(OFF)
    TimePeriodOfDay.postUpdate("Dusk")
}
else {
    logInfo(RFN, initStr + "Night: " + now)
    Dawn.sendCommand(OFF)
    Day.sendCommand(OFF)
    Dusk.sendCommand(OFF)
    Night.sendCommand(ON)
    TimePeriodOfDay.postUpdate("Night")
}

end

rule “Generate Time of Day Events”
when
Item CurrentTime received update
then
val now = new Date()
val dawn = new Date((DawnStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val day = new Date((DayStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val dusk = new Date((DuskStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val night = new Date((NightStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val sunset = new Date((SunsetStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val sunrise = new Date((SunriseStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)

if((now.getTime-(now.getTime%60000)) == (dawn.getTime-(dawn.getTime%60000))) {
    logInfo(RFN, "Transitioning to Dawn!!!")
    DawnStart_Event.postUpdate(ON)
}
else if((now.getTime-(now.getTime%60000)) == (day.getTime-(day.getTime%60000))) {
    logInfo(RFN, "Transitioning to Day!!!")
    DayStart_Event.postUpdate(ON)
}
else if((now.getTime-(now.getTime%60000)) == (dusk.getTime-(dusk.getTime%60000))) {
    logInfo(RFN, "Transitioning to Dusk!!!")
    DuskStart_Event.postUpdate(ON)
}
else if((now.getTime-(now.getTime%60000)) == (night.getTime-(night.getTime%60000))) {
    logInfo(RFN, "Transitioning to Night!!!")
    NightStart_Event.postUpdate(ON)
}

if((now.getTime-(now.getTime%60000)) == (sunrise.getTime-(sunrise.getTime%60000))) {
    logInfo(RFN, "Start of Sunrise!")
    SunriseStart_Event.postUpdate(ON)
}
else if((now.getTime-(now.getTime%60000)) == (sunset.getTime-(sunset.getTime%60000))) {
    logInfo(RFN, "Start of Sunset!")
    SunsetStart_Event.postUpdate(ON)
}

end

rule “Dawn Started”
when
Item DawnStart_Event received update ON
then
val now = new Date()
val dawn = new Date((DawnStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val day = new Date((DayStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)

if(now.after(dawn) && now.before(day)) {
    logInfo(RFN, "Its Dawn: " + now)
    Dawn.sendCommand(ON)
    Day.sendCommand(OFF)
    Dusk.sendCommand(OFF)
    Night.sendCommand(OFF)
    TimePeriodOfDay.postUpdate("Dawn")
}

end

rule “Day Started”
when
Item DayStart_Event received update ON
then
val now = new Date()
val day = new Date((DayStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val dusk = new Date((DuskStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)

if(now.after(day) && now.before(dusk)) {
    logInfo(RFN, "Its Day: " + now)
    Dawn.sendCommand(OFF)
    Day.sendCommand(ON)
    Dusk.sendCommand(OFF)
    Night.sendCommand(OFF)
    TimePeriodOfDay.postUpdate("Day")
}

end

rule “Dusk started”
when
Item DuskStart_Event received update ON
then
val now = new Date()
val dusk = new Date((DuskStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val night = new Date((NightStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)

if(now.after(dusk) && now.before(night)) {
    logInfo(RFN, "Its Dusk: " + now)
    Dawn.sendCommand(OFF)
    Day.sendCommand(OFF)
    Dusk.sendCommand(ON)
    Night.sendCommand(OFF)
    TimePeriodOfDay.postUpdate("Dusk")
}

end

rule “Night started”
when
Item NightStart_Event received update ON
then
val now = new Date()
val morningNightStart = new Date((MorningNightStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val morningNightStop = new Date((MorningNightStop_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val eveningNightStart = new Date((EveningNightStart_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val eveningNightStop = new Date((EveningNightStop_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)

if((now.after(morningNightStart) && now.before(morningNightStop)) || 
   (now.after(eveningNightStart) && now.before(eveningNightStop))) {
    logInfo(RFN, "Its Night: " + now)
    Dawn.sendCommand(OFF)
    Day.sendCommand(OFF)
    Dusk.sendCommand(OFF)
    Night.sendCommand(ON)
    TimePeriodOfDay.postUpdate("Night")
}

end

rule “Sunrise started”
when
Item SunriseStart_Event received update ON
then
val now = new Date()
logInfo(RFN, "Its Sunrise : " + now)
end

rule “Sunset started”
when
Item SunsetStart_Event received update ON
then
val now = new Date()
logInfo(RFN, "Its Sunset : " + now)
end


Related Things are green in PaperUI but information is wrong and stuck.

Can you clarify - they look reasonable to me (not knowing your location), I can see today’s date, and Astro generated values will normally remain the same from one midnight to the next.

Let’s go one step at a time.
The rules shown all seem to cascade from a single (non-Astro) event,

Is that Item getting updates?

Looks like it is kicking.

root@oh-main-dk:~# tail -f /home/delta04/docker/smarthome/openhab/userdata/logs/events.log | grep CurrentTime
2022-12-20 23:17:25.556 [vent.ItemStateChangedEvent] - CurrentTime changed from 2022-12-20T23:16:25.549+0200 to 2022-12-20T23:17:25.549+0200
2022-12-20 23:18:25.556 [vent.ItemStateChangedEvent] - CurrentTime changed from 2022-12-20T23:17:25.549+0200 to 2022-12-20T23:18:25.550+0200
2022-12-20 23:19:25.557 [vent.ItemStateChangedEvent] - CurrentTime changed from 2022-12-20T23:18:25.550+0200 to 2022-12-20T23:19:25.550+0200

Jolly good.
Next find out if your rule is starting - add a logInfo at the top, for example.
Then you’d want to find out about the variables that is comparing.
Log out say DawnStart_Time.state, dawn, now

1 Like

Hmm, After some reboots it started to work, except the season part. It is still autumn from his side.

I guess you are on Earth but we do not even know what hemisphere you are in yet. You have to offer info if you want sensible help. What are you looking at that says autumn?

Hey, sorry. It should definetly say winter instead of autumn. I’m in Romania.
I have some rules that are triggered also by the season.
I see the season name in a sitemap entry,

  Text item=SeasonName icon="sun_clouds"

That doesn’t tell us how that Item gets populated, at all.

And in Paper UI.
Screenshot 2022-12-21 at 15.43.54

should grab seasib info from from this channel.

Screenshot 2022-12-21 at 15.49.13

Most probably it does … It will do…
According to Winter Solstice – When Is Winter 2022 / 2023?

In Bucharest, Romania winter starts : Wednesday, 21 December 2022, 23:48 EET
This corresponds to Wednesday, 21 December 2022, 21:48 UTC.

It is not just the date also the time is required …

Hey, hmm. Never thought of that. Let’s see. :slight_smile:

Hey,
It’s winter also on OH!
Thanks for answering my distress, good thing that was a false alarm.
All good.

1 Like

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