Turn on light an hour after sunset

Hi Everybody,

Trying to transition from ISY to OpenHAB. Facing many challenges.

I want to turn on a light an hour after sunset. I’ve installed Astro Binding v2.0. Created “Sun” and “Moon” things from the GUI. They got named as “astro:sun:local:rise#start” for example.

I then created two items to show the time in the GUI:
DateTime SunsetTime “Sunset [%1$tH:%1$tM]” (Astro) { channel=“astro:sun:local:set#start” }
DateTime SunriseTime “Sunrise [%1$tH:%1$tM]” (Astro) { channel=“astro:sun:local:rise#end” }

and added to the sitemap to see the values:

Frame label="Dates" {
    Text item=SunsetTime
    Text item=SunriseTime

But, could not see the values in the GUI. It complains about:
2017-04-09 05:40:21.917 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SunsetTime' for widget org.eclipse.smarthome.model.sitemap.Text

Would appreciate help to see the time, and write a rule to turn on a light an hour after the sunset.


At first sight your syntax looks correct. Hmmmmmm…

the error seems to imply OH does not “know” your items.
Has the items file been loaded correctly?(i.e. in openhab.log “Loading model ‘yourfile.items’”)
As for a rule, here an example rule that triggers when civil dusk ends. There are several “event”-type chanells that might suit your needs(e.g. sundown, civil dusk, nautical dusk…). Additionally you can set an offset from e.g. sunset as explained here:

rule "pitch black"
  Channel 'astro:sun:local:civilDusk#event' triggered END
	//do stuff when it gets really dark


I had my items in a wrong file, which causes the weird behavior. Now I can read the sunset time.
But, how can I compare the time with sunset/sunrise offsets? Can I have a rule which would say something like this:

Date.Now is between [astro:sun:local:set + 1 hour, astro:sun:local:rise - 2 hours]

You might be interested in this approach - switching an Item state by astro or time based events