How to control multiple Thermostats via MQTT - but with one thermostat card?

Hi fellas :slight_smile:

I have a MQTT controlled floor heating system in the whole house. Each room is controlled by a sensor, that reports back to the unit, which reports to the MQTT broker.

The code for example one room looks like this:

climate:
  - platform: mqtt
    name: Værksted
    modes:
      - 'off'
      - 'heat'
    current_temperature_topic: 'heat/floorB4E62D292F41/0/current'
    temperature_command_topic: 'heat/floorB4E62D292F41/0/target_set'
    temperature_state_topic: 'heat/floorB4E62D292F41/0/target'
    availability_topic: 'heat/floorB4E62D292F41/online'
    payload_available: 'True'
    payload_not_available: 'False'
    mode_state_topic: 'heat/floorB4E62D292F41/0/output'
    mode_state_template: >-
      {{ 'heat' if value == 'on' else 'off' }}
    qos: 0

I have multiple of these entities, but is there a way to control all with just one thermostat card or how do I do it best?

Best regards

Jacob

1 Like

create a simple automation that triggers on changes to your “master” thermostat and reflects changes to your “slave” thermostats
Define which will be master for your lovelace card

Would you mind showing an example.i tried this way and it will switch between off and selected mode all the time .

you first need to create a template sensor that gets the target temperature:

  - platform: template
    sensors:
      thermostat_target_temp:
        friendly_name: "Thermostat Target Temp"
        entity_id: climate.master_thermostat_name
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('climate.master_thermostat_name', 'temperature') }}"

then create an automation that changes the slave thermostat target temp:

  - alias: Thermostat - Set Slave Target Temperature
    trigger:
      - platform: state
        entity_id: sensor.thermostat_target_temp
    action:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.slave_thermostat_name
          temperature: "{{states('sensor.thermostat_target_temp')}}"

I solved my loop problem with a delay of 1 second :slight_smile: this is my whole config if someone might be interested :slight_smile:

# AC Bedroom Sensors for Thermostat

# AC Bedroom

  - platform: template
    sensors:
      ac_bedroom_hvac_mode:
        entity_id: climate.air_conditioner_bedroom
        value_template: "{{ states.climate.air_conditioner_bedroom.state }}"
        friendly_name: AC Bedroom HVAC Mode

      ac_bedroom_temperature:
        entity_id: climate.air_conditioner_bedroom
        value_template: "{{ state_attr('climate.air_conditioner_bedroom', 'temperature') }}"
        friendly_name: AC Bedroom Temperature 
        
      ac_bedroom_fan_mode:
        entity_id: climate.air_conditioner_bedroom
        value_template: "{{ state_attr('climate.air_conditioner_bedroom', 'fan_mode') }}"
        friendly_name: AC Bedroom Temperature 

# Thermostat

      thermostat_bedroom_hvac_mode:
        entity_id: climate.bedroom_ac_control
        value_template: "{{ states.climate.bedroom_ac_control.state }}"
        friendly_name: Thermostat Bedroom HVAC Mode
      thermostat_bedroom_temperature:
        entity_id: climate.bedroom_ac_control
        value_template: "{{ state_attr('climate.bedroom_ac_control', 'temperature') }}"
        friendly_name: Thermostat Bedroom Temperature 
      thermostat_bedroom_fan_mode:
        entity_id: climate.bedroom_ac_control
        value_template: "{{ state_attr('climate.bedroom_ac_control', 'fan_mode') }}"
        friendly_name: Thermostat Bedroom Temperature 

###################################### END ###########################################################

And the automations:

# # Bedroom Thermostat


## HVAC Mode

  - alias: Thermostat - 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 - 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 - 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 - 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 - 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 - 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 have made an initial (not tested) implementation here to my climate_group component:

you have to add:

master_device: entity

to your config of the climate group. Maybe that is useful for some people.