it would rather need to be something like this (beware, untested …) now.isAfter(now.withTimeAtStartOfDay.plusHours(6)) && now.isBefore(now.withTimeAtStartOfDay.plusHours(6).plusMinutes(30))
There’s many options but no definite or recommended one.
I’m actually using now.millis which is long type, that’s easier to work with particularly when you don’t want to code fixed times into your rules but want to use items (of Number type) instead and have the times changeable via GUI.
Docs: Something’s here, more if you google for Joda just as Udo just replied.
This is a very good point. In my case however it’s a Monday-Friday only situation (turning off my morning lights when I leave the house). I don’t ever work on Sunday so daylight saving on/off will not affect this rule.
I’m going to save the idea though - just in case I want to make another automation that might fire on Sunday.
Here’s another way to do it (I added in your day of week requirement too)…
when
Item AnyoneHome received command OFF
then
if ((1..5).contains(now.getDayOfWeek) && (new Interval(now.withTime(6,0,0,0),now.withTime(6,30,0,0)).contains(now))) {
Group11.sendCommand(OFF)
}
end
2020-12-22 14:59:37.820 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Activatie-2’ failed: ‘withTimeAtStartOfDay’ is not a member of ‘java.time.ZonedDateTime’; line 24, column 71, length 24 in Activatie
thx for the hint. I tried to change the rule above but i get an error or nothing happens, can you give me a hint how to? Because i cant wrap my head around it.
when
Time cron "0/20 * * 1/1 * ? *"
then
if((Dom_Nacht_Ems.state == ON || Timer_Lamp.state == OFF) &&
(now.getHour.isAfter(8) && now.getMinute.isAfter(59))){
sendCommand(Dom_Nacht_Ems, OFF)
sendCommand(Timer_Lamp, ON)
sendCommand(Kids_Slapen, OFF)
if((!Kinderkamer_Binary_Switch.changedSince(now.minusMinutes(10))) && Gem_perc_KidsRol.state != 0 && Gem_Buiten_Licht.state >= 10000){
if(Liam_Rolluik.state != 0){
sendCommand(Liam_Rolluik, 0)
}
if( Emily_Rolluik.state != 0) {
sendCommand(Emily_Rolluik, 0)
}
}
}
end```
this is the fault :
2020-12-23 17:44:00.945 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'KidsSlaap-1' failed: 'isAfter' is not a member of 'int'; line 12, column 10, length 22 in KidsSlaap
tried a lot of things but here i stopped...
thx for the ''' tip btw!
There is no such thing as a or “the” correct syntax. There’s many correct syntaxes and a gazillion possibilities. To select from these remains to be your task (and yours alone).
Check out this thread (there’s an OH3 one, too)