Following the example, I ended up with the config below.
I’m close to a working solution, I feel it. I think that my issues is linked somewhere with the if &&. When I drop the Heating_Mode.state part, it seems to works?
At the moment fe, my wanted temperature (Bureau_TargetTemp) is set to 15), and the real temperature (SCH_BURO1_TEMP) is 19.74. So only the airco part should be triggered.
But both parts are triggered as you can see below in the log.
Items:
Number SCH_BURO1_TEMP "Deur [%.2f C]" <temperature> (TEMP_ALL) { knx="3/2/0" }
Number Bureau_TargetTemp "Gewenste Temperatuur [%.1f °C]" <temperature>
String Heating_Mode "Globale HVAC Mode [%s]"
Part of my rule:
// =========================
rule "HVAC Bureel Activatie"
when
Item SCH_BURO1_TEMP changed
then
// Heating ON (NO since 16 < 19.74)
if ((((Bureau_TargetTemp.state as DecimalType)+1)>(SCH_BURO1_TEMP.state as DecimalType)) && (Heating_Mode.state == "Werk")) {
logInfo("HVAC_Bureel", "De temperatuur is lager dan gewenst [" + SCH_BURO1_TEMP.state + " < " + Bureau_TargetTemp.state as DecimalType +"]")
if (HVAC_BureelKoeling.lastUpdate.isBefore(now.minusHours(2))) HVAC_BureelVerwaming.sendCommand(ON)
logInfo("HVAC_Bureel", "De verwarming is opgezet")
}
else {
logInfo("HVAC_Bureel", "De temperatuur is lager dan gewenst [" + SCH_BURO1_TEMP.state + " < " + Bureau_TargetTemp.state as DecimalType +"]")
logInfo("HVAC_Bureel", "De Verwarming is niet aangezet omdat HVAC modus niet op werken staat.")
}
// Heating & Cooling OFF
if ((SCH_BURO1_TEMP.state as DecimalType)==(Bureau_TargetTemp.state as DecimalType)) {
logInfo("HVAC_Bureel", "Gewenste temperatuur is bereikt [" + SCH_BURO1_TEMP.state + " = " + Bureau_TargetTemp.state as DecimalType +"]")
sendCommand( HVAC_BureelVerwarming, OFF )
sendCommand( HVAC_BureelKoeling, OFF)
logInfo("HVAC_Bureel", "De verwarming & Airco zijn uitgezet")
}
// Cooling ON (YES since 20.74 < 15)
if ((((SCH_BURO1_TEMP.state as DecimalType)+1)>(Bureau_TargetTemp.state as DecimalType)) && (Heating_Mode.state == "Werk")) {
logInfo("HVAC_Bureel", "De temperatuur is hoger dan gewenst [" + SCH_BURO1_TEMP.state + " < " + Bureau_TargetTemp.state as DecimalType +"]")
logInfo("HVAC_Bureel", "De Airco is aangezet")
}
else {
logInfo("HVAC_Bureel", "De temperatuur is hoger dan gewenst [" + SCH_BURO1_TEMP.state + " > " + Bureau_TargetTemp.state as DecimalType +"]")
logInfo("HVAC_Bureel", "De Airco is niet aangezet omdat HVAC modus niet op werken staat.")
}
end
openhab.log
2018-03-11 16:10:09.775 [INFO ] [e.smarthome.model.script.HVAC_Bureel] - De temperatuur is lager dan gewenst [19.740000000000002 < 15.0]
2018-03-11 16:10:09.778 [INFO ] [e.smarthome.model.script.HVAC_Bureel] - De Verwarming is niet aangezet omdat HVAC modus niet op werken staat.
2018-03-11 16:10:09.788 [INFO ] [e.smarthome.model.script.HVAC_Bureel] - De temperatuur is hoger dan gewenst [19.740000000000002 > 15.0]
2018-03-11 16:10:09.792 [INFO ] [e.smarthome.model.script.HVAC_Bureel] - De Airco is niet aangezet omdat HVAC modus niet op werken staat.
Not sure that I understand this correctly.
Do you mean that without the parenthesis, it will always work if fe the state is not the correct value?
And with parenthesis, it will crash?