[SOLVED] How do you make a rule run between a certain time

hi everyone i have a socket that i want to turn on and off if an xbox is online or offline
all good i only want this rule to run between certain times between 7am & 7pm

rule "rule name"
when
Item TylerSXboxOnline_Online changed from OFF to ON
then
  PLUG6TylerSTV_Switch.sendCommand("ON")
end

should i use a cron timer this doesn’t seem right too me

if (now.getMinuteOfDay > 420 && now.getMinuteOfDay < 1140) {}
1 Like

i will try now thanks for that how did you do the math for the 1140 part

i get that the 420 part is 7 hours past 12AM and thats 420 mins

7 PM is 19 hours * 60 minutes

1 Like

thanks again yes thats simple now i think about it

i have just tested my rule its working fine thanks for that i will test again after 7 to confirm the rule is fully working

1 Like

If you only want to ceck the hour you an use instead

now.getHourOfDay()
2 Likes

thanks for that