I’ve been banging my head on this one for a few hours now. I set up my weather station (CumulusMX) to send updates via MQTT, and have set up a MQTT sensor in HA to read it. Frustratingly, this worked fine for about an hour after I set it up, but now the sensor values are all “unknown”.
For the purposes of troubleshooting, I’ve pared it down to one sensor in my mqtt.yaml file, which is called from the main configuration.yaml thus:
mqtt: !include mqtt.yaml
mqtt.yaml:
sensor:
- name: "Weather_Station_Temp"
state_topic: "sensor/cumulusmx/interval"
value_template: "{{ value_json['temp'] }}"
unit_of_measurement: "c"
The MQTT topic at sensor/cumulusmx/interval is:
{
"time":"17:45:10",
"temp":17.6,
"tempchange":+0.1,
"heatindex":17.6,
"solarrad":148,
"uv":0.6,
"feelslike":17.1,
"humidity":94,
"inhum":55,
"raintoday":2.8,
"rainrate":0.0,
"rainlasthr":0.2,
"rainlst24":3.8,
"rainmnth":47.4,
"rainyear":1427.4,
"drydays":0,
"pressure":1004.7,
"pressuretrendval":0.1,
"pressuretrend3hr":0.3,
"windspeed":3.6,
"windgust":7.2,
"windcardinal":WSW
}
Note - the exact values don’t match between the above and the debug log below because I sampled them at different times. The MQTT integration is seeing the topic update every 5 seconds though, with the current data.
The MQTT debug log shows:
2024-08-08 17:33:30.412 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on sensor/cumulusmx/interval (qos=0): b'{\n "time":"17:33:30",\n "temp":17.6,\n "tempchange":-0.2,\n "heatindex":17.6,\n "solarrad":165,\n "uv":0.7,\n "feelslike":17.1,\n "humidity":94,\n "inhum":55,\n "raintoday":2.8,\n "rainrate":0.0,\n "rainlasthr":0.2,\n "rainlst24":3.8,\n "rainmnth":47.4,\n "rainyear":1427.4,\n "drydays":0,\n "pressure":1004.5,\n "pressuretrendval":0.0,\n "pressuretrend3hr":0.1,\n "windspeed":3.6,\n "windgust":7.2,\n\t\t "windcardinal":WSW \n }'
2024-08-08 17:33:30.413 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{
"time":"17:33:30",
"temp":17.6,
"tempchange":-0.2,
"heatindex":17.6,
"solarrad":165,
"uv":0.7,
"feelslike":17.1,
"humidity":94,
"inhum":55,
"raintoday":2.8,
"rainrate":0.0,
"rainlasthr":0.2,
"rainlst24":3.8,
"rainmnth":47.4,
"rainyear":1427.4,
"drydays":0,
"pressure":1004.5,
"pressuretrendval":0.0,
"pressuretrend3hr":0.1,
"windspeed":3.6,
"windgust":7.2,
"windcardinal":WSW
}' with variables {'entity_id': 'sensor.weather_station_temp', 'name': 'Weather_Station_Temp', 'this': <template TemplateStateFromEntityId(sensor.weather_station_temp)>} with default value 'default' and Template<template=({{ value_json['temp'] }}) renders=8>
… and yet the sensor continually shows ‘Unknown’ in HA proper.
I’m tearing my hair out - any words of advice? The worst part is that it WAS working and appeared to break for no reason.
Cheers,
Peter