Question about generic_thermostat

Hi,

I have a question about the generic_thermostat configuration

My configuration looks like this:

temperature_xiaomi_air_1:
  unit_of_measurement: '°C'
  value_template: "{{ states.fan.xiaomi_air_1.attributes.temperature }}"
  device_class: temperature
- platform: generic_thermostat
  name: thermostat_bedroom
  heater: switch.heater_bedroom
  target_sensor: sensor.temperature_xiaomi_air_1
  min_temp: 16
  max_temp: 26
  ac_mode: False
  target_temp: 20.5
  cold_tolerance: 0.1
  hot_tolerance: 0.1
  min_cycle_duration:
    seconds: 5
  keep_alive:
    minutes: 3
  initial_operation_mode: "auto"
  away_temp: 16

The problem with this configuration is that if the temperature sensor becomes unavailable while thermostat is on heat mode, it continues in heat mode indefinitely.

As a workaround I changed the sensor’s template configuration so the value is 999 when the data is not available:

temperature_xiaomi_air_1:
  unit_of_measurement: '°C'
  value_template: "{{ states.fan.xiaomi_air_1.attributes.temperature or 999 }}"
  device_class: temperature

Apart from being not too elegant, it messes up the sensor/thermostat history, which normally I find useful.

I there a better way to handle the sensor unavailability so the thermostat goes idle without this workaround?

Thanks,
Juan

I solved this by having more sensors spread out throughout the heating zone and using a min_max sensor to average them together. The unavailable values are ignored.

I noticed this too and I set the template to give 50 degrees C so the heating is off. Have you tried using an automation to check for unavailable temperature and then turn the thermostat mode to off?

Thanks. It is a good solution. However I don’t have yet the infrastructure :slight_smile:

Thanks, I may give it a try.