Can one generic thermostat control two switches?

The title pretty much says it all. In my dining room I have one temperature sensor and two heaters each connected to its own switch. What I want is to have one generic thermostat that could control both switches. Is there any easy way to that? I have tried making a group which contains the switches but it did not work.

What error did occur?

you could make a boolean_switch… turn that on using the thermostat and add automations to turn on/off the other two switches according to the boolean_switch… the trigger would be when its state changes

heater string Required

entity_id for heater switch, must be a toggle device. Becomes air conditioning switch when ac_mode is set to true .

I guess the fact that groups can be more than just toggle devices is causing the issue.

You could use a template switch instead of a group in the thermostat (though you still need the group):

switch:
  - platform: template
    switches:
      dining_heaters:
        value_template: "{{ is_state('group.dining_heaters', 'on') }}"
        turn_on:
          service: homeassistant.turn_on
          data:
            entity_id: group.dining_heaters
        turn_off:
          service: homeassistant.turn_off
          data:
            entity_id: group.dining_heaters

Note: while using this will allow the thermostat to control both heaters, this will not turn both heaters on/off if either of the individual heater switches are used.

1 Like

No errors. I just did not find a way to let the thermostat control a group. My group is this in groups.yaml:

name: diningroom_heating
  entities:
    - switch.diningroom_a
    - switch.diningroom_b

This creates a group.diningroom_heating but I do not know how to put the thermostat use this as a heater.

Taking from the integration page:

climate:
  - platform: generic_thermostat
    name: Study
    heater: group.diningroom_heating
    target_sensor: sensor.my_temperature_sensor

or if using the group directly is not supported as @tom_l expects, use his intermediate, template switch instead.

Generic thermostat cannot control groups directly so I’ll try a template switch.

1 Like

Since there seems not to be any straightforward way to do this, I created an automation which turns switch_b on or off according to the state of switch_a. Switch_a is controlled by a generic thermostat. Because automations have now a choose option, this was easy.

I did not try the template switch suggested by tom_l but I suppose it might have worked as well. Thank you very much for your help!

1 Like

I was half way through writing an automation for you that did exactly that when I thought of the template switch.

1 Like

Like this?

alias: switch b follows a
trigger:
  - platform: state
    entity_id: switch.switch_a
conditions: []
action:
  - service: switch.turn_{{ trigger.to_state.state }}
    entity_id: switch.switch_b
2 Likes

I used ‘choose’ instead of a template. I admit that your code is much more advanced and elegant. This is my code created by GUI:

alias: Diningroom heating
  description: ''
  trigger:
  - platform: device
    type: turned_on
    device_id: b8652ef34f794e09a7b8b07a48eb8d23
    entity_id: switch.diningroom_a
    domain: switch
  - platform: device
    type: turned_off
    device_id: b8652ef34f794e09a7b8b07a48eb8d23
    entity_id: switch.diningroom_a
    domain: switch
  condition: []
  action:
  - choose:
    - conditions:
      - condition: device
        type: is_on
        device_id: b8652ef34f794e09a7b8b07a48eb8d23
        entity_id: switch.diningroom_a
        domain: switch
      sequence:
      - type: turn_on
        device_id: 4ba755e9c698bf8e0bfd1753b72e50dd
        entity_id: switch.diningroom_b
        domain: switch
    - conditions:
      - condition: device
        type: is_off
        device_id: b8652ef34f794e09a7b8b07a48eb8d23
        entity_id: switch.diningroom_a
        domain: switch
      sequence:
      - type: turn_off
        device_id: 4ba755e9c698bf8e0bfd1753b72e50dd
        entity_id: switch.diningroom_b
        domain: switch
    default: []
  mode: single

Create 2 automation.

automation one (A1) turns the heater switches ON automation two (A2) turns to switches OFF

Create a template switch (TS1) that triggers A1 when ON when triggered and triggers A2 when OFF when triggered

Lastly, create a generic thermostat using TS1 and your temperature sensor

Why?

I showed how it could be done with just the template switch, a switch group, and no automations.

Christoph showed how it could easily and efficiently be done with one automation. Even Tapkor’s longer automation was still only one automation.

What does your method of two automations and a template switch bring to the table?

Missed it…that’d be much better :grin:

There is an add-on in hacs that allows 2 or more heater switches in one thermostat.

thx a lot for this solution - works fine for me as well :slight_smile: