I am using the following rules and they produce the error. Please help
An error occurred during the script execution: index=1, size=1
rule "Calculate time of day state"
when
Time cron " 0 0/3 * 1/1 * ? *"
then
Thread::sleep(1000) // make sure we are a tad past midnight to give Astro a chance to recalculate DateTimes for today
val long day_start = (Sunrise_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
val long night_start = (Sunset_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
var curr = "UNKNOWN"
switch now {
case now.isAfter(day_start) && now.isBefore(night_start): curr = "Daytime"
case (now.isAfter(night_start) && now.isBefore(now.withTimeAtStartOfDay.plusHours(24))) ||
(now.isAfter(now.withTimeAtStartOfDay) && now.isBefore(day_start)): curr = "Night time"
}
if(TimeOfDay.state.toString != curr) {
logInfo("TimeofDay", "Current time of day is now " + curr)
TimeOfDay.sendCommand(curr)
}
if(Day.state == OFF && TimeOfDay.state.toString == "Daytime"){Day.sendCommand(ON)}
if(Day.state == ON && TimeOfDay.state.toString == "Night time"){Day.sendCommand(OFF)}
end
and
rule "Rec Room Lights On"
when
Item rrtrigger changed to ON
then
var LocalTime LocTime = new LocalTime(now)
if((LocTime.getLocalMillis()) >= (new LocalTime(7, 0, 0, 0).getLocalMillis()) &&
(LocTime.getLocalMillis()) <= (new LocalTime(7, 59, 59, 0).getLocalMillis())){
if(HueBulb14.state.toString != "41,38,50"){sendCommand(HueBulb14, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(50)))}
if(HueBulb15.state.toString != "41,38,50" && MBRAuto.state == ON){sendCommand(HueBulb15, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(50)))}
if(Light_scene_RR.state != 7){Light_scene_RR.sendCommand(7)}
sendCommand(Wifi5Ledrgbw, new HSBType(new DecimalType(200),new PercentType(20),new PercentType(2)))
}
else if((LocTime.getLocalMillis()) >= (new LocalTime(8, 0, 0, 0).getLocalMillis()) &&
(LocTime.getLocalMillis()) <= (new LocalTime(19, 29, 59, 0).getLocalMillis())){
if(HueBulb14.state.toString != "41,38,50"){sendCommand(HueBulb14, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(50)))}
if(HueBulb15.state.toString != "41,38,50" && MBRAuto.state == ON){sendCommand(HueBulb15, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(50)))}
if(Light_scene_RR.state != 7){Light_scene_RR.sendCommand(7)}
sendCommand(Wifi5Ledrgbw, new HSBType(new DecimalType(200),new PercentType(20),new PercentType(10)))
}
else if((LocTime.getLocalMillis()) >= (new LocalTime(19, 30, 0, 0).getLocalMillis()) &&
(LocTime.getLocalMillis()) <= (new LocalTime(20, 59, 59, 0).getLocalMillis())){
if(HueBulb14.state.toString != "41,38,25"){sendCommand(HueBulb14, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(25)))}
if(HueBulb15.state.toString != "41,38,0"){sendCommand(HueBulb15, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(0)))}
if(Light_scene_RR.state != 7){Light_scene_RR.sendCommand(7)}
sendCommand(Wifi5Ledrgbw, new HSBType(new DecimalType(200),new PercentType(20),new PercentType(2)))
}
else if((LocTime.getLocalMillis()) >= (new LocalTime(21, 0, 0, 0).getLocalMillis()) &&
(LocTime.getLocalMillis()) <= (new LocalTime(23, 59, 59, 0).getLocalMillis())){
if(Light_scene_RR.state != 1){Light_scene_RR.sendCommand(1)}
sendCommand(Wifi5Ledrgbw, new HSBType(new DecimalType(0),new PercentType(100),new PercentType(2)))
}
else if((LocTime.getLocalMillis()) >= (new LocalTime(0, 0, 0, 0).getLocalMillis()) &&
(LocTime.getLocalMillis()) <= (new LocalTime(6, 59, 59, 0).getLocalMillis())){
if(Light_scene_RR.state != 1){Light_scene_RR.sendCommand(1)}
sendCommand(Wifi5Ledrgbw, new HSBType(new DecimalType(0),new PercentType(100),new PercentType(2)))
}
if(WindowSwitch_Status21.state == CLOSED && HueBulb24.state.toString != "41,38,0"){sendCommand(HueBulb24, new HSBType(new DecimalType(41),new PercentType(38),new PercentType(0)))}
end