Hi,
Could I please get some fresh eyes to look at my heater rule. I have a problem where it turns on/off at the end of the hour, regardless of what minute I have set.
The snippet of my rule that I suspect has the issue is below. Further down is the entire rule.
if (((currenthour > (LivingRoomHeaters1OnHour.state as DecimalType)) && (currenthour < (LivingRoomHeaters1OffHour.state as DecimalType))) || //Turn on if the current hour is between the start and stop hour. Ie: 9 and 10am. Minutes is irrelevant.
((currenthour == (LivingRoomHeaters1OnHour.state as DecimalType)) && (currentminute >= (LivingRoomHeaters1OnMinute.state as DecimalType))) || //If the hour is equal to the start hour, ie: 8, then check the minutes. If the current minute is equal to or more than the on minute, ie more or equal to 30, then turn on.
((currenthour == (LivingRoomHeaters1OffHour.state as DecimalType)) && (currentminute < (LivingRoomHeaters1OffMinute.state as DecimalType)))) //If the hour is equal to the end hour, ie: 11, then check the minutes. If the current minute is less than the off minute, ie less than 40, then turn on.
The above is ignoring the minutes.
If I set the heaters to turn on at 8:30, they’ll turn on at 9:00. If I set them to turn off at 4:30, they’ll turn off at 5:00. Can anyone see what’s wrong?
Schedule 1 is currently set as:
On time: 8:30am
Off time: 16:10
So, it should be off.
16:14:00.184 [INFO ] [runtime.busevents :22 ] - LivingRoomHeaters1Active received command ON
16:14:00.248 [INFO ] [runtime.busevents :22 ] - LivingRoomHeaters2Active received command OFF
16:14:00.391 [INFO ] [runtime.busevents :22 ] - LivingRoomHeaters3Active received command OFF
rule "Heating Check"
when
Time cron "00 * * ? * *" or
Item LivingRoomHeaters1Schedule changed or
Item LivingRoomHeaters2Schedule changed or
Item LivingRoomHeaters3Schedule changed or
Item LivingRoomHeatersManual changed
then
var int currenthour
var int currentminute
currenthour = now.getHourOfDay
currenthour = currenthour.intValue
currentminute now.getMinuteOfDay
currentminute = currentminute.intValue
var Number day = now.getDayOfWeek
// Process scheduler 1
if (LivingRoomHeaters1Schedule.state == ON) {
if (((currenthour > (LivingRoomHeaters1OnHour.state as DecimalType)) && (currenthour < (LivingRoomHeaters1OffHour.state as DecimalType))) ||
((currenthour == (LivingRoomHeaters1OnHour.state as DecimalType)) && (currentminute >= (LivingRoomHeaters1OnMinute.state as DecimalType))) ||
((currenthour == (LivingRoomHeaters1OffHour.state as DecimalType)) && (currentminute < (LivingRoomHeaters1OffMinute.state as DecimalType)))) {
if ((LivingRoomTemp.state as DecimalType) <= (LivingRoomHeaters1Threshold.state as DecimalType)) {
if (((day == 1) && (LivingRoomHeaters1Monday.state == ON)) ||
((day == 2) && (LivingRoomHeaters1Tuesday.state == ON)) ||
((day == 3) && (LivingRoomHeaters1Wednesday.state == ON)) ||
((day == 4) && (LivingRoomHeaters1Thursday.state == ON)) ||
((day == 5) && (LivingRoomHeaters1Friday.state == ON)) ||
((day == 6) && (LivingRoomHeaters1Saturday.state == ON)) ||
((day == 7) && (LivingRoomHeaters1Sunday.state == ON))) {
sendCommand(LivingRoomHeaters1Active,ON)
}
else {
sendCommand(LivingRoomHeaters1Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters1Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters1Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters1Active,OFF)
}
// Process scheduler 2
if (LivingRoomHeaters2Schedule.state == ON) {
if (((currenthour > (LivingRoomHeaters2OnHour.state as DecimalType)) && (currenthour < (LivingRoomHeaters2OffHour.state as DecimalType))) ||
((currenthour == (LivingRoomHeaters2OnHour.state as DecimalType)) && (currentminute >= (LivingRoomHeaters2OnMinute.state as DecimalType))) ||
((currenthour == (LivingRoomHeaters2OffHour.state as DecimalType)) && (currentminute < (LivingRoomHeaters2OffMinute.state as DecimalType)))) {
if ((LivingRoomTemp.state as DecimalType) <= (LivingRoomHeaters2Threshold.state as DecimalType)) {
if (((day == 1) && (LivingRoomHeaters2Monday.state == ON)) ||
((day == 2) && (LivingRoomHeaters2Tuesday.state == ON)) ||
((day == 3) && (LivingRoomHeaters2Wednesday.state == ON)) ||
((day == 4) && (LivingRoomHeaters2Thursday.state == ON)) ||
((day == 5) && (LivingRoomHeaters2Friday.state == ON)) ||
((day == 6) && (LivingRoomHeaters2Saturday.state == ON)) ||
((day == 7) && (LivingRoomHeaters2Sunday.state == ON))) {
sendCommand(LivingRoomHeaters2Active,ON)
}
else {
sendCommand(LivingRoomHeaters2Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters2Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters2Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters2Active,OFF)
}
// Process scheduler 3
if (LivingRoomHeaters3Schedule.state == ON) {
if (((currenthour > (LivingRoomHeaters3OnHour.state as DecimalType)) && (currenthour < (LivingRoomHeaters3OffHour.state as DecimalType))) ||
((currenthour == (LivingRoomHeaters3OnHour.state as DecimalType)) && (currentminute >= (LivingRoomHeaters3OnMinute.state as DecimalType))) ||
((currenthour == (LivingRoomHeaters3OffHour.state as DecimalType)) && (currentminute < (LivingRoomHeaters3OffMinute.state as DecimalType)))) {
if ((LivingRoomTemp.state as DecimalType) <= (LivingRoomHeaters3Threshold.state as DecimalType)) {
if (((day == 1) && (LivingRoomHeaters3Monday.state == ON)) ||
((day == 2) && (LivingRoomHeaters3Tuesday.state == ON)) ||
((day == 3) && (LivingRoomHeaters3Wednesday.state == ON)) ||
((day == 4) && (LivingRoomHeaters3Thursday.state == ON)) ||
((day == 5) && (LivingRoomHeaters3Friday.state == ON)) ||
((day == 6) && (LivingRoomHeaters3Saturday.state == ON)) ||
((day == 7) && (LivingRoomHeaters3Sunday.state == ON))) {
sendCommand(LivingRoomHeaters3Active,ON)
}
else {
sendCommand(LivingRoomHeaters3Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters3Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters3Active,OFF)
}
}
else {
sendCommand(LivingRoomHeaters3Active,OFF)
}
if (LivingRoomHeatersManual.state == OFF) {
if ((LivingRoomHeaters1Active.state == ON) || (LivingRoomHeaters2Active.state == ON) || (LivingRoomHeaters3Active.state == ON)) {
sendCommand(LivingRoomHeaters,ON)
}
else {
sendCommand(LivingRoomHeaters,OFF)
}
}
end
Switch LivingRoomHeaters {wemo="Socket-1_0-221516K110021F"}
Switch LivingRoomHeatersManual
Switch LivingRoomHeaters1Schedule
Switch LivingRoomHeaters1Active
Number LivingRoomHeaters1Threshold "Temperature Set [%d°C]" <temperature>
Number LivingRoomHeaters1OnHour "On Time - Hour [%d]" <clock>
Number LivingRoomHeaters1OnMinute "On Time - Minute [%d]" <clock>
Number LivingRoomHeaters1OffHour "Off Time - Hour [%d]" <clock>
Number LivingRoomHeaters1OffMinute "Off Time - Minute [%d]" <clock>
Switch LivingRoomHeaters1Monday "Monday" <switch>
Switch LivingRoomHeaters1Tuesday "Tuesday" <switch>
Switch LivingRoomHeaters1Wednesday "Wednesday" <switch>
Switch LivingRoomHeaters1Thursday "Thursday" <switch>
Switch LivingRoomHeaters1Friday "Friday" <switch>
Switch LivingRoomHeaters1Saturday "Saturday" <switch>
Switch LivingRoomHeaters1Sunday "Sunday" <switch>
Switch LivingRoomHeaters2Schedule
Switch LivingRoomHeaters2Active
Number LivingRoomHeaters2Threshold "Temperature Set [%d°C]" <temperature>
Number LivingRoomHeaters2OnHour "On Time - Hour [%d]" <clock>
Number LivingRoomHeaters2OnMinute "On Time - Minute [%d]" <clock>
Number LivingRoomHeaters2OffHour "Off Time - Hour [%d]" <clock>
Number LivingRoomHeaters2OffMinute "Off Time - Minute [%d]" <clock>
Switch LivingRoomHeaters2Monday "Monday" <switch>
Switch LivingRoomHeaters2Tuesday "Tuesday" <switch>
Switch LivingRoomHeaters2Wednesday "Wednesday" <switch>
Switch LivingRoomHeaters2Thursday "Thursday" <switch>
Switch LivingRoomHeaters2Friday "Friday" <switch>
Switch LivingRoomHeaters2Saturday "Saturday" <switch>
Switch LivingRoomHeaters2Sunday "Sunday" <switch>
Switch LivingRoomHeaters3Schedule
Switch LivingRoomHeaters3Active
Number LivingRoomHeaters3Threshold "Temperature Set [%d°C]" <temperature>
Number LivingRoomHeaters3OnHour "On Time - Hour [%d]" <clock>
Number LivingRoomHeaters3OnMinute "On Time - Minute [%d]" <clock>
Number LivingRoomHeaters3OffHour "Off Time - Hour [%d]" <clock>
Number LivingRoomHeaters3OffMinute "Off Time - Minute [%d]" <clock>
Switch LivingRoomHeaters3Monday "Monday" <switch>
Switch LivingRoomHeaters3Tuesday "Tuesday" <switch>
Switch LivingRoomHeaters3Wednesday "Wednesday" <switch>
Switch LivingRoomHeaters3Thursday "Thursday" <switch>
Switch LivingRoomHeaters3Friday "Friday" <switch>
Switch LivingRoomHeaters3Saturday "Saturday" <switch>
Switch LivingRoomHeaters3Sunday "Sunday" <switch>