Generic thermostat will turn off but not on?

Hey guys.

I am desperate. I just spent 2 days configuring a generic thermostat but I keep getting stuck (and I am pretty sure that at some point in the past two days it was working … until I “fixed” something).

The situation:
I have a group of thermostats for my office radiators. The work fine as group in a climate entity (climate.kellerburo_group). I then purchased an external temperature sensor (sensor.lumi_lumi_weather_temperature_2) and wanted to combine it with said group. It is my understanding (but maybe I am wrong?) that I have to put climate and sensor together in a generic_thermostat (climate.kellerthermostat ) to have the climate entity use the external sensor as temperature reference (instead of the internal one). I also figured out that I would have to build a template switch (switch. toggle_heater_office) to toggle between “heat” and “off” – because that is how the generic_thermostat works.

To further complicate things, I added a slider (input_number.slider_external_max) for setting the max temperature via UI. But that does not seem to be the problem, as it works fine when trying everything in the dev tools.

The config:

switch:
  - platform: template
    switches:
      toggle_heater_office:
        friendly_name: "Toggle heating in office"
        value_template: "{{ not is_state('climate.kellerburo_group', 'off') }}"
        turn_on:
          - service: climate.turn_on
            target:
              entity_id: climate.kellerburo_group
          - service: climate.set_temperature
            target:
              entity_id: climate.kellerburo_group
            data_template:
              temperature: "{{ states('input_number.slider_external_max')|float }}"
              hvac_mode: "heat"
              target_temp_high: "{{ states('input_number.slider_external_max')|float + 3 }}" 
              target_temp_low: "{{ states('input_number.slider_min')|float }}"
        turn_off:
          - service: climate.set_hvac_mode
            target:
              entity_id: climate.kellerburo_group
            data:
              hvac_mode: "off"  
          - service: climate.turn_off
            target:
              entity_id: climate.kellerburo_group

climate:
  - platform: generic_thermostat
    name: Kellerthermostat
    heater: switch.toggle_heater_office
    target_sensor: sensor.lumi_lumi_weather_temperature_2
    min_temp: 15
    max_temp: 30
    ac_mode: false
    target_temp: 17
    cold_tolerance: 0.3
    hot_tolerance: 0.4
    min_cycle_duration:
      seconds: 5
    initial_hvac_mode: "off"
    away_temp: 16
    precision: 0.1
    comfort_temp: 24

The result:
For testing, I added a thermostat card for the climate_group, one for the generic_thermostat and a button for toggling the switch to the UI.

  • The switch and the group work together just fine. When I toggle via button, the climate_group turns on (“heat”) and off just fine. Also: When I heat via the thermostat card, the toggle correctly represents the current on/off state.
  • Turning off the group (and the toggle) via the generic_thermostat also works just fine.
  • Turning on the group (and the toggle) via the generic_thermostat does not work though. When I paste the service call (“turn_on” section from the fake switch) from above in the home assistant dev tools, it turns the climate_group on as expected – but via the thermostat card in the UI, it fails. Turning on the generic_thermostat with the same service-call (I just replaced the group entity with the generic one) via dev tools also fails.

I just can’t get my head around what is happening here. There is no error entry in the logs, and the logbook also doesn’t help. Does anybody have an idea what’s going one here?

It looks correct to me.
I have not set mine up that way, I have used just a boolean as the switch.
Then have an automation that sets the TRVs on or off.
I honestly can’t say that should make a difference because that is pretty much what your template does also.

But is there anything in the logs?
What happens if you copy your turn on to an automation and trigger it ( or script), does that create any errors?

Nothing in the logs that I can link to these devices. I have not tried to put the service call into an automation … only in the dev tools. But I will test that right away!

UPDATE: It does toggle the switch and turn on the climate group – but it won’t turn on the generic_thermostat. Maybe the value_template there is wrong? But when I copy that part over to the dev tools, it shows the expected results.

I just now thought about something.
Could it be that it runs to fast.
Turn on is too slow that the temperature set happens before it’s on and it fails?

That’s an interesting guess. How would I test that? Where would I need to put a delay?

Yes add a 5 second delay then reduce until it stops working again (if you want it less than 5 seconds)

turn_on:
          - service: climate.turn_on
            target:
              entity_id: climate.kellerburo_group
          - delay: '0:05'
          - service: climate.set_temperature
            target:
              entity_id: climate.kellerburo_group
            data_template:
...

Like that? No change, it still does not work. Not even with 15 Seconds …

Try the automation route then and look at the trace

Same effect as mentioned above :arrow_up:.

Okay, I just figured out: It seems like the generic thermostat stay in preset “idle” – and that somehow messed things up. I added the entity_id of the generic thermostat to all service-calls (that should be redundant, but now it works, so I will definitely leave it that way!), and also added another service-call for changing the climate preset to “comfort”.

excerpt:

switch:
  - platform: template
    switches:
      toggle_heater_office:
        friendly_name: "Toggle heating in office"
        value_template: "{{ not is_state('climate.kellerburo_group', 'off') }}"
        turn_on:
          - service: climate.turn_on
            target:
              entity_id: 
                - climate.kellerburo_group
                - climate.kellerthermostat
          - service: climate.set_preset_mode
            data:
              preset_mode: "comfort"
            target:
              entity_id: 
                - climate.kellerburo_group
                - climate.kellerthermostat
          - service: climate.set_temperature
...

This will need a few days of testing, but I guess this is solved now. Thanks for helping out, appreciate it!

Hi,
How can i change the target temperature on the generic HA thermostat?
My AC temperature sensor is fk up.
Thanks!