Hi folks,
I’ve a rule that was working with OH2.5, but now I have some issues with OH3.1 It depends most probably on the new class ZonedDateTime.
I’m trying to trigger some automation depending on day/time.
I’ve tried with logs, in order to check what’s happening, but I can’t see anything (so there is a problem before the log :))
Any clue?
rule "A2A Energy Timeslot"
when
Time cron "0 0/1 * * * ?" or
//Time cron "0 0 0/1 1/1 * ? *" or
System started
then
if (((now.getDayOfWeek.getValue == 1) || (now.getDayOfWeek.getValue == 2) || (now.getDayOfWeek.getValue == 3) || (now.getDayOfWeek.getValue == 4) || (now.getDayOfWeek.getValue == 5)) && (LocalTime_Holiday.state == OFF)) {
val int thisHour = now.getHour()
val int thisMinute = now.getHour() * 60 + now.getMinute()
//val int thisHour = now.getHourOfDay
//val int thisMinute = now.getMinuteOfDay
logInfo("test", "thisHour=" + thisHour + " thisMinute=" + thisMinute)
switch thisHour {
case thisHour < 7: {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case thisHour == 7: {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case (thisHour > 7 && thisHour < 19): {
Auto_Energy_Timeslot.postUpdate(1)
Auto_AirConditioner.postUpdate(OFF)
Auto_Boiler.postUpdate(OFF)
}
case (thisHour >= 19 && thisHour < 21): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(OFF)
Auto_Boiler.postUpdate(OFF)
}
case (thisHour >= 21 && thisMinute < 21*60+30): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(OFF)
}
case (thisMinute >= 21*60+30 && thisHour < 23): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case thisHour >= 23: {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
}
}
else if ((now.getDayOfWeek.getValue == 6) && (LocalTime_Holiday.state == OFF)) {
//val int thisHour = now.getHourOfDay
//val int thisMinute = now.getMinuteOfDay
val int thisHour = now.getHour()
val int thisMinute = now.getHour() * 60 + now.getMinute()
switch thisHour {
case thisHour < 7: {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case (thisHour >= 7 && thisHour < 10): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case (thisHour >= 10 && thisHour < 21): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(OFF)
Auto_Boiler.postUpdate(OFF)
}
case (thisHour >= 21 && thisMinute < 21*60+30): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(OFF)
}
case (thisMinute >= 21*60+30 && thisHour < 23): {
Auto_Energy_Timeslot.postUpdate(2)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case thisHour >= 23: {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
}
}
else if ((now.getDayOfWeek.getValue == 7) || (LocalTime_Holiday.state == ON)) {
//val int thisHour = now.getHourOfDay
//val int thisMinute = now.getMinuteOfDay
val int thisHour = now.getHour()
val int thisMinute = now.getHour() * 60 + now.getMinute()
switch thisHour {
case thisHour < 10: {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
case (thisHour >= 10 && thisHour < 21): {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(OFF)
Auto_Boiler.postUpdate(OFF)
}
case (thisHour >= 21 && thisMinute < 21*60+30): {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(OFF)
}
case (thisMinute >= 21*60+30): {
Auto_Energy_Timeslot.postUpdate(3)
Auto_AirConditioner.postUpdate(ON)
Auto_Boiler.postUpdate(ON)
}
}
}
end
thanks for any suggestion
Andrea