Thermostats + Climate + HVAC

Hi everyone,

I’m trying something pretty silly right now… Maybe I’m overthinking it, but here we go…

I have a MQTT climate entity in home assistant that works well connected to my HVAC. I’m now trying to add a MQTT wall thermostat that controls the exact same features as the HVAC, so how do I link these devices together???

Here’s the code I have now…

  - platform: mqtt
    name: Living Room HVAC
    modes:
      - "off"
      - "auto"
      - "cool"
      - "dry"
      - "fan_only"
      - "heat"
    swing_modes:
      - "On"
      - "Off"
    fan_modes:
      - "Auto"
      - "High"
      - "Medium"
      - "Low"
      - "Quiet"
    min_temp: 16
    max_temp: 30
    temp_step: 1
    power_command_topic: "Home/Living/Hvac/Power/Cmd"
    mode_command_topic: "Home/Living/Hvac/Mode/Cmd"
    temperature_command_topic: "Home/Living/Hvac/Temp/Cmd"
    fan_mode_command_topic: "Home/Living/Hvac/Fan/Cmd"
    swing_mode_command_topic: "Home/Living/Hvac/Swing/Cmd"
    mode_state_topic: "Home/Living/Hvac/Stts"
    mode_state_template: "{{ value_json.mode }}"
    temperature_state_topic: "Home/Living/Hvac/Stts"
    temperature_state_template: "{{ value_json.temp }}"
    fan_mode_state_topic: "Home/Living/Hvac/Stts"
    fan_mode_state_template: "{{ value_json.fan }}"
    swing_mode_state_topic: "Home/Living/Hvac/Stts"
    swing_mode_state_template: "{{ value_json.swing }}"
    current_temperature_topic: "Home/Living/Hvac/Json"
    current_temperature_template: "{{ value_json.air_temp }}"
    availability_topic: "Home/Living/Hvac/LWT"
    payload_available: "online"
    payload_not_available: "offline"
    precision: 1.0
    send_if_off: true
    retain: false
    qos: 0
    json_attributes_topic: "Home/Living/Hvac/Json"
    
  - platform: mqtt
    name: Living Room Thermostat
    modes:
      - "off"
      - "auto"
      - "cool"
      - "dry"
      - "fan_only"
      - "heat"
    swing_modes:
      - "On"
      - "Off"
    fan_modes:
      - "Auto"
      - "High"
      - "Medium"
      - "Low"
      - "Quiet"
    min_temp: 16
    max_temp: 30
    temp_step: 1
    power_command_topic: "Home/Living/Therm/Power/Cmd"
    mode_command_topic: "Home/Living/Therm/Mode/Cmd"
    temperature_command_topic: "Home/Living/Therm/Temp/Cmd"
    fan_mode_command_topic: "Home/Living/Therm/Fan/Cmd"
    swing_mode_command_topic: "Home/Living/Therm/Swing/Cmd"
    mode_state_topic: "Home/Living/Therm/Stts"
    mode_state_template: "{{ value_json.mode }}"
    temperature_state_topic: "Home/Living/Therm/Stts"
    temperature_state_template: "{{ value_json.temp }}"
    fan_mode_state_topic: "Home/Living/Therm/Stts"
    fan_mode_state_template: "{{ value_json.fan }}"
    swing_mode_state_topic: "Home/Living/Therm/Stts"
    swing_mode_state_template: "{{ value_json.swing }}"
    current_temperature_topic: "Home/Living/Therm/Json"
    current_temperature_template: "{{ value_json.air_temp }}"
    availability_topic: "Home/Living/Therm/LWT"
    payload_available: "online"
    payload_not_available: "offline"
    precision: 1.0
    send_if_off: true
    retain: false
    qos: 0
    json_attributes_topic: "Home/Living/Therm/Json"

Separately, everything works:

  • The climate entity Living Room HVAC controls the HVAC properly
  • The thermostat is not adjusting the Living Room HVAC, but it reports to HA properly and HA updates the thermostat Living Room Thermostat

You have two thermostats, each with their own separate “agenda”, controlling the same HVAC system. I’m trying to imagine how this can possibly work well.

There’s no MQTT topic to keep their setpoint temperature in sync. What do you expect will happen when one thermostat’s setpoint is 20C and the other is 22C? Assume each one has a 1C deadband. I suspect they will fight to control the HVAC system (one wants to turn it on to maintain 22 while the other wants to turn it off because the ambient temperature is well above 20).

