Sunrise / Sunset Help

All, I looked through a few searches in the forum and I think I have my programming correct however my sunrise / sunset did not trigger.
Items:
DateTime Sunrise_Time “Sunrise [%1$tH:%1$tM]” { channel = “astro:sun:home:rise#start” }

DateTime Sunset_Time “Sunset [%1$tH:%1$tM]” { channel = “astro:sun:home:set#start” }

Rule:
rule “Sunrise Rule - Outside Lights”

when

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

then

Light_GF_Front_Outside.sendCommand(OFF)

Light_GF_Deck_Outside.sendCommand(OFF)

end

rule “Sunset Rule - Outside Lights”

when

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

then

Light_GF_Front_Outside.sendCommand(ON)

Light_GF_Deck_Outside.sendCommand(ON)

end

Any idea’s ?, I tried to look in my log however for some reason it doesn’t go back to yesterday or even this morning (only shows a few hours) when it should have triggered, any idea on that as well ?.

Happy New Year!

astro:sun:home:set#start

Depending on how it’s been setup you might want

astro:sun:local:set#start

local instead of home.

1 Like

Whichever way, it needs to match the astro Thing name.

You need the event channel:
Channel 'astro:sun:home:set#event' triggered START

1 Like

That is another way to do it. Either should work.

1 Like

Thanks, all confirmed that it is home (Thing as per paperUI) and changed to…

rule “Sunset Rule - Outside Lights”

when

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

then

Light_GF_Front_Outside.sendCommand(ON)

Light_GF_Deck_Outside.sendCommand(ON)

end

As for the log, I think it only fills in data when the screen is open, is there any way to get the past history (haven’t searched this yet so I may end up finding it).

Thanks

Did this change recently? I did not find anything in the docs, unfortunately.
As this is asked very often it is important :slight_smile:
From what I know from the past: the start and end triggers are for displaying the astro time, for example on the sitemap and the event is the channel trigger.
I did a quick test and only the event channel got triggered:

rule "test astro channel trigger event"
when
    Channel 'astro:sun:wss3:set#event' triggered START
then
  	logInfo("EXTRA", "Test astro event set channel")	    
end

rule "test astro channel trigger start"
when
    Channel 'astro:sun:wss3:set#start' triggered START
then
  	logInfo("EXTRA", "Test astro start set  channel")	    
end

The log:

2021-01-02 16:20:00.141 [INFO ] [org.openhab.core.model.script.EXTRA ] - Test astro event set channel
2021-01-03 16:21:00.007 [INFO ] [org.openhab.core.model.script.EXTRA ] - Test astro event set channel

I have always used #start personally on OH2. (2.5.2, I think)

1 Like

All thoughts on how to keep a light on if it’s dark (between civil dusk and civil dawn), for instance if someone manually turns the light off it automatically comes back on

If the light sends a state change saying it was turned off, a rule could be triggered to turn it back on during that time window.

Bruce, exactly except I am having trouble with the code more specifically the “in between times”

What I did is set up a virtual switch I call “IsItDark”. i use astro rules to turn the switch on when it is dark & off otherwise. If on a site map you can also enable the switch manually for testing your rules.

The other rules just need to check the status if that switch to know if it is dark. I got the idea from this forum years ago.
Item

Switch IsItDark <moon>

Rules

rule "Sunset"
when
    Channel 'astro:sun:local:civilDusk#event' triggered START
then
    IsItDark.postUpdate(ON)
end

rule "Sunrise"
when
    Channel 'astro:sun:local:civilDawn#event' triggered START
then
    IsItDark.postUpdate(OFF)
end

Now I am confused: I thought your were not triggering on the event channel?

I was confused.

I use the start times for visual Items showing the times.

Now I am back on track :grinning:

1 Like

Finally got around to this and I have it working to the point where if it’s dark it comes on (thank you for the tip about adding a switch for testing, this was helpful). How do I get the lights to come back on should someone turn it off and it’s still dark

Rule:

rule “keep outside lights on if dark”
when
Item IsItDark received update
then
if (Light_GF_Front_Outside.state == OFF)
Light_GF_Front_Outside.sendCommand(ON)
end

Intercept the state-change event from your device with a rule to turn it back on. Some devices may have a way of disabling local control.

So I gave this a try and it did not seem to work

rule “Keep lights on at night”

when

Item Light_GF_Front_Outside changed from ON to OFF

then

if (IsItDark == ON){

    Light_GF_Front_Outside.sendCommand(ON)

}

end

Try

IsItDark.state == ON
1 Like

Excellent, thank you very much. Can you explain why this made the difference so I learn from this.