Generic Thermostat with Sonoff TH16

Something is wrong with my generic thermostat. If as target_sensor I put an Aquara temperature sensor, generic thermostat works. With the Sonoff TH16 generic thermostat was always INACTIVE.

Sonoff TH16 gives me:

11:09:19 MQT: tele/sonoff-th16/SENSOR = {“Time”:“2021-12-08T11:09:19”,“SI7021”:{“Temperature”:15.9,“Humidity”:59.2},“TempUnit”:“C”}

climate.yaml

- platform: generic_thermostat
  name: Heat
  heater: switch.heater
  target_sensor: sensor.sonoff_th16_temperature
  min_temp: 15
  max_temp: 30
  target_temp: 22
  cold_tolerance: 0.3
  hot_tolerance: 0
  min_cycle_duration:
    seconds: 5
  keep_alive:
    minutes: 3
  initial_hvac_mode: heat
  precision: 0.5

sensor.yaml

- platform: mqtt
  name: "Sonoff TH16"
  unique_id: "sonoff_th16_temperature"
  state_topic: "tele/sonoff-th16/SENSOR"
  value_template: "{{ value_json['SI7021'].Temperature | float }}"
  qos: 1
  unit_of_measurement : "°C"
  device_class: temperature
  state_class: measurement

What’s wrong?

Take a look in Dev Tools/States for your target sensor.
I think it is:

sensor.sonoff_th16
state_class: measurement
unit_of_measurement: °C
friendly_name: Temperature
device_class: temperature

State: 15.8

The entity_id?

sonoff_th16_temperature

According to what you posted, your Sonoff temperature sensor’s entity_id is:

 sensor.sonoff_th16

not:

sensor.sonoff_th16_temperature

That’s why the Generic Thermostat doesn’t work because it was assigned a non-existent temperature sensor.

This is why VDRainer asked you to confirm the MQTT Sensor’s entity_id which is normally derived from its name and not its unique_id.

Change target_sensor to this then restart Home Assistant.

  target_sensor: sensor.sonoff_th16
2 Likes

Ultimately, it’s your choice of which reply to your problem should be assigned the Solution tag but the common convention is to assign it to the first or most complete post that identifies and resolves the original problem.

In the interests of fairness, I think you should mark VDRainer’s post with the Solution tag because it is the first post to identify the problem to be due to an incorrect entity_id. I simply added context.