Climate Generic Thermostat does not seem to record state on restart

Hi there.

Following this post, I was playing around with Climate Generic Thermostat.

What I would like is to be able to turn it on/off based on an input_boolean and keep the target temperature after a restart (without the default).

Here is my relevant config:

climate:
  - platform: generic_thermostat
    name: Termostato Sala
    heater: switch.tomada_sala
    target_sensor: sensor.temperature_158d00012356d8
    min_temp: 19
    max_temp: 23
    min_cycle_duration: 5
#    target_temp: 20
    tolerance: 1
    operation_mode: Heat

input_boolean:
  temp_sala_auto:
    name: On/Off
#    initial: off
  icon: mdi:thermometer-lines

automation:
  - alias: "Thermostat On"
    trigger:
      platform: state
      entity_id: input_boolean.temp_sala_auto
      from: 'off'
      to: 'on'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.termostato_sala
          temperature: 20

  - alias: "Thermostat Off"
    trigger:
      platform: state
      entity_id: input_boolean.temp_sala_auto
      from: 'on'
      to: 'off'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.termostato_sala
          temperature: 0

Still then, even if I leave the input_boolean on and restart, its state is kept, but not the target temperature set before the restart.

I even tried this, but it also doesn’t work:

automation:
  - alias: "If Thermostat is On after restart, make sure temperature is set right"
    trigger:
      - platform: homeassistant
        event: start
    condition:
      condition: state
      entity_id: input_boolean.notify_home
      state: 'on'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.termostato_sala
          temperature: 20

  - alias: "If Thermostat is Off after restart, make sure temperature is set right"
      trigger:
        - platform: homeassistant
          event: start
      condition:
        condition: state
        entity_id: input_boolean.notify_home
        state: 'off'
      action:
        - service: climate.set_temperature
          data:
            entity_id: climate.termostato_sala
            temperature: 0

Is this is an issue or am I missing something?

Thanks in advance.

I don’t believe this is an issue. Last I checked the setpoint is not persisted. AFAIK persist-on-restart is available only for input sliders and selects.

I’ve managed to achieve this using an AppDaemon script.

1 Like

Damn…

Any idea on why my triggers on homeassistant start might not work?

Theoretically this trigger should only run when all the components in configuration are properly initialized, right?

Thanks in advance.

I recall there being some issues with that event and also I think it’s now renamed to homeassistant_start, check here:

I haven’t made use of that event so I can’t give you any help how it works.

I also recalled something, but I think it was the other way around.

Check here the warning:

It was a mistake in the input_boolean name.

It worked like this:

climate:
  - platform: generic_thermostat
    name: Termostato Sala
    heater: switch.tomada_sala
    target_sensor: sensor.temperature_158d00012356d8
    min_temp: 19
    max_temp: 23
    min_cycle_duration: 5
#    target_temp: 20
    tolerance: 1
    operation_mode: Heat

input_boolean:
  temp_sala_auto:
    name: On/Off
#    initial: off
  icon: mdi:thermometer-lines

automation:
  - alias: "Thermostat On"
    trigger:
      platform: state
      entity_id: input_boolean.temp_sala_auto
      from: 'off'
      to: 'on'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.termostato_sala
          temperature: 20

  - alias: "Thermostat Off"
    trigger:
      platform: state
      entity_id: input_boolean.temp_sala_auto
      from: 'on'
      to: 'off'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.termostato_sala
          temperature: 0

  - alias: "If Thermostat is On after restart, make sure temperature is set right"
    trigger:
      - platform: homeassistant
        event: start
    condition:
      condition: state
      entity_id: input_boolean.temp_sala_auto
      state: 'on'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.termostato_sala
          temperature: 20

  - alias: "If Thermostat is Off after restart, make sure temperature is set right"
      trigger:
        - platform: homeassistant
          event: start
      condition:
        condition: state
        entity_id: input_boolean.temp_sala_auto
        state: 'off'
      action:
        - service: climate.set_temperature
          data:
            entity_id: climate.termostato_sala
            temperature: 0

It works when I change the On/off switch and also keeps it when I restart the server.

Now I just need to influence the On/off switch depending on the schedule I want the thermostat to be active and it’s done.

Thanks a lot for all your help (trying also counts).