How To Set Ecobee "Away and Hold"

How do I create an action in a rule to set the thermostat to “Away and Hold” or “Home and Hold”. I tried sending the command “away” (without the quotes) through the Ecobee Hold Action channel but the logfile shows:

2023-02-27 14:58:58.710 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘Ecobee_Thermostat_Hold_Action’ received command away
2023-02-27 14:58:58.712 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘Ecobee_Thermostat_Hold_Action’ predicted to become away
2023-02-27 14:58:58.717 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Ecobee_Thermostat_Hold_Action’ changed from askMe to away
2023-02-27 14:59:05.407 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Ecobee_Thermostat_Hold_Action’ changed from away to askMe

Do I need to use a different channel or a different command to make this work?

You need to call one of the setHold actions from within a rule.

There also are some example rules further down in the documentation.

Here’s a rule I worked out in ECMAScript to set multiple thermostats. Substitute “Away” for “Arriving”

ecobeeActions = actions.thingActions("ecobee", "ecobee:thermostat:7...8");
setClimateHold("Main Floor", ecobeeActions, "Arriving"); 

ecobeeActions = actions.thingActions("ecobee", "ecobee:thermostat:7...7");
setClimateHold("Office", ecobeeActions, "Arriving"); 

ecobeeActions = actions.thingActions("ecobee", "ecobee:thermostat:7...6");
setClimateHold("Bedroom", ecobeeActions, "Arriving"); 

ecobeeActions = actions.thingActions("ecobee", "ecobee:thermostat:7...0");
setClimateHold("Hall", ecobeeActions, "Arriving"); 

function setClimateHold(statName, statActions, desiredClimate) {
  var climates = statActions.getClimates()
  // console.log("climate = " + climates);
  if (climates !== null) {
    climates = JSON.parse(climates);
    var numElements = climates.length;
    console.log("Climates: There are ", numElements, " climates in array");
    console.log(JSON.stringify(climates[numElements-1]));

    var nameMap = {};
    for (var i=0; i < numElements; i++) {
        climateSettings = climates[i];
        nameMap[climateSettings.name] = climateSettings.climateRef;
        // console.log("Climate ", i, " Name: " + climateSettings.name, " Ref: ", climateSettings.climateRef, " Heat: ",  (climateSettings.heatTemp/10.0));
    }
    if (desiredClimate in nameMap ) {
      console.log("Setting ", nameMap[desiredClimate], " for ", statName);
      ecobeeActions.setHold(nameMap[desiredClimate]);
    } else {
      console.log("Did not find ", desiredClimate, " for ", statName);
      console.log(JSON.stringify(nameMap));
    }
  } else {
      console.log("No climates found for " + statName)
  }
}
1 Like

@tcgerhard Nice use of getClimates action!