SOLVED MQTT data showing as "unknown"

Forgive me for a new question on this subject, I have spend the morning reading through topics and manuals but seem to miss a key ingredient/piece of knowledge. Thank you for your understanding.

I have a ESP32 sending DHT22 sensor data (temperature/humidity) to the Mosquitto broker installed in HA. This works fine. I can see the data flowing in:

Message 7 received on esp32/humidity at 13:50:
59.20
QoS: 0 - Retain: false
Message 6 received on esp32/humidity at 13:50:
59.20
QoS: 0 - Retain: true
Message 5 received on esp32/humidity at 13:50:
59.20
QoS: 0 - Retain: false
Message 4 received on esp32/humidity at 13:50:
59.20
QoS: 0 - Retain: true
Message 3 received on esp32/humidity at 13:40:
59.40
QoS: 0 - Retain: false

In configuration.yaml I have entered this entry:

mqtt:
  sensor:
    - name: "DHT ESP32 Temperatuur"
      state_class: measurement
      state_topic: "esp32/temperature"
      unique_id : 09568b8b-c0cb-47d9-887b-29a89268d91e
      unit_of_measurement: "°C"
      value_template: "{{ value_json.temperature }}"

    - name: "DHT ESP32 Luchtvochtigheid"
      state_class: measurement
      state_topic: "esp32/humidity"
      unique_id : ff663ab9-7547-4790-8a70-30cd961fd4ad
      unit_of_measurement: "%"
      value_template: "{{ value_json.Humidity }}"
  • I have added " state_class: measurement"
  • I have changed humidity into Humidity
  • I have added “unique_id : 1234567890” with ID’s from https://www.uuidgenerator.net/ to be able to see the entry.

The entry is showing om my dashboard but with values “unknown”

Obviously I am overlooking something. What?

Are you confident in the format of the data? Based on the logs it doesn’t appear to be JSON it just looks like a raw value.

Try this to see what the data looks like:

value_template: "{{ value }}"

1 Like

Thank YOU, sir: this did it. Proof that copy-paste from websites sometimes is not smart…

Problem solved.