rule "Civil Dusk Has Occured"
when
Channel 'astro:sun:local:civilDusk#event' triggered START
then
FrontPorchLight_Switch.sendCommand(ON)
BackYardLedgeLights_Dimmer.sendCommand(20)
end
rule "Sun Rise Has Occured"
when
Channel 'astro:sun:local:rise#event' triggered START
then
FrontPorchLight_Switch.sendCommand(OFF)
end
I migrated these Rules over from OH2 and they won’t fire.
The Astro binding seems to work fine as I can link Items to its Channels and they do update okay. There is one exception though the Trigger type channels won’t link. I get the error, “There is no profile available for the selected item”.
I realize I can now use UI rules but all my other rules are text based and I’d like to keep them all together for now. I am however going to try a UI built rule tonight to see if it fires.
I am trying to turn some lights on at civil dusk and turn one light off at sun rise. These rules worked for months with no issues in OH2. I copied the .rules file exactly as-is to OH3 and it stopped working.
I’m not sure what you mean by, “This is not related to rule event triggers.” Isn’t, “Channel ‘astro:sun:local:rise#event’ triggered START” an event that I can use in the When clause of a rule?
These are all the events over the past couple of days that contain “astro”. Odd that there are no Dusk events?
which has nothing to do with rule triggers. So I was curious what you were trying to do, when seeing this message.
There’s one of your rule triggers, looks good. Confident that your rule did not run, perhaps when you did not expect it? This ‘sunrise’ is after two in the afternoon.
May we know your latitude? Not all events appear in all parts of the world all the year round.
Having said that, there are sunrises but no sunsets, which makes no sense. It might be because your timezone is so weirdly offset, with a sunrise in the afternoon so the corresponding sunset would be the next date.
You probably ought to fix your timezone or location.
I don’t suppose your sunrise is at half past two in the afternoon though. The more I think on it, the more likely Astro is to mess up if the location/timezone combination gives “sun rise after sun noon”
Yes, I think that was it. I had set the time zone in the OpenHab UI but not in the Linux OS, it was still set to its default which I assume would be GMT. I have now set the OS time zone to what it should be, MDT (GMT-6:00), I also enabled the local NTP client.
Night:
12:00 am - 4:25 am
10:50 pm - 12:00 am
Astronomical Twilight:
4:25 am - 5:15 am
9:59 pm - 10:50 pm
Nautical Twilight:
5:15 am - 6:00 am
9:15 pm - 9:59 pm
Civil Twilight:
6:00 am - 6:36 am
8:40 pm - 9:15 pm
Daylight:
6:36 am - 8:40 pm
Solar Noon/Midnight:
1:38 PM
1:38 AM
They look good now, they are a little out but I think that is because of the update interval being 300 seconds.
Shouldn’t changing the time zone in the OpenHab UI also change the OS time zone? There is this note on the UI Settings page, " A time zone can be set from the user interface. The underlying system’s time zone is the default.". Does that mean one should not be setting the OS time zone?
Also there doesn’t not appear to be any provision for daylight savings adjustments in the UI.
Regardless, it’s working now. Thanks very much for everyone’s help!
OH does not have permission to change the OS time zone. It’d need to run as root and it would also have to know how to do that for all the OS’s it runs on which is more than just Linux.
No but it does mean that if you don’t set a timezone in the UI, the OS’s timezone will be what OH uses.
Daylight savings is handled by choosing the city/location that is closest to you in your timezone. So for me I’d choose America/Denver which observes daylight savings. Someone from Arizona would choose America/Phoenix or US/Arizona which does not observe daylight savings.
You can also fix it by choosing something like GMT-6 and it will stay GMT-6 no matter what daylight savings is doing in your area.
Both the OS and openHAB offer these options for setting the time zone.
Daylight savings is a travesty and needs to end. US states and Canadian provinces in the Pacific Time Zone are considering not changing time twice a year.
What annoys me is that we’re probably going to change permanently to Daylight Savings Time, and not to Standard Time. Why? Because when they took polls, people said “I would rather have DST so that there’s more sun in the evenings during summer”. Oh will those people regret when winter comes and it’s still dark out at 8:00am.
Is this correct to turn on a virtual switch at Sunset?
rule "Sunset started"
when
Channel 'astro:sun:local:civilDusk#event' triggered START
then
logInfo("time-of-day.rules", "Its Sunset")
vDaylight.sendCommand(OFF)
end
Minor Detail: sunset and civil dusk are slightly different times. The Astro binding handles both of those so if you really mean SUNSET then you’ll want to change the trigger channel to reflect that. The difference is minimal, but you can see a brief review here if you need some precision.
Bigger Detail: Your basic rule structure is fine, but you’re sending an OFF command instead of ON.
If you look in your events.log, you should find exactly that event. Check carefully, this is all case- and spelling-sensitive. Not everyone’s sun Thing is called “local” for an example.