DHT11 (attached to ESP8266 and flashed with Tasmota) sensor values not showing up in Home Assistant

Hi,
I flashed Tasmota on Nodemcu. Attached a 4 channel relay and a DHT11 sensor. It shows up fine on the browser. I can see the sensor outputs and can control the relays. However, from HA, I can only control the relays but don’t see the output of the sensors.
Below is my entry in the configuration.yaml file. I took it from the Tasmota wiki https://github.com/arendst/Sonoff-Tasmota/wiki/Home-Assistant-%E2%80%90-Manual-Config

sensor:
  - platform: mqtt
    name: "Temperature"
    state_topic: "tele/sonoff/SENSOR"
    value_template: "{{ value_json['DHT22'].Temperature }}"
    unit_of_measurement: "°C"
    availability_topic: "tele/sonoff/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
  - platform: mqtt
    name: "Humidity"
    state_topic: "tele/sonoff/SENSOR"
    value_template: "{{ value_json['DHT22'].Humidity }}"
    unit_of_measurement: "%"
    availability_topic: "tele/sonoff/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"

Below is the console output from Tasmota:

21:45:29 MQT: tele/sonoff/SENSOR = {"Time":"2019-03-31T21:45:29","DHT11":{"Temperature":31.3,"Humidity":43.0},"TempUnit":"C"}


Tasmota screenshot showing Temperature and Humidity alongwith relay status.


HA screenshot showing the relays (under Switch) but not the sensor output

What could I be missing?

Change your sensor from DHT22 to DHT11 as per the json string.

value_template: "{{ value_json['DHT11'].Temperature }}"

Do the same for the humidity sensor.

1 Like

My bad. I had directly pasted it from the tasmota wiki. My actual configurations are
value_template: “{{ value_json[‘DHT11’].Temperature }}”
and
value_template: “{{ value_json[‘DHT11’].Humidity }}”
Still not working.

The same problem over here …

So, I got it resolved. Though I can’t explain why. There was a line in the config.yaml file which was throwing a warning (completely unrelated). Removing that solved the issue.
Thus, the config in the documentation should be working right.

Can you paste your configuration and the output from the Tasmota console?

output from Tasmota :

12:08:27 MQT: tele/sonoffTH/STATE = {“Time”:“2019-04-03T12:08:27”,“Uptime”:“1T22:02:27”,“Vcc”:2.714,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:21,“Wifi”:{“AP”:1,“SSId”:“MEO-HRM”,“BSSId”:“00:06:91:4C:0D:40”,“Channel”:1,“RSSI”:100,“LinkCount”:1,“Downtime”:“0T00:00:04”}}
12:08:27 MQT: tele/sonoffTH/SENSOR = {“Time”:“2019-04-03T12:08:27”,“DHT11”:{“Temperature”:24.9,“Humidity”:37.0},“TempUnit”:“C”}

configuration from yaml file:

  • platform: mqtt
    state_topic: “tele/sonoffTH/SENSOR”
    name: "Temperatura Sala "
    icon: mdi:thermometer
    availability_topic: “tele/sonoffTH/SENSOR”
    unit_of_measurement: °C
    value_template: “{{ value_json[‘DHT11’].Temperature }}”
    payload_available: “Online”
    payload_not_available: “Offline”

  • platform: mqtt
    state_topic: “tele/sonoffTH/SENSOR”
    name: "Humidade Sala "
    icon: mdi:water-percent
    availability_topic: “tele/sonoffTH/SENSOR”
    value_template: “{{ value_json[‘DHT11’].Humidity }}”
    unit_of_measurement: ‘%’
    payload_available: “Online”
    payload_not_available: “Offline”

{{value_json.DHT11.Temperature}}

Replace with following code. Its working.

  - platform: mqtt
    name: "Bedroom Temperature"
    state_topic: "tele/testlamps/SENSOR"
    # Change testlamps with MQTT topic given in Tasmota Configuration/Configure MQTT WUI
    value_template: "{{ value_json['DHT11'].Temperature }}"
    # Change DHT11 with your actual sensor name like DHT22, AM2301 etc.
    unit_of_measurement: "°C"  # "F" if using Fahrenheit
    availability_topic: "tele/testlamps/LWT"
    # Change testlamps with MQTT topic given in Tasmota Configuration/Configure MQTT WUI
    payload_available: "Online"
    payload_not_available: "Offline"
    device_class: temperature  

Hit like if it worked for you !!! :slight_smile:

1 Like