Sunset rule not working

I am trying to use a rule to switch the outside lighting on at sunset. My system is knx.
I get the sunset time from the astro binding.

In my items I do have the following items

/*Licht*/ Switch Licht_BG_BV 	  "Wandlampen Buiten"   (BG_BV,gBU,gVE,gSC,Licht)	{knx="<0/0/62"}

Switch Sunset_Event    {astro="planet=sun, type=set, property=end"} 

The rule is as below

rule "Licht Voordeur aan"
when
 //      Item Sunset_Event received command ON
   Item Sunrise_Event received command ON
then
//       sendCommand(Wandlampen Buiten, ON)
    sendCommand(Licht_BG_BV, ON)
end

I see in de logs that the rule is loaded but does not fire the lights.
Most likely I have made a mistake somewhere.

Try changing the rule to:

“Item Sunrise_Event received update ON”

That is what I have, and it works. Also, make sure you set the proper lat/long for the astro binding in the main .cfg file. If you see entries in your log file showing startup of the astro binding with your lat/long, you’ll know it’s being loaded correctly.

P.S. In my items file, I added an “offset=30” to the astro binding’s Sunset_Event, you can do this too to adjust the actual time the event fires and lights turn on, until it’s actually a bit darker.

I have changed the rule as you (@Bartus) stated but it is not working.

  rule "Licht Voordeur aan"
when
//      Item Sunset_Event received command ON
Item Sunrise_Event received update ON
then
//       sendCommand(Wandlampen Buiten, ON)
    sendCommand(Licht_BG_BV, ON)
end

In the debug log I see:

- Scheduled job with name Sunset_Event at 2015-09-05 18:08:00

I have used an offset of 10 minutes. I know that the sunset time is not correct in my debug setting but that should not make a difference.

Nowhere in the debug log I see the rule being executed.
Also nowhere I see that the sunset is switched to on.
Any ideas?

Why are triggering on sunrise and not sunset?

Actually I do trigger on Sunset. First I tried to trigger on Sunrise but then found out that with an off-set it also should work with Sunset.
In the log was something written that job was cancelled because of time is in the past.

Your rule code above has your sunset item commented out and sunrise not commented out, so it’s confusing. What is the actual rule code that’s not triggering?

I have it working now! Yeah! :smiley:

The issue was because of the time difference with local time. So I was confused that the rule was not triggered. Now I changed the rule for item line for testing to :

Switch Sunset_Event    {astro="planet=sun, type=set, property=end, offset=-84"}

In the debug log I can see that the rule is triggered and the lights switch on.

Also the switching off works well.

I understand that it is confusing. Now it is working I will strip it down.

Thanks for your help.

Have you seen any astro binding entries in your debug log, at startup? You
should see at least one, with your lat long…

Yes I do have the astro binding working. It was already working for a few weeks.
And I do see the entries in the debug log.

Excellent, glad you got it working!

All,

I have similar problems with triggering my rollershutters.
Sunrise works, but Sunset doesn’t:

What’s weird is that the Event is extremely short (events.log).

2016-01-06 16:17:00 - Weather_Sunset_Event state updated to ON
2016-01-06 16:17:00 - Weather_Sunset_Event state updated to OFF

So I guess the rule does not recognize the event:

rule "Night has broken"
when
    Item Weather_Sunset_Event received update ON
then
    sendTelegram("OH_TeleBot", "Rollladen:\nSunset Event triggered")
    Rollladen_Balkon.sendCommand(DOWN)
end

@NCO Can you post the items you have defined for the astro binding? Are you using a Switch item?

Hi @bartus,

Yes, I use a switch item:
Switch Weather_Sunrise_Event (G_Wetter) { astro=“planet=sun, type=rise, property=start” }

That looks OK to me - do you get any entries in the openhab.log when these fire? I would expect to see your “Rollladen:\nSunset Event triggered” entry. If so, you’re successfully entering the rule, and your problem may be with the actual Rollershutter command.

Actually, @NCO, I’m not sure if this may be your problem or not, but try changing the command line to:

sendCommand(Rollladen_Balkon, DOWN)

and see if that changes anything.

Finally, make sure you use the property=end for the Sunset event (not start)!

The rollershutter works fine, when manually triggered (separate debug trigger switch item).
So I think it’s the very short duration of the Sunset_Event (in the log it switches OFF again in the same second).
It would be great if I could set the duration of the Sunset_event to let’s say 10 seconds.
So an additional “duration” parameter would be helpful.

Do you use this event? is it also just less than a second log active?

Anyway - I will try your suggestions!
Thanks.

@NCO - Yes, I use the astro binding to turn my outdoor lights on and off at sunset/sunrise. and I also see that my sunset event only lasts 1 second (even 0 seconds) in the events log. I think that is why you have to use the “end” property for your application, otherwise the event may not be long enough to allow the command to fire.

Hi @bartus,

Doesn’t end mean, that the switch is triggered when the sunset ends (sun is gone) instead of the sun starting to descent!? So the duration should be the same!?

It’s all explained in the wiki:

If you bind it to a Switch, a event is scheduled and the state of the 
Switch is updated to ''ON'', immediately followed by a ''OFF'' at the 
calculated time.

and

  // shows the sunset
DateTime Sunset_Time   "Sunset [%1$tH:%1$tM]"   {astro="planet=sun, type=set, property=end"}

I have a similar problem. My items:

Switch Night_start  {astro="planet=sun, type=night, property=start"}
Switch Night_end  {astro="planet=sun, type=night, property=end"}

events log:

2016-01-21 19:55:00 - Night_start state updated to ON
2016-01-21 19:55:00 - Night_start state updated to OFF
2016-01-22 19:56:00 - Night_start state updated to ON
2016-01-22 19:56:00 - Night_start state updated to OFF

I never see the “Night_end” events…