Controlling generic thermostat switch

Hello,

I have the following:

I have a baseboard heater that is controlled by it’s own controller that reports MQTT a topic for the current temperature and will listen for a temperature setpoint that I send it.

It reports the current temperature as sensor.master_bedroom_temperature
It receives the setpoint I set through input_number.master_bedroom_baseboard_temperature

In the past I’ve just had two entity cards that show me the current temp and allow me to set the input_number. Recently I thought I’d like to see this represented as a generic thermostat.

This is my climate entry:

climate:

  • platform: generic_thermostat
    name: “Master Bedroom Thermostat”
    unique_id: “master_bedroom_thermostat”
    heater: switch.master_bedroom_baseboard_heater_dummy
    target_sensor: sensor.master_bedroom_temperature
    min_temp: 50
    max_temp: 75
    ac_mode: false
    precision: 0.5

I have an automation that passes the setpoint to the baseboard heater. The heater works fine, but I can’t figure out how to get the thermostat card to reflect the current state of the heater (ie. heating or idle). Caveat: it’s not as simple as comparing the temperatures either. The baseboard is on off-peak, so it could be that the heater is told to heat but isn’t actually heating because the power is rippled.

I have a binary sensor (binary_sensor.master_bedroom_heat_working) that tells me if the heater is working, either because the heater knows it is (by looking at the temperature at the heater) or because I see the current draw on the electrical panel.

How can I reflect the heater status on the climate card for this thermostat?

In developer tools I can manually set the state of the dummy switch to on or off and it will show up on the climate card correctly, but if I call “switch_on” or “switch_off” in an automation, or I try and turn the dummy switch on or off through an entity card, it doesn’t work (and the switch immediately reverts to its original state). The only way I can make it stick is through developer tools → set state.

Which integration is providing switch.master_bedroom_baseboard_heater_dummy ?

It’s defined in configuration.yaml:

switch:
  platform: template
  switches:
    master_bedroom_baseboard_heater_dummy:
      value_template: "{{ false }}"
      turn_on:
      turn_off:

The value_template sets the entity’s state… so, you have set it’s state to be permanently “off”.

That should be used to define the switch’s state.

The “Set State” function is for debugging. It writes the value to the state machine, but it has no direct effect on anything else. Whatever value you write using it will always be overwritten as soon as the integration updates the entity in question.

You haven’t assigned any actions for turn_on or turn_off… so those service calls, whether they are made through script actions or the dashboard, don’t have anything to do. For a template switch to work normally, the action sequences defined in these two configuration keys should have the means to affect the “calculation” being made in the value_template.

The dummy switch is really just a placeholder for the climate entry. It doesn’t do anything.

I now have a working configuration - thank you!

climate:
  - platform: generic_thermostat
    name: "Master Bedroom Thermostat"
    unique_id: "master_bedroom_thermostat"
    heater: switch.master_bedroom_baseboard_heater_dummy
    target_sensor: sensor.master_bedroom_temperature
    min_temp: 50 
    max_temp: 75
    ac_mode: false
    precision: 0.5 

switch:
  platform: template
  switches:
    master_bedroom_baseboard_heater_dummy:
      value_template: "{{ states('input_boolean.master_bedroom_heat_working') }}"
      turn_on:
      turn_off:

I monitor the heater through power consumption and have an automation that toggles the input_boolean on or off if the heater is drawing power.