I am running OH3.1 on a synology docker and i do have troubles with rules and comparing times.
The rule code (DSL type) is seemingly simple and as follows:
So therefore i have installed the NTP-binding (local time) and the Astro Binding to get the time of sunset. Rule should say (excerpt):
If the sunset has already started, shut down all rollers.
Please see attached item information.
Maybe it’s because the item state/data is formatted differently?
Unfortunately, the Astro Event is not the trigger. The trigger is something else. The rule is like: WHEN event happens >> shut down all rollershutters>> but only if current time is later than sunset start
(= it is dark outside)
You could use an item that represents true/false or ON/OFF triggered by the astro binding and use this state to evaluate if it is dark outside.
Have a look at this thread ( How to get and use Astro sunrise and sunset via OH3 Javascript ) as far as I understand that should help.
Take care about Item types. That one is a String type, you will not be able to compare a collection of alphanumeric characters directly with a DateTime type representing a moment in time. At some point you need to convert stuff to the same type to do meaningful comparisons.
Also bear in mind an Item is a complex object, with icon, label, etc. properties. In a rule you are almost always interested in its state property.
Great input from both of you guys! Thanks for that
I took Wolfgang_S’ idea to create an item “Dunkelheit” (darkness) which is on state “1” once the sunset event has been triggered (and set to state “0” once sunrise fires).
I have not tested the script yet, but hopefully it will do it’s job