Ok, So I found something, but I’m not sure it’s the cleanest way to accomplish this… I does work though, but I’m open to suggestions

  - alias: HVAC Thermostat to HVAC
    trigger:
      - platform: state
        entity_id: climate.living_room_therm
    action:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.living_room_hvac
          temperature: "{{ state_attr('climate.living_room_therm', 'temperature') }}"
      - service: climate.set_fan_mode
        data_template:
          entity_id: climate.living_room_hvac
          fan_mode: "{{ state_attr('climate.living_room_therm', 'fan_mode') }}"
      - service: climate.set_hvac_mode
        data_template:
          entity_id: climate.living_room_hvac
          hvac_mode: "{{ state_attr('climate.living_room_therm', 'hvac_mode') }}"
      - service: climate.set_swing_mode
        data_template:
          entity_id: climate.living_room_hvac
          swing_mode: "{{ state_attr('climate.living_room_therm', 'swing_mode') }}"
          
  - alias: HVAC to HVAC Thermostat
    trigger:
      - platform: state
        entity_id: climate.living_room_hvac
    action:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.living_room_therm
          temperature: "{{ state_attr('climate.living_room_hvac', 'temperature') }}"
      - service: climate.set_fan_mode
        data_template:
          entity_id: climate.living_room_therm
          fan_mode: "{{ state_attr('climate.living_room_hvac', 'fan_mode') }}"
      - service: climate.set_hvac_mode
        data_template:
          entity_id: climate.living_room_therm
          hvac_mode: "{{ state_attr('climate.living_room_hvac', 'hvac_mode') }}"
      - service: climate.set_swing_mode
        data_template:
          entity_id: climate.living_room_therm
          swing_mode: "{{ state_attr('climate.living_room_hvac', 'swing_mode') }}"

Hi @123, I don’t have two physical thermostat, I have one wall thermostat and HA climate card and trying to keep both in sync.

OK but the first post doesn’t provide a description is that anywhere as clear and concise. In fact, the code you posted contains two MQTT HVAC configurations, one for climate.living_room_hvac and another for climate.living_room_thermostat.

If you only have one physical thermostat, why have you created two climate components?

In fact, I’m not really sure of what I’m doing :rofl: :rofl: :rofl:

I’ve been using the thermostat (climate) in HA for my HVAC for about a year now and it works great for controlling the HVAC from HA. Now I want to add a thermostat on the wall to easily change temp settings. So my thermostat is controlling the second climate entity. I first created a separate climate entity in order to test my thermostat.

If I well understand:

you have a climate component installed. Whatever how. and you want to control this climate with the thermostat climate entity right?

well… let’s see my setup. I have also my Airconditioner Climate component:

  - platform: xiaomi_remote
    name: Air Conditioner Bedroom
    temp_sensor: sensor.multisensor_bedroom_temperature
    remote: remote.remote_bedroom
    commands: !include Hitachi.yaml
    min_temp: 16
    max_temp: 32
    target_temp: 21
    target_temp_step: 1
    hvac_mode: "off"
    fan_mode: low
    customize:
      hvac_modes:
        - cool
        - heat
        - dry
        - auto
        - fan_only
        - "off"
      fan_modes:
        - low
        - medium
        - high
        - auto

And this is my climate thermostat:

  - platform: mqtt
    name: Bedroom AC Control
    availability_topic: "home/bedroom/tele/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    action_topic: "home/bedroom/stat/things/thermostat/properties"
    action_template: "{{value_json.action}}"
    temperature_command_topic: "home/bedroom/cmnd/things/thermostat/properties/targetTemperature"
    temperature_state_topic: "home/bedroom/stat/things/thermostat/properties"
    temperature_state_template: "{{value_json.targetTemperature}}"
    current_temperature_topic: "home/bedroom/stat/things/thermostat/properties"
    current_temperature_template: "{{value_json.temperature}}"
    mode_command_topic: "home/bedroom/cmnd/things/thermostat/properties/mode"
    mode_state_topic: "home/bedroom/stat/things/thermostat/properties"
    mode_state_template: "{{value_json.mode}}"
    fan_mode_command_topic: "home/bedroom/cmnd/things/thermostat/properties/fanMode"
    fan_mode_state_topic: "home/bedroom/stat/things/thermostat/properties"
    fan_mode_state_template: "{{value_json.fanMode}}"
    hold_command_topic: "home/bedroom/cmnd/things/thermostat/properties/holdState"
    hold_state_topic: "home/bedroom/stat/things/thermostat/properties"
    hold_state_template: "{{value_json.holdState}}"
    hold_modes: ["scheduler", "manual", "eco"]
    payload_on: true
    payload_off: false
    modes: ["heat", "cool", "fan_only", "off"]
    min_temp: 16
    max_temp: 32
    temp_step: 1
    precision: 0.5

And here is ONE automation which would sync both ways! In my case Bedroom

