Hi There,
I’m fighting with one of my rules - again
In this case, I’m using a function for make the rule more readable. But the function isn’t executed completely.
val org.eclipse.xtext.xbase.lib.Functions$Function4 setHeaterOperatingModes = [
int HeaterModeMainComfortZoneValue,
int HeaterComfortZoneValue,
int HeaterOutbuildingsValue,
int HeaterManualZoneValue |
HeaterModeMainComfortZone?.members.forEach[element1,index1|
logInfo("Heating","Set State for MainComfortZone: " + HeaterModeMainComfortZoneValue)
if (element1.state != HeaterModeMainComfortZoneValue) {
logInfo("Heating","State for MainComfortZone was different from last state")
sendCommand(element1, HeaterModeMainComfortZoneValue)
}
]
HeaterComfortZone?.members.forEach[element1,index1|
logInfo("Heating","Set State for ComfortZone: " + HeaterComfortZoneValue)
if (element1.state != HeaterComfortZoneValue) {
logInfo("Heating","State for ComfortZone was different from last state")
sendCommand(element1, HeaterComfortZoneValue)
}
]
HeaterOutbuildings?.members.forEach[element1,index1|
if (element1.state != HeaterOutbuildingsValue) {
sendCommand(element1, HeaterOutbuildingsValue)
}
]
// At the moment there is only the office in the manual zone
if (Office_Operating_Mode_Manual.state == ON) {
if (Office_Operating_Mode.state != 1) {
sendCommand(Office_Operating_Mode, 1)
}
} else {
if (Office_Operating_Mode.state != HeaterManualZoneValue) {
sendCommand(Office_Operating_Mode, HeaterManualZoneValue)
}
}
]
The relevant parts are the first two blocks “Main Comfort Zone” and “Comfort Zone”.
The rule is looking like this:
// Heating at noon
rule "Heating Switch Operating Mode at noon"
when
Time cron "0 /5 9-17 * * ?"
then
if (I_am_on_vacation.state == ON) {
// Set all to freeze protection when on vacation
setHeaterOperatingModes.apply(4,4,4,4)
} else {
// 1 + 2 : Only heate on precense - reduce othervice
if (Heater_Mode.state == 1 || Heater_Mode.state == 2) {
sendCommand(Operating_Mode_Summer, OFF)
if (Heater_Presence.state == ON) {
setHeaterOperatingModes.apply(1,1,2,4)
} else {
setHeaterOperatingModes.apply(2,2,3,4)
}
}
}
end
When the rule is executed I’m getting the following log output:
2016-09-28 09:50:03.372 [INFO ] [g.openhab.model.script.Heating] - Set State for MainComfortZone: 1
2016-09-28 09:50:04.106 [INFO ] [g.openhab.model.script.Heating] - Set State for ComfortZone: 1
2016-09-28 09:50:04.135 [INFO ] [g.openhab.model.script.Heating] - State for ComfortZone was different from last state
BUT: The Value for the Comfort Zone isn’t set - so obviously “sendCommand(element1, HeaterComfortZoneValue)” isn’t executed and I have no Idea why
Any Idea what wen’t wrong?
Bests
Chris
P.S.: One interesting thing, which might be a bug - When I add a log message with an error in it (Not on purpose), the function stops executing at the point of the log message but without logging an error message.