Time of Day Events

Its a shame this is significantly more difficult (or rather, more work to achieve the same result) than OpenHAB 1

It’s just different, not more difficult.

http://docs.openhab.org/addons/bindings/astro/readme.html

You even don’t need any items to trigger events:

when
    Channel 'astro:sun:home:rise#event' triggered START 
then
4 Likes

Hi @sihui,
I am trying this example to switch a light at sunset, but i’l get an error in HABmin:
image

I dit this with:

Channel 'astro:sun:home:set#start' triggered START

As with:

Channel 'astro:sun:home:set#event' triggered START

Same error on the line.
Any idea what this may cause?

ESH Designer (that is a screenshot of ESH Designer, not Habmin) is kind of stuck in time. The latest working version was released before Channel triggers were implemented. You will also see it falsely marking all the third party Actions you may call and any Items defined using PaperUI as errors.

Despite its lack of updating it is the best we have until someone decides to spend the time to fix it, the vscode adds syntax highlighting, or the Experimental Rules Engine stops being experimental.

Ok Rich, yes you are right it is ESH Designer :blush: my mistake…
Thanks for the explanation! I’l have to keep that in mind. I used to use only text files till i saw a tutorial where ESH D was used. Looked like a nice tool, but…
It could have been a beautifut nice tool with syntax checking.

@deltabert you might want to check out openHAB VSCode extension - it recently gained Language Server Protocol support, which means it already highlights errors in your code :wink:
The prerequisite is latest openHAB SNAPSHOT and misc-lsp addon (Language Server Support) installed on your system. See here for more details.

Cheers,
Kuba

3 Likes

Thanks @kubawolanin, I just installed Visual Studio with the openhab extension, and here i do not have the error indication. But i do not use the snapshot… Changed a rule and saved it. seems to work, althoug i have an error on REST AP on top of the screenI. Don’t know if that’s important at the moment.

Looks as i will switch to MS VS, although i prefer real open source products (you never know what they are collecting now… :wink: )

Note it’s not Visual Studio (IDE) but Visual Studio Code - opensource general-purpose code editor :wink:

@kubawolanin. I see that you are the maker of the openHAB VS Code Extension. Great combination, and thank you for building this!
I do have a small issue though. Everything seems to work OK, i can edit mt rule files without a problem. However i do get this message in the status bar on top of the screen:
image

And when i open the Settings and Search for REST API, i see that “openhab.useRestApi”: true, but the “openhab.username”: “”, and “openhab.password”: “”, are empty.
So i tried to edit these like so:


But i don’t know how to save this, anyhow File::Save does not work.

It does not seem to interfere with the normal editing, because i can reach the files on the RPi share and they are changed as well. Still it worries me a little bit…
Any idea wat this is causing?

@deltabert you need to point "openhab.host" to your openHAB IP address or hostname. See the docs for more details.

OK, think i found it. The save button for saving the user settings which overwrite the defaults.
Thanks, i changed the “openhab.host” parameter.
Have to get acquainted with this editor :blush:

1 Like

Sorry to bring this back up, but in a bid to almost complete my OH1 to OH2 migration, I’m just trying to tame the last of my rules. I have a lot of reliance on times of day, for example, my motion sensors only work when LUX is below a certain parameter AND its a specific time of day.

I’m currently testing, using some of the logic above, but not having much luck.

I’m using the theory behind @mhilbush’s original post, but cobbled together using PaperUI rather than .items. I’m using Mark’s rule set.

I’ve defined an Offset on my night#start to bring it into real time for testing, I’m just having problems with triggering the channel!

capture20171111113053873

rule “Night test”
when
Channel ‘astro:sun:casavenicio:night#start’ triggered START
then
sendMail(“myemail@addre.ss”, “NIGHT”, “Night TEST Channel Trigger!”)
logInfo(“EXTRA”, “Its Night time, dark things can happen”)
end

The logs show that the time comes and goes, and effectively nothing occurs. Any ideas?

What version of OH are you running? If you’re running 2.1 stable, you might be experiencing this.

