Configure Sunset to trigger light on

Latest OpenHabian on a Pi 4.

I have had this working before, but owing to a data corruption I have had to rebuild my installation.

I am trying to turn on a light at sunset, but I can’t seem to get it working. I am doing this via the Rules UI.

Can I be pointed in the right direction…

DSL rule used in Astro binding Channel trigger: receivedEvent only contains 'START' shows a list of triggers.

Does that mean you can’t use this to trigger another event in the GUI?

No, it means choosing the right rule trigger.

Whatever your Item AstroSunData_CivilDusk_Start represents, it is unlikely to receive command ON.

Most people use the Astro binding trigger events instead.

1 Like

Isn’t AstroSundData_CivilDusk_Start a trigger event?

When I add this as a trigger event, the options provided don’t make sense, probably because it is not suitable.

No, it’s a DateTime item that shows you the exact time when Civil Dusk starts. In your item, that’s 17:09 on November 19.

Note that this date is not updated exactly at 17:09. It was updated earlier in the day when Astro refreshed the values (usually early in the morning).

When 17:09 struck, openHAB used the Range Event channel to report that Civil Dusk had started. The reported states are START and END.


As @rossko57 noted, you don’t need to make an item for the Range Event channel. You can call it directly in your rule.


I simplify things by having an item called Time_of_Day, and two DSL rules to determine its state.

rule "Day"
    Channel 'astro:sun:local:rise#event' triggered START

rule "Night"
    Channel 'astro:sun:local:set#event' triggered START

Many of my rules start with an if condition to check if it’s Day or Night.

1 Like

Also add a rule on startup that checks the current time against the sunrise time for that day, and set your Time_Of_Day item accordingly. This covers the case when you restarted openhab, and before those astro events fired. Or in the OP’s case, turn on the light if openhab is restarted after sunset.

1 Like

Ah thank you pointing that out… it was there in plain sight and I missed it!

I will try that.

I now know why I didn’t see the Trigger events, I was trying to add them from the Model and they are not listed there.

I noted you select the Thing in the Trigger event and then the channel. I must of done that a couple of years ago when I originally had it working! Will make a note this time.

Lets see if it works later today.

Out of interest is this:

rule “Day”
Channel ‘astro:sun:local:rise#event’ triggered START

rule “Night”
Channel ‘astro:sun:local:set#event’ triggered START

Just a way of describing, in text, the GUI rule or is it stored somewhere like this?

Thank you for your help!

This is DSL rule syntax that can e.g. be used to store them in .rules files.