I’ve set up my Raspberry to use a DHT22 sensor to get temperature and humidity.
I’ve configured MQTT integration in HA and tested send a message to MQTT and it shows up in MQTT Explorer.
Using MQTT Explorer I can see it is receiving the values from RPi:
But in HA values always show as 0
My Yaml is as follows:
sensor:
- platform: mqtt
name: "Temperatura Sala"
state_topic: "Sala/DHT22/sensor/temperatura_sala"
unit_of_measurement: "°C"
value_template: '{{ value_json.temperature }}'
- platform: mqtt
name: "Humidade Sala"
state_topic: "Sala/DHT22/sensor/humidade_sala"
unit_of_measurement: "%"
value_template: "{{ value_json.humidity }}"
What am I doing wrong here?
browetd
(Browet Didier)
August 14, 2022, 8:50pm
2
Try this:
sensor:
- platform: mqtt
name: "Temperatura Sala"
state_topic: "Sala/DHT22/sensor"
unit_of_measurement: "°C"
value_template: '{{ value_json.temperatura_sala }}'
- platform: mqtt
name: "Humidade Sala"
state_topic: "Sala/DHT22/sensor"
unit_of_measurement: "%"
value_template: "{{ value_json.humidade_sala }}"
Now instead of showing 0ºC and 0% , i shown Unknown in both…
browetd
(Browet Didier)
August 14, 2022, 8:56pm
4
My mistake, as I do not know MQTT Explorer and the format of those records… I installed it (thanks to you)…
Try this instead
sensor:
- platform: mqtt
name: "Temperatura Sala"
state_topic: "Sala/DHT22/sensor/temperatura_sala"
unit_of_measurement: "°C"
value_template: '{{ value_json }}'
- platform: mqtt
name: "Humidade Sala"
state_topic: "Sala/DHT22/sensor/humidade_sala"
unit_of_measurement: "%"
value_template: "{{ value_json }}"