# # Bedroom Thermostat


## HVAC Mode

  - alias: Thermostat`Bedroom - Set Slave HVAC Mode
    trigger:
      - platform: state
        entity_id: sensor.thermostat_bedroom_hvac_mode
    action:
      - delay: 
          seconds: 1
      - service: climate.set_hvac_mode
        data_template:
          entity_id: climate.air_conditioner_bedroom
          hvac_mode: "{{ trigger.to_state.state }}"

  - alias: Thermostat Bedroom - Set Master HVAC Mode
    trigger:
      - platform: state
        entity_id: sensor.ac_bedroom_hvac_mode
    action:
      - delay: 
          seconds: 1
      - service: climate.set_hvac_mode
        data_template:
          entity_id: climate.bedroom_ac_control
          hvac_mode: "{{ trigger.to_state.state }}"

## Temperature

  - alias: Thermostat Bedroom - Set Slave Temperatue
    trigger: 
      - platform: state 
        entity_id: sensor.thermostat_bedroom_temperature
    action:
      - delay:
          seconds: 1
      - service: climate.set_temperature
        data_template:
          entity_id: climate.air_conditioner_bedroom
          temperature: "{{ trigger.to_state.state }}"

  - alias: Thermostat Bedroom- Set Slave Temperatue
    trigger: 
      - platform: state 
        entity_id: sensor.ac_bedroom_temperature
    action:
      - delay:
          seconds: 1
      - service: climate.set_temperature
        data_template:
          entity_id: climate.bedroom_ac_control
          temperature: "{{ trigger.to_state.state }}"

## Fan Mode

  - alias: Thermostat Bedroom - Set Slave Fan Mode
    trigger: 
      - platform: state 
        entity_id: sensor.thermostat_bedroom_fan_mode
    action:
      - delay:
          seconds: 1
      - service: climate.set_fan_mode
        data_template:
          entity_id: climate.air_conditioner_bedroom
          fan_mode: "{{ trigger.to_state.state }}"

  - alias: Thermostat Bedroom - Set Slave Fan Mode
    trigger: 
      - platform: state 
        entity_id: sensor.ac_bedroom_fan_mode
    action:
      - delay:
          seconds: 1
      - service: climate.set_fan_mode
        data_template:
          entity_id: climate.bedroom_ac_control
          fan_mode: "{{ trigger.to_state.state }}"

I also found a custom component called >Climate group but somehow it never worked. But maybe you want to give it a try:

https://github.com/daenny/climate_group (ALSO AVAILABLE IN HACS)

Side Note: I tried also to put hvac_mode, temp and fan_mode in the same automation as trigger but it did not work. I had to also add a delay of 1 sec as I would get a race condition between the two climate entities. Just try it out and tell me if it works for you :slight_smile:

1 Like

Hey, that’s what I ended doing with automations to sync, so it looks like this is the way to go :hugs:

Thanks buddy

Is this the arrangement?

MQTT HVAC (Living Room HVAC) --------------------> HVAC System
                                                       ^
                                                       |
                                                       |
MQTT HVAC (Living Room Thermostat) ----> Thermostat --->

Two climate entities:

  • Living HVAC controls the HVAC system directly.
  • Living Thermostat controls a thermostat that, in turn, controls the HVAC system.

No, more like this

MQTT HVAC (Living Room HVAC) --------------------> HVAC System
        ⇕
MQTT HVAC (Living Room Thermostat)

I already had my HVAC controlled by HA, and now I added a thermostat that syncs with the HA entity that syncs with the HVAC (internal EEPROM, so HVAC is master)

I don’t see the physical thermostat in your diagram. What I see is two climate entities where one is linked to the other (via an automation).

Do you mean this?

MQTT HVAC (Living Room HVAC) --------------------> HVAC System
           ^
           |
       Automation
           |
           |
MQTT HVAC (Living Room Thermostat)
           ^
           |
           |
           |
    Physical Thermostat

Yes, exactly… except automations are both ways, but yes…

OK, so why not make the physical thermostat communicate directly with climate.living_room_hvac?

You currently have the physical thermostat using MQTT topics beginning with:

Home/Living/Therm/

If you were to change it to use:

Home/Living/Hvac/

it would communicate directly with climate.living_room_hvac and eliminate the need for a second climate entity and the synchronizing automation.

Or is there some specific requirement that demands you use a separate climate entity?

Can I with Home Assistant also communicating with it??? If I can, that’s an awesome idea :open_mouth:

I don’t see why not. climate.living_room_hvac acts as an MQTT client that is subscribed to your HVAC system’s topics. Your physical thermostat can subscribe to the same topics and behave as a secondary MQTT client.

1 Like