Please be aware that the event channel trigger is in your case

Channel 'astro:sun:casavenicio:night#event' triggered START //beginning of night

or

Channel 'astro:sun:casavenicio:night#event' triggered END //end of night

This channel does not need to be linked to any item (in fact, this would be totally useless)

1 Like

Virtual beer for you! Cheers @Udo_Hartmann !!

Running openHAB 2.2.0 Build #1112, it appears getCalendar() is now deprecated?

The method getCalendar() from the type DateTimeType is deprecated

Any ideas how I might tweak this rule to work?

rule “Get time period for right now”
when
System started
then
logInfo(“EXTRA”, “System started, attempting to get time period for right now”)
val now = new Date()
val dawn = new Date((DawnStart_Time.state as DateTimeType).calendar.timeInMillis)
val day = new Date((DayStart_Time.state as DateTimeType).calendar.timeInMillis)
val dusk = new Date((DuskStart_Time.state as DateTimeType).calendar.timeInMillis)
val night = new Date((NightStart_Time.state as DateTimeType).calendar.timeInMillis)

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

http://docs.openhab.org/configuration/rules-dsl.html#datetime-item

This should be useful.

The Design Pattern: Time Of Day has been updated since this posting (maybe was written after it actually) which has a little bit more concise implementation.

Hi All. i have tried this and ended up with some errors .

Part 1

2020-05-13 17:28:44.114 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:29:43.768 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:30:44.049 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:31:44.078 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:32:44.340 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:30:44.049 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:31:44.078 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:32:44.340 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:33:44.162 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:34:43.650 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:35:44.118 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:36:44.106 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:37:44.539 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:38:43.816 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:39:45.071 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:40:27.095 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost

java.lang.RuntimeException: {"error":"timeout"}

	at org.influxdb.impl.InfluxDBErrorHandler.handleError(InfluxDBErrorHandler.java:19) ~[influxdb-java-2.2.jar:?]

2020-05-13 17:40:43.957 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:41:12.371 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost

java.lang.RuntimeException: {"error":"timeout"}

	at org.influxdb.impl.InfluxDBErrorHandler.handleError(InfluxDBErrorHandler.java:19) ~[influxdb-java-2.2.jar:?]

2020-05-13 17:41:46.163 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:42:10.653 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Get time period for right now': Could not cast NULL to org.eclipse.smarthome.core.library.types.DateTimeType; line 13, column 26, length 36

2020-05-13 17:42:22.685 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Get time period for right now': Could not cast NULL to org.eclipse.smarthome.core.library.types.DateTimeType; line 13, column 26, length 36

2020-05-13 17:42:30.873 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:30.874 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:30.875 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:30.876 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:30.877 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:30.877 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:33.040 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:33.042 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:33.043 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:33.044 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:33.045 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:33.045 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:42:44.260 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:43:02.953 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:02.954 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:02.956 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:02.957 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:02.958 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:02.960 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:32.817 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:32.820 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:32.822 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:32.823 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:32.824 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:32.825 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:43:44.264 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:44:02.989 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:02.991 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:02.994 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:02.997 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:02.998 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:02.999 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:33.434 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:33.435 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:33.436 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:33.437 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:33.438 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:33.439 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:44:44.262 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-misc-restdocs'

2020-05-13 17:45:03.416 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:45:03.417 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunriseStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:45:03.418 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:45:03.419 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:45:03.419 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetStart_Time' for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

2020-05-13 17:45:03.420 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

Items

// Times of Day
String TimePeriodOfDay              "Time of Day [%s]"

DateTime DawnStart_Time             "Dawn Start [%1$tH:%1$tM]"              { channel="astro:sun:local:civilDawn#start" }
DateTime DawnStop_Time              "Dawn Stop [%1$tH:%1$tM]"               { channel="astro:sun:local:civilDawn#end" }
DateTime DayStart_Time              "Day Start [%1$tH:%1$tM]"               { channel="astro:sun:local:daylight#start" }
DateTime DayStop_Time               "Day Stop [%1$tH:%1$tM]"                { channel="astro:sun:local:daylight#end" }
DateTime DuskStart_Time             "Dusk Start [%1$tH:%1$tM]"              { channel="astro:sun:local:civilDusk#start" }
DateTime DuskStop_Time              "Dusk Stop [%1$tH:%1$tM]"               { channel="astro:sun:local:civilDusk#end" }
DateTime NightStart_Time            "Night Start [%1$tH:%1$tM]"             { channel="astro:sun:local:night#start" }
DateTime NightStop_Time             "Night Stop[%1$tH:%1$tM]"               { channel="astro:sun:local:night#end" }
DateTime MorningNightStart_Time     "MorningNightStart [%1$tH:%1$tM]"       { channel="astro:sun:local:morningNight#start" }
DateTime MorningNightStop_Time      "MorningNightStop [%1$tH:%1$tM]"        { channel="astro:sun:local:morningNight#end" }
DateTime EveningNightStart_Time     "EveningNightStart [%1$tH:%1$tM]"       { channel="astro:sun:local:eveningNight#start" }
DateTime EveningNightStop_Time      "EveningNightStop [%1$tH:%1$tM]"        { channel="astro:sun:local:eveningNight#end" }

// Events
Switch DawnStart_Event              "Start of Dawn Event"
Switch DayStart_Event               "Start of Day Event"                         
Switch DuskStart_Event              "Start of Dusk Event"                            
Switch NightStart_Event             "Start of Night Event"                           

// Items
Switch Dawn                         "Dawn [%s]"                             // After Dawn and before Day
Switch Day                          "Day [%s]"                              // After Day and before Dusk
Switch Dusk                         "Dusk [%s]"                             // After Dusk and before Night
Switch Night                        "Night [%s]"                            // After Night and before Dawn

Number SunAzimuth                   "Azimuth [%.0f °]"                      { channel="astro:sun:local:position#azimuth" }
Number SunElevation                 "Elevation [%.0f °]"                    { channel="astro:sun:local:position#elevation" }

String MoonPhase                    "MoonPhase [%s]"                        { channel="astro:moon:local:phase#name" }

Rule :

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).calendar.timeInMillis)
    val day = new Date((DayStart_Time.state as DateTimeType).calendar.timeInMillis)
    val dusk = new Date((DuskStart_Time.state as DateTimeType).calendar.timeInMillis)
    val night = new Date((NightStart_Time.state as DateTimeType).calendar.timeInMillis)

    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).calendar.timeInMillis)
    val day = new Date((DayStart_Time.state as DateTimeType).calendar.timeInMillis)
    val dusk = new Date((DuskStart_Time.state as DateTimeType).calendar.timeInMillis)
    val night = new Date((NightStart_Time.state as DateTimeType).calendar.timeInMillis)
    val sunset = new Date((SunsetStart_Time.state as DateTimeType).calendar.timeInMillis)
    val sunrise = new Date((SunriseStart_Time.state as DateTimeType).calendar.timeInMillis)

    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).calendar.timeInMillis)
    val day = new Date((DayStart_Time.state as DateTimeType).calendar.timeInMillis)

    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).calendar.timeInMillis)
    val dusk = new Date((DuskStart_Time.state as DateTimeType).calendar.timeInMillis)

    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).calendar.timeInMillis)
    val night = new Date((NightStart_Time.state as DateTimeType).calendar.timeInMillis)

    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).calendar.timeInMillis)
    val morningNightStop = new Date((MorningNightStop_Time.state as DateTimeType).calendar.timeInMillis)
    val eveningNightStart = new Date((EveningNightStart_Time.state as DateTimeType).calendar.timeInMillis)
    val eveningNightStop = new Date((EveningNightStop_Time.state as DateTimeType).calendar.timeInMillis)

    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

RestDocs moved from the misc category to the UIs category in OH 2.4 I think, maybe early on in OH 2.5. There are lots of threads discussing it with solutions.

And since the Astro binding supports events now (and has for some years) this particular approach is somewhat archaic.

Thank you. Will look in to it.