Automation to switch thermostat modes based on target temp

I’m using a Honeywell T6 Z Wave thermostat tied into HA. The thermostat has an auto-change feature to change from heat-to-cool and vice versa if minimum or maximum temps are hit. But, I can’t change to the auto-change mode from HA. I can only change the mode to heat, cool, or off.

I want HA to switch the thermostat from heat to cool and vice-versa based on the target temp I set on my lovelace card. I want HA to handle this because my fireplace is close to the thermostat. I’ll add a condition to the automation to only go to cool mode if the fireplace is turned off.

I know how to set an automation that would turn the thermostat to cool mode when the temp goes above 72, but that makes my lovelace slider useless. I’d like to build an automation that turns the thermostat to cool mode if the indoor temp is higher than the set temp on my lovelace card and vice-versa to change to heat mode.

sensor.honeywell_unknown_type_0011_id_0008_temperature
climate.honeywell_unknown_type_0011_id_0008_cooling_1 (temperature attribute).

Can this be done?

I’m assuming you mean you have an input_number entity that is your “set temp on my lovelace card”???

trigger:
  platform: template
  value_template: >
    {{ states('sensor.honeywell_unknown_type_0011_id_0008_temperature')|float >
       states('input_number.xyz')|float }}

I might need to explain this better.

I’m using the temperature card below.
Untitled

When I change the target temperature using the slider it changes the temperature: attribute of the entity climate.honeywell_unknown_type_0011_id_0008_cooling_1

I would like to use this attribute as the trigger to switch from heat to cool. Something like this:

- id: '1571794108312'
  alias: Change HVAC Mode to Heat
  description: ''
  trigger:
  - below: `temperature:` attribute of the entity `climate.honeywell_unknown_type_0011_id_0008_cooling_1`
    entity_id: sensor.honeywell_unknown_type_0011_id_0008_temperature
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: climate.honeywell_unknown_type_0011_id_0008_cooling_1
      hvac_mode: heat
    service: climate.set_hvac_mode

Ideally, I’d have the heat mode kick in if the temp goes 2 degrees below the temperature: attribute and the cool go on if it goes 2 degrees above the temperature: attribute.

1 Like

You could likely create a sensor that monitors the difference between the ‘current_temperature’ and ‘temperature’ - and then build two separate automations based on the value of this sensor.

Create a SENSOR:

temperature_difference:
  value_template: "{{ ((state_attr('climate.honeywell_unknown_type_0011_id_0008_cooling_1t','temperature') | int) - (state_attr('climate.honeywell_unknown_type_0011_id_0008_cooling_1','current_temperature') | int)) | int }}"

Then create automations based on this sensor value. If numeric_state > 2 set to HEAT, numeric_state < 2 set to cool

trigger:
  platform: template
  value_template: >
    {% set mode = states('climate.honeywell_unknown_type_0011_id_0008_cooling_1') %}
    {% set trg = state_attr('climate.honeywell_unknown_type_0011_id_0008_cooling_1', 'temperature')|float %}
    {% set cur = states('sensor.honeywell_unknown_type_0011_id_0008_temperature')|float %}
    {{ mode == 'heat' and trg <= cur - 2 or mode == 'cool' and trg >= cur + 2 }}
action:
  service: climate.set_hvac_mode
  entity_id: climate.honeywell_unknown_type_0011_id_0008_cooling_1
  data_template:
    hvac_mode: >
      {% set mode = states('climate.honeywell_unknown_type_0011_id_0008_cooling_1') %}
      {{ 'heat' if mode == 'cool' else 'cool' }}

Depending on how your system behaves you may need to increase the delta to more than 2. E.g., when heating, if the current temperature reading goes to 2 or more degrees above the set point before, or even after, the heat turns off, then this implementation would switch it to cooling mode. Then, if the same thing happened when cooling (i.e., temp drops to 2 or more degrees below set point before, or even after, the cooling turns off), it would switch it back to heat mode. Can you say oscillation? :wink:

1 Like

Thanks! I’m going to give this one a shot.

I’m getting an error on that automation.

`

Invalid config for [automation]: [platform] is an invalid option for [automation]. Check: automation->platform. (See /config/configuration.yaml, line 687). Please check the docs at https://home-assistant.io/integrations/automation/

`

Can you post exactly what you have in your config file?

In my configuration.yaml file? I didn’t put anything in that file for this. Here is the entry for my automation.yaml file.

- id: '1571793830052'
  alias: Change HVAC Mode to Cool or heat
  description: Changes HVAC to cool or heat mode if the temp varies 2 degrees more than the set point and the fireplace
    is off
  trigger:
  platform: template
  value_template: >
    {% set mode = states('climate.honeywell_unknown_type_0011_id_0008_cooling_1') %}
    {% set trg = state_attr('climate.honeywell_unknown_type_0011_id_0008_cooling_1', 'temperature')|float %}
    {% set cur = states('sensor.honeywell_unknown_type_0011_id_0008_temperature')|float %}
    {{ mode == 'heat' and trg <= cur - 2 or mode == 'cool' and trg >= cur + 2 }}
  condition:
  - condition: state
    entity_id: switch.fireplace
    state: 'off'
  action:
  service: climate.set_hvac_mode
  entity_id: climate.honeywell_unknown_type_0011_id_0008_cooling_1
  data_template:
    hvac_mode: >
      {% set mode = states('climate.honeywell_unknown_type_0011_id_0008_cooling_1') %}
      {{ 'heat' if mode == 'cool' else 'cool' }}

Your indentation is incorrect. It should be:

  trigger:
    platform: template
    value_template: >
      {% set mode = states('climate.honeywell_unknown_type_0011_id_0008_cooling_1') %}
      {% set trg = state_attr('climate.honeywell_unknown_type_0011_id_0008_cooling_1', 'temperature')|float %}
      {% set cur = states('sensor.honeywell_unknown_type_0011_id_0008_temperature')|float %}
      {{ mode == 'heat' and trg <= cur - 2 or mode == 'cool' and trg >= cur + 2 }}

and

  action:
    service: climate.set_hvac_mode
    entity_id: climate.honeywell_unknown_type_0011_id_0008_cooling_1
    data_template:
      hvac_mode: >
        {% set mode = states('climate.honeywell_unknown_type_0011_id_0008_cooling_1') %}
        {{ 'heat' if mode == 'cool' else 'cool' }}
1 Like