[SOLVED] Changing Heatingmode on Presence

Hey there,
im trying to change the mode of my AVM 301 heating radiator when I arrive at home, depending on the temperatur there is.
I dont get, why openHAB always sends the BOOST command, even if COMFORT would be enough.

  • Platform information:
    • Hardware: rPi 3B

    • OS: Raspbian Buster

    • Java Runtime Environment: OpenJDK Runtime Environment (Zulu8.40.0.178-CA-linux_aarch32hf) (build 1.8.0_222-b178)

    • openHAB version: 2.5.0 M5

rule "Anwesenheit"
when
    Item Presence changed to ON
then
    val TempIst = TempWZ.state as Number
    val TempSoll = WZHeizungComfortTemp.state as Number
    val diff = TempSoll - TempIst
    if(diff>= 5)
        {
            if(WZHeizungRadiatorMode.state != "BOOST") WZHeizungRadiatorMode.sendCommand("BOOST")
        }else{
            if(WZHeizungRadiatorMode.state != "COMFORT") WZHeizungRadiatorMode.sendCommand("COMFORT")
        }
end

My Items:

Group:Switch:OR(ON,OFF)     Presence      (Virtual)

String WZHeizungRadiatorMode   "Radiator mode" (WZHeizung) {channel="avmfritz:FRITZ_DECT_301:192_168_178_1:xxxxxxxxxxxxx:radiator_mode"}

Group:Number:AVG TempWZ (Temperatures)
Number:Temperature WZHeizungComfortTemp "Comfort temperature" (WZHeizung) {channel="avmfritz:FRITZ_DECT_301:192_168_178_1:xxxxxxxxxxxxxxx:comfort_temp"}

Any hint is appreciated.

Greetings from Germany

Because this line of code says if not (!= Boost) on Boost then set to Boost.

But this line should just be executed if

if(diff>= 5)

is true. But even if this should be false, the true block is executed, instead of the false block.
At least that was my idea

Try this and change diff value to what works best for you.

rule "Anwesenheit"
when
    Item Presence changed to ON
then
    var TempIst = TempWZ.state as Number
    var TempSoll = WZHeizungComfortTemp.state as Number
    val diff = TempSoll - TempIst
    if(diff>= 5)
        {
            if(WZHeizungRadiatorMode.state != "BOOST") WZHeizungRadiatorMode.sendCommand("BOOST")
        }else if (diff>= 2){
            if(WZHeizungRadiatorMode.state != "COMFORT") WZHeizungRadiatorMode.sendCommand("COMFORT")
        }
end

It would probably help to log out what diff actually is, to compare with what you are hoping it is.
logInfo("myTest", "variable diff is " + diff.toString)

I think you may get a surprise because TempWZ state is a simple Number but WZHeizungComfortTemp is a Number:Temperature with units.

You are right. Thanks for the hint.

2019-12-10 20:53:03.792 [INFO ] [clipse.smarthome.model.script.myTest] - variable diff is 273.45
2019-12-10 20:53:03.800 [INFO ] [clipse.smarthome.model.script.myTest] - variable Ist is 21.7
2019-12-10 20:53:03.807 [INFO ] [clipse.smarthome.model.script.myTest] - variable Soll is 22.0 °C

Is there any way to change the group “TempWZ” to a group of temperatures? Every member of the group is a Number:Temperature.

Never tried it myself, I don’t see why not.

You can reconcile numbers with and without units in your rule, but I agree that if all your sensors are with units, make the Group so as well.

1 Like
Group:Number:Temperature:AVG TempWZ (Temperatures)

This seems to work.

2019-12-10 21:46:57.296 [INFO ] [clipse.smarthome.model.script.myTest] - variable diff is 0.70
2019-12-10 21:46:57.304 [INFO ] [clipse.smarthome.model.script.myTest] - variable Ist is 21.3 °C
2019-12-10 21:46:57.309 [INFO ] [clipse.smarthome.model.script.myTest] - variable Soll is 22.0 °C

Thank you, @rossko57!