Simply turn on at sunrise, turn off at sunset in openhab2

PaperUI -> Configuration -> Things -> select Astro sun data channel and fill in your offset value under “Range event”

Exactly what I was looking for thank you sir.

I will set up a test for sunset :slight_smile:

Always the place to look: http://docs.openhab.org/addons/bindings/astro/readme.html

True. It was my brain that totally failed to make the connection to PaperUI for channel properties :blush:

Still to have the original question answered, it would be interested to know how the offset can be set in a config file. @sihui any input on that?

No, haven’t it figured out yet …
If Kai and Gerhard don’t know, who else should know it?:grinning:

Edit:

Hello all,

Got stuck with a syntax error while copied Marks example:

22:11:55.083 [INFO ] [marthome.event.ItemStateChangedEvent] - SunriseStart_Time changed from NULL to 2017-02-11T08:05:00.000+0100
22:11:55.100 [INFO ] [home.event.ItemChannelLinkAddedEvent] - Link 'SunriseStart_Time-astro:sun:local:rise#start' has been added.
22:11:55.115 [INFO ] [marthome.event.ItemStateChangedEvent] - SunsetStart_Time changed from NULL to 2017-02-11T17:41:00.000+0100
22:11:55.134 [INFO ] [marthome.event.ItemStateChangedEvent] - SunsetStart_Time changed from NULL to 2017-02-11T17:41:00.000+0100
22:11:55.139 [INFO ] [home.event.ItemChannelLinkAddedEvent] - Link 'SunsetStart_Time-astro:sun:local:set#start' has been added.
22:11:55.155 [INFO ] [marthome.event.ItemStateChangedEvent] - DateT changed from 2017-02-11T22:11:03.051+0100 to 2017-02-11T22:11:55.096+0100
22:11:55.165 [INFO ] [marthome.event.ItemStateChangedEvent] - CurrentTime changed from NULL to 2017-02-11T22:11:55.096+0100
22:11:55.170 [INFO ] [marthome.event.ItemStateChangedEvent] - LocalTime changed from 2017-02-11 22:11:41 CET to 2017-02-11 22:11:55 CET
22:11:55.172 [INFO ] [home.event.ItemChannelLinkAddedEvent] - Link 'CurrentTime-ntp:ntp:local:dateTime' has been added.
22:11:55.204 [INFO ] [marthome.event.ItemStateChangedEvent] - MoonPhase changed from NULL to FULL
22:11:55.224 [INFO ] [marthome.event.ItemStateChangedEvent] - SunriseStart_Time changed from NULL to 2017-02-11T08:05:00.000+0100
22:11:55.251 [INFO ] [marthome.event.ItemStateChangedEvent] - DateT changed from 2017-02-11T22:11:55.096+0100 to 2017-02-11T22:11:55.133+0100
22:11:55.261 [INFO ] [marthome.event.ItemStateChangedEvent] - CurrentTime changed from 2017-02-11T22:11:55.096+0100 to 2017-02-11T22:11:55.133+0100
22:12:03.072 [INFO ] [marthome.event.ItemStateChangedEvent] - DateT changed from 2017-02-11T22:11:55.133+0100 to 2017-02-11T22:12:03.051+0100
22:12:03.081 [INFO ] [marthome.event.ItemStateChangedEvent] - CurrentTime changed from 2017-02-11T22:11:55.133+0100 to 2017-02-11T22:12:03.051+0100
22:12:03.092 [INFO ] [marthome.event.ItemStateChangedEvent] - LocalTime changed from 2017-02-11 22:11:55 CET to 2017-02-11 22:12:03 CET
22:12:04.271 [INFO ] [thome.model.script.time-of-day.rules] - CurrentTime received update
22:12:04.271 [INFO ] [thome.model.script.time-of-day.rules] - CurrentTime received update
22:12:04.279 [INFO ] [thome.model.script.time-of-day.rules] - CurrentTime received update
22:12:04.370 [WARN ] [.rule.jvmmodel.RulesJvmModelInferrer] - Duplicate field: 'CurrentTime'. Ignoring 'org.eclipse.smarthome.core.library.items.DateTimeItem'.
22:12:04.483 [WARN ] [.rule.jvmmodel.RulesJvmModelInferrer] - Duplicate field: 'CurrentTime'. Ignoring 'org.eclipse.smarthome.core.library.items.DateTimeItem'.
22:12:17.658 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'astro.rules'
22:12:17.671 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'astro.rules' is either empty or cannot be parsed correctly!
22:12:17.805 [WARN ] [.rule.jvmmodel.RulesJvmModelInferrer] - Duplicate field: 'CurrentTime'. Ignoring 'org.eclipse.smarthome.core.library.items.DateTimeItem'.

Where can I find the linenr, characternr, variable, … which is causing the syntax error?
Using Openhab Designer, though only having ‘could not resolve issues’-errors.

In my opinion the items file in Openhab2 should be replace by the items editor of the PaperUI. But in my opinion there are some looses en while editing/deleting existing items.

Though after looking a little further in the logs, and after adding some LogInfo-s the rule is being run, though sunset/rise I will see tomorrow (I hope).

Actually that was a workaround because at that time the astro2 binding did not support events.
That has changed and can now simply be accomplished by:

rule "example trigger rule"
when
    Channel 'astro:sun:home:rise#event' triggered START 
then
    ...
end

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

Which reminds me that I should put a note at the top of my post indicating that the Astro binding now has this functionality.

2 Likes

The syntax for adding the offset in the config files is now documented in the same place too:

astro:sun:home [ geolocation="xx.xxxxxx,xx.xxxxxx", altitude=100, interval=60 ] {
    Channels:
        Type rangeEvent : rise#event [
            offset=-30
        ]
}

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

Oddly though, I can’t see the offset option in Paper UI (using snapshot from 10th Feb), just start, end and duration

It’s called “Range Event”, not “Offset” or something like that …

All: thanks for your input!
I will give it another try.

Though one questions remain:

Now that offset’s are supported would something like this work?

rule "sunrise_offset_30"
when
Channel “astro:sun:home:rise#event, offset=30” triggered START
then
logInfo(“Sunrise”, “Sunrise rule triggered 30 minutes after sunrise”)
end

No, see the examples in the docs for proper setup:

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

1 Like

thanks, that helped a bunch, I got all my rules re-factored for OH2 now.

1 Like