[SOLVED] Rule change TADO Mapping when window opens

Hi guys!

I’e been reading a lot on this forum to get my system up and running the way I like it and I’m nog digging into rules. I’ve been able to write a couple of simple rules using the design patterns found on this page and they work fine.

I’m now trying to change the state of our Tado heating system whenever a window opens, whowever I get stuck using the correct syntax to advance. I’ve been able to change the Tado from Schedule to Timer by setting the setpoint temperature to 5 degrees whenever a window opens but that’s not what I try to achieve. I would like to switch the operation mode to MANUAL whenever a window is opened and set it back to SCHEDULE when it closes.

ITEMS:

//Tado Thermostat Living Room
Number:Temperature  HEAT_inside_temperature    "Living Room Temperature" (Livingroom, Temperatures) { channel="tado:zone:8671c7f6:1:currentTemperature" }
Number              HEAT_humidity              "Living Room Humidity" (Livingroom, Temperatures) { channel="tado:zone:8671c7f6:1:humidity" }
Number              HEAT_heating_power         "Heating Power" (Livingroom) { channel="tado:zone:8671c7f6:1:heatingPower" }
String              HEAT_hvac_mode             "HVAC Mode" (Livingroom) { channel="tado:zone:8671c7f6:1:hvacMode" }
Number:Temperature  HEAT_target_temperature    "Target Temperature" (Livingroom, Temperatures) { channel="tado:zone:8671c7f6:1:targetTemperature" }
DateTime            HEAT_overlay_expiry        "Setting Expiry" (Livingroom) { channel="tado:zone:8671c7f6:1:overlayExpiry" }
Number              HEAT_timer_duration        "Timer Duration" (Livingroom) { channel="tado:zone:8671c7f6:1:timerDuration" }
String              HEAT_operation_mode        "Operation Mode" (Livingroom) { channel="tado:zone:8671c7f6:1:operationMode" }

SITEMAP:

Text label="Heating Controls" icon="settings" {

        Text      item=HEAT_inside_temperature icon="temperature"
        Text      item=HEAT_humidity icon="humidity"
        Text      item=HEAT_heating_power

        Setpoint  item=HEAT_target_temperature  minValue=5 maxValue=25
        Selection item=HEAT_hvac_mode           mappings=[OFF=off, HEAT=on]
        Selection item=HEAT_operation_mode      mappings=[SCHEDULE=schedule, MANUAL=manual, UNTIL_CHANGE="until change", TIMER=timer]
        Setpoint  item=HEAT_timer_duration      minValue=5 maxValue=60 step=1
        Text      item=HEAT_overlay_expiry      icon="none"
        }

RULES:

rule "Turn off heating when window is opened"
when
    Item LeftStudioWindow_OpenStatus changed
then
    if (LeftStudioWindow_OpenStatus.state == OPEN) {
        HEAT_target_temperature.sendCommand(5)
    } 
end

rule "Turn off heating when window is closed"
when
    Item LeftStudioWindow_OpenStatus changed
then
    if (LeftStudioWindow_OpenStatus.state == CLOSED) {
        HEAT_operation_mode ???
    } 
end

LOG:

thome.event.ItemStateChangedEvent] - HEAT_target_temperature changed from 5.0 °C to 21.0 °C
08:48:03.639 [INFO ] [smarthome.event.ItemStateChangedEvent] - LeftStudioWindow_OpenStatus changed from CLOSED to OPEN
08:48:03.673 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'HEAT_target_temperature' received command 5
08:48:03.675 [INFO ] [arthome.event.ItemStatePredictedEvent] - HEAT_target_temperature predicted to become 5
08:48:03.681 [INFO ] [smarthome.event.ItemStateChangedEvent] - HEAT_target_temperature changed from 21.0 °C to 5.0 °C

As you can see if I use the HEAT_target_temperature.sendCommand(5) I’m able to set the temperature but instead I would like to use the mappings of the HEAT_operation_mode instead found in the sitemap. Can somebody help on this?

Thanks!

Hello,
As I understand it when using the operationMode channel you cant actually change the temperature the heating is set too. You will have to use either the targetTemperature channel or the hvacMode one. For a window open rule you could use the hvacMode instead of setting a low target temperature and just turn the heating off. So the operationMode channel will only work on its own for returning to schedule otherwise its probably best used in conjunction with either the targetTemperature and optionally the timerDuration.
You could also get fancy and use a dummy item:

String Hvacandoperation

and a rule:

rule "Combination"
when
    Item Hvacandoperation received update
then
    var String Command = Hvacandoperation.state.toString
    logInfo("Command", Command)
    if(Command == "OFF") {
        HeizungHvac.sendCommand(Command)
    } else if (Command == "SCHEDULE" || Command == "MANUAL" || Command == "UNTIL_CHANGE" || Command == "TIMER") {
        HeizungMode.sendCommand(Command)
    }
end

to unite the hvac and operation mode into one item that you can than use in your sitemap or rule:

Selection item=Hvacandoperation      mappings=[SCHEDULE=schedule, MANUAL=manual, UNTIL_CHANGE="until change", TIMER=timer, OFF=off]

you could also add the custom window open mode into this:

rule "Combination"
when
    Item Hvacandoperation received update
then
    var String Command = Hvacandoperation.state.toString
    logInfo("Command", Command)
    if(Command == "OFF") {
        HeizungHvac.sendCommand(Command)
    } else if (Command == "SCHEDULE" || Command == "MANUAL" || Command == "UNTIL_CHANGE" || Command == "TIMER") {
        HeizungMode.sendCommand(Command)
    } else if (Command == "WINDOWOPEN") {
        HeizungMode.sendCommand("MANUAL")
        HeizungTargetTemp.sendCommand("5")
    }
end

This mode you could than use in your rule and or sitemap:

rule "Turn off heating when window is opened"
when
    Item LeftStudioWindow_OpenStatus changed
then
    if (LeftStudioWindow_OpenStatus.state == OPEN) {
        Hvacandoperation.sendCommand("WINDOWOPEN")
    } 
end

rule "Turn off heating when window is closed"
when
    Item LeftStudioWindow_OpenStatus changed
then
    if (LeftStudioWindow_OpenStatus.state == CLOSED) {
        Hvacandoperation.sendCommand("SCHEDULE")
    } 
end 

Maybe this gives you some inspiration.
Best regards Johannes

This works like a charm! Thank you so much for that @JGKK ! I’m very happy with the way the rule works now.