ESP8266 + DHT 22 sensor post to local MQTT server, but can't post to HASSio

Hello,
I’ve managed to post to local Mosqito server a topic “DHT22/json”. I can’t separate them to a different topics.
The data comes correctly like this:

*{"system":{"hostname":"ESP001189E4","uptime":5400,"rssi":-39,"freemem":28912},"sensors":{"dhtt1":20.5,"dhth1":41.4}}*

My configuration.yaml file looks like this:

# MQTT Sensor Example configuration.yaml entry
mqtt:
  broker: 127.0.0.1
  username: local
  password: local

sensor:
  - platform: mqtt
    unique_id: ESP001189E4Temp
    name: "Temperature"
    state_topic: "DHT22/json"
    unit_of_measurement: "°C"
    value_template: "{{ value_json.dhtt1 }}"
  - platform: mqtt
    unique_id: ESP001189E4Humid
    name: "Humidity"
    state_topic: "DHT22/json"
    unit_of_measurement: "%"
    value_template: "{{ value_json.dhth1 }}"

But the readings dispayed is always 0.
Please help. I dont’t know how to read correct value on my dashboard?

Have you verified what is actually on your MQTT broker?
MQTT Explorer is an incredible tool to check this.

Hi,
Yes I did. That’s where I’ve copied the JSON from.

Please try this value templates.

{{ value_json.sensors.dhtt1 }}
{{ value_json.sensors.dhth1 }}
1 Like

Thank you. Your sollution work well.

1 Like