Hello
I am a student and I am just starting to learn about opehab. I am having difficulty using openhab.
I’m using ntp bindings to display the time. I want to create a rule to turn on the light after 6pm. But I don’t know how to compare time. Can everyone help me?
demo.items:
DateTime CurrentDate “Date [% 1 $ tA,% 1 $ td.% 1 $ tm.% 1 $ tY% 1 $ tH:% 1 $ tM]” {channel = “ntp: ntp: demo: dateTime” }
Switch Light1 “Light” (Living)
Can you show me how to compare time in ntp bindings?
Thanks very much
That’s fine, you use a cron trigger for rule at your desired time.
The action to take after triggering, would be to send a command to your Item representing your light.
Hi Andrew_Rowe
I have read that article. But I want to compare the current time with a specific time of day (6 pm) but I do not know how to create a time variable to compare and convert Item CurrentDate into a variable that can be compared to other time points. Can you help me?
I have no idea what you are asking.
The cron statement in the example rule is a fairly common programmer’s way to show a particular time.
openHAB uses this cron format because that is what the openHAB designers chose for it to use.
That is the way we have to present the time if we want a rule to trigger at a given time, like 6pm. 6pm is hour 18 of the day.
The time/date it is referring to is the time/date of the system that your copy of openHAB is running on.
Your system does not care what timezone my system is operating in.
When your system thinks it is 6pm in your timezone, it will start the rule.