Rule Timings

Hi all,

I have a rule:

rule "Turn Sidelight On_LUX"

when
Item WeatherUV2 changed
then
var CurrentHour = now.getHourOfDay

if (CurrentHour <7 || CurrentHour >15){
if (GroundLights.state == OFF && WeatherUV2.state < 100){
GroundLights.sendCommand(ON)
sendBroadcastNotification(“Side Lights ON”)
}
}
end

I want to trigger the rule at 14:30 instead of 15:00, can i just use 14.5?

Cheers

The first if statement in your rule is true when the time is before 7am (now.getHourOfDay < 7) or after 4pm (now.getHourOfDay > 15). Using 14.5 would make the latter time an hour earlier (3pm), since now.getHourOfDay returns an integer. So, remove the CurrentHour variable and compare times…

if (now.isBefore(now.withTime(7, 0, 0, 0) || now.isAfter(now.withTime(16, 30, 0, 0)) {
1 Like

You could use a cron rule for a specific time.