Hello again. I try to refactor my rule and get rid of all sleeps … here is my new rule:
var Timer timer1 = null
var Timer timer2 = null
var Number tmcount
val theArray5 = newArrayList(49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 55, 55, 55, 55, 55, 55, 55, 60, 60, 60, 60, 60, 60, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 71, 71, 71, 71, 71, 71)
val theArray6 = newArrayList(80, 80, 80, 80, 75, 75, 75, 75, 70, 70, 60, 60, 60, 50, 50, 50, 40, 40, 40, 40, 35, 35, 35, 35, 35, 35, 35, 31, 31, 31, 34, 34, 34, 34, 21, 21, 21, 21, 15, 15, 15, 15, 15, 15, 15, 15, 21, 21, 21, 21)
val theArray1 = newArrayList(40, 40, 50, 50, 60, 60, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 49, 49, 49, 49, 49, 49, 54, 54, 54, 55, 55, 55, 60, 60, 60, 60, 60, 60, 60, 82, 82, 82)
val theArray2 = newArrayList(100, 100, 100, 100, 100, 100, 78, 78, 78, 78, 78, 78, 78, 78, 70, 70, 70, 70, 70, 70, 58, 58, 58, 58, 58, 58, 46, 46, 46, 46, 46, 46, 32, 32, 32, 32, 32, 32, 22, 22, 22, 22, 22, 22, 15, 15, 15, 15, 15, 15, 15, 26, 26, 26)
rule "Restarting"
when
System started
then
createTimer(now.plusSeconds(3)) [|
if(prepare.state == ON){
createTimer(now.plusSeconds(2)) [| prepare.sendCommand(OFF) ]
createTimer(now.plusSeconds(7)) [| set.sendCommand(OFF) ]
createTimer(now.plusSeconds(14)) [| stage1.sendCommand(stage2.state as Number) ]
createTimer(now.plusSeconds(19)) [| prepare.sendCommand(ON) ]
}
]
end
rule "pause"
when
Item pause received command ON
then
Heater.sendCommand(OFF)
SprinklerSystemSchedule.sendCommand("OFF")
createTimer(now.plusSeconds(1)) [| Vent.sendCommand(OFF) ]
createTimer(now.plusSeconds(2)) [| Fan.sendCommand(OFF) ]
createTimer(now.plusSeconds(3)) [| Spray.sendCommand(OFF) ]
end
rule "resume"
when
Item pause received command OFF
then
if(Fan.state != ON) Fan.sendCommand(ON)
end
rule "preparng"
when
Item prepare received command ON
then
start.sendCommand("ON")
tmcount = stage1.state as Number
stage2.sendCommand(tmcount)
Fan.sendCommand(ON)
pause.sendCommand("OFF")
end
rule "starting1"
when
Item rush175 received command ON or
Item tooska3 received command ON
then
prepare.sendCommand(ON)
end
rule "stadfsing1"
when
Item rush175 received command OFF or
Item tooska3 received command OFF
then
prepare.sendCommand(OFF)
end
rule "tmcounting"
when
Time cron "0 0/3 * 1/1 * ? *"
then
if(start.state == ON && pause.state == OFF) {
tmcount = tmcount + 1
stage2.sendCommand(tmcount)
}
end
rule "drye223m2dity"
when
Item h1 received update or
Item h2 received update
then
if(start.state == ON && pause.state == OFF) {
if(Fan.state != ON) Fan.sendCommand(ON)
if(((h1.state as DecimalType) > (goalhumidity.state as DecimalType)+8) || ((h2.state as DecimalType) > (goalhumidity.state as DecimalType)+8)) {
if(SprinklerSystemSchedule.state != OFF) SprinklerSystemSchedule.sendCommand(OFF)
if(Vent.state != ON) Vent.sendCommand(ON)
if(Spray.state != OFF) Spray.sendCommand(OFF)
} else if(((h1.state as DecimalType) < (goalhumidity.state as DecimalType)) && ((h2.state as DecimalType) < (goalhumidity.state as DecimalType))) {
if(Spray.state != ON) Spray.sendCommand(ON)
if(Vent.state != OFF) Vent.sendCommand(OFF)
}
}
end
rule "1msde3din"
when
Item t1 received update or
Item t2 received update or
Item t3 received update
then
if(start.state == ON && pause.state == OFF) {
if(((t1.state as DecimalType) > (goaltemp.state as DecimalType)) || ((t2.state as DecimalType) > (goaltemp.state as DecimalType)) || ((t3.state as DecimalType) > (goaltemp.state as DecimalType))) {
if(Heater.state != OFF) Heater.sendCommand(OFF)
} else if(((t1.state as DecimalType) < (goaltemp.state as DecimalType)-2) && ((t2.state as DecimalType) < (goaltemp.state as DecimalType)-2) && ((t3.state as DecimalType) < (goaltemp.state as DecimalType)-2)) {
if(Heater.state != ON) Heater.sendCommand(ON)
}
}
end
rule "egr2sh"
when
Item stage2 received update
then
if(rush175.state == ON) {
goalhumidity.sendCommand(theArray2.get((stage2.state as Number).intValue))
goaltemp.sendCommand(theArray1.get((stage2.state as Number).intValue))
}
if(tooska3.state == ON) {
goalhumidity.sendCommand(theArray6.get((stage2.state as Number).intValue))
goaltemp.sendCommand(theArray5.get((stage2.state as Number).intValue))
}
if((stage2.state as Number) > 48 && rush175.state == ON) {
rush175.sendCommand("OFF")
}
if((stage2.state as Number) > 51 && tooska3.state == ON) {
tooska3.sendCommand("OFF")
}
end
rule "stop1"
when
Item prepare received command OFF
then
start.sendCommand("OFF")
end
rule "st33op"
when
Item start received command OFF
then
Heater.sendCommand(OFF)
createTimer(now.plusSeconds(1)) [| Vent.sendCommand(OFF) ]
createTimer(now.plusSeconds(2)) [| Fan.sendCommand(OFF) ]
createTimer(now.plusSeconds(3)) [|
if(SprinklerSystemSchedule.state != OFF) SprinklerSystemSchedule.sendCommand(OFF)
]
createTimer(now.plusSeconds(4)) [| Spray.sendCommand(OFF) ]
end
rule "checkrelay"
when
Time cron "0 0/3 * 1/1 * ? *"
then
Heater.sendCommand(Heater.state.toString)
Vent.sendCommand(Vent.state.toString)
Fan.sendCommand(Fan.state.toString)
Spray.sendCommand(Spray.state.toString)
end
rule "Stagdeset"
when
Item set received command ON
then
stage1.sendCommand(tm.state as Number)
end
rule "spra2ycycle1"
when
Time cron "0 0/8 * 1/1 * ? *"
then
if(SprinklerSystemSchedule.state == ON) {
Spray.sendCommand(ON)
timer1?.cancel
timer1 = createTimer(now.plusSeconds(10)) [|
Spray.sendCommand(OFF)
timer1 = null
]
}
end
rule "da3251wf"
when
Item t1 received update or
Item t2 received update or
Item t3 received update
then
if(t1.state as DecimalType > goaltemp.state as DecimalType + 20 || t2.state as DecimalType > goaltemp.state as DecimalType + 20 || t3.state as DecimalType > goaltemp.state as DecimalType + 20) {
if(Heater.state != OFF) Heater.sendCommand(OFF)
}
end
I enabled the logs.
the “egr2sh” rule, executed at first. than I reboot the Rpi and suddenly goaltemp and goal humidity don’t update which exist in this rule. after one or two reboot, goaltemp changes but no changes in goalhumidity, I guess this is random.
here are my logs:
2024-07-15 14:00:45.189 [vent.ItemStateChangedEvent] - set changed from OFF to ON
2024-07-15 14:00:45.196 [vent.ItemStateChangedEvent] - stage1 changed from 12 to 8
2024-07-15 14:00:48.083 [ome.event.ItemCommandEvent] - Item 'tooska3' received command ON
2024-07-15 14:00:48.095 [ome.event.ItemCommandEvent] - Item 'prepare' received command ON
2024-07-15 14:00:48.098 [vent.ItemStateChangedEvent] - tooska3 changed from OFF to ON
2024-07-15 14:00:48.109 [ome.event.ItemCommandEvent] - Item 'start' received command ON
2024-07-15 14:00:48.113 [vent.ItemStateChangedEvent] - prepare changed from OFF to ON
2024-07-15 14:00:48.119 [ome.event.ItemCommandEvent] - Item 'stage2' received command 8
2024-07-15 14:00:48.140 [ome.event.ItemCommandEvent] - Item 'Fan' received command ON
2024-07-15 14:00:48.146 [ome.event.ItemCommandEvent] - Item 'pause' received command OFF
2024-07-15 14:00:48.152 [vent.ItemStateChangedEvent] - start changed from OFF to ON
2024-07-15 14:00:48.156 [nt.ItemStatePredictedEvent] - Fan predicted to become ON
2024-07-15 14:00:48.185 [vent.ItemStateChangedEvent] - stage2 changed from 12 to 8
2024-07-15 14:00:48.200 [ome.event.ItemCommandEvent] - Item 'Fan' received command ON
2024-07-15 14:00:48.204 [vent.ItemStateChangedEvent] - Fan changed from OFF to ON
2024-07-15 14:00:48.207 [nt.ItemStatePredictedEvent] - Fan predicted to become ON
2024-07-15 14:00:57.899 [ome.event.ItemCommandEvent] - Item 'tooska3' received command OFF
as you can see after stage2 got its new value goaltemp and goalhumidity don’t update
one time it updates:
as you see it only goaltemp.
is there any possibility that a problem exist in this part:
goalhumidity.sendCommand(theArray2.get((stage2.state as Number).intValue))
goaltemp.sendCommand(theArray1.get((stage2.state as Number).intValue))
by the way, the easy solution for fixing this problem is to change array numbers, for example if I change array1 and 2 to 5 and 6 and reset the openhab. it works for a while unless power outage happens then it may come back.
thanks