NTP Bindings-rules

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

1 Like

You don’t. This is something for rules to do.

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.

general rules beginnings

time based rules triggers

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?

Hi rossko57
I have read about rules in openhab but I don’t understand epoch. How was it created? Have you done this part, can I show you an example?

There is no time comparison required at all to perform the task that you asked for.

Example to turn on light at 6pm

rule "my Cron rule"
when
	Time cron "0 0 1 18 * ? *"  // rule runs once at 6pm every day
then
         myLightItem.sendCommand(ON)
end

Thank you
Can you tell me how to convert the time to “0 0 1 18 *? *”?

What is the timeline in Rules? Can you answer me? Because my time and you are different, do I have to change anything?

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.

Hi rossko57
I understand what you said. Thank you very much