Hi folks,
Still a bit of a newbie to Home Assistant and MQTT, but I had a number of sensors defined that were working OK up until I had to reboot the Pi that was feeding them in.
After the reboot of the Pi, all those sensors are stuck at “Unknown” despite the MQTT topic being published OK and I can see the data in MQTT Explorer, and the python script on the Pi that generates the data says it’s connected OK and is publishing.
I’ve obfuscated the MQTT user name and password in the sections below.
I’m running supervised HA on a Pi4, with the Mosquitto adding and integration both loaded and running.
Mosquitto broker is up and running and shows the Pi connecting OK
1611238861: New client connected from 192.168.1.100 as raspi-00000000b1b6694d (p2, c1, k60, u'mqttusernameremoved').
MQTT DATA showing in MQTT Explorer connected to HA
washingmachine = Idle
EnviroMonitor = {"Gas_Calibrated": false, "Bar": [987.2, "0"], "Hum": [34.9, "1"], "P2.5": 1, "P10": 1, "P1": 0, "Temp": 24.5, "Min Temp": 24.2, "Max Temp": 24.8, "Red": 0.09, "Oxi": 0.13, "NH3": 0.01, "Lux": 12.2}
Extract from SENSOR.YAML
# Enviromnent monitoring sensors from indoor monitoring station.
# These were working, but I had to reboot the Pi, and now all
# are showing "Unknown" in HA, despite the MQTT topic being present
# when I check in MQTT Explorer
#
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.P1 }}"
name: "enviro_pm1"
unit_of_measurement: 'µg/m3'
icon: "mdi:thought-bubble-outline"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.P10 }}"
name: "enviro_pm10"
unit_of_measurement: 'µg/m3'
icon: "mdi:thought-bubble-outline"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json['P2.5'] }}"
name: "enviro_pm2"
unit_of_measurement: 'µg/m3'
icon: "mdi:thought-bubble"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json['Hum'][0] }}"
name: "enviro_humidity"
unit_of_measurement: '%'
icon: "mdi:water-percent"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json['Bar'][0] }}"
name: "enviro_pressure"
unit_of_measurement: 'Bar'
icon: "mdi:arrow-down-bold"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.Temp }}"
name: "enviro_temperature"
unit_of_measurement: 'C'
icon: "mdi:thermometer"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.Lux }}"
name: "enviro_lux"
unit_of_measurement: 'lx'
icon: "mdi:weather-sunny"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.NH3 }}"
name: "enviro_nh3"
unit_of_measurement: 'ppm'
icon: "mdi:thought-bubble"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.Red }}"
name: "enviro_reduced"
unit_of_measurement: 'ppm'
icon: "mdi:thought-bubble"
- platform: mqtt
state_topic: "EnviroMonitor"
value_template: "{{ value_json.Oxi }}"
name: "enviro_oxidised"
unit_of_measurement: 'ppm'
icon: "mdi:thought-bubble"
# Washing Machine status (calculated in Node-RED and thrown out to MQTT), this
# is just the msg.payload from the calculations based on Amps used by washer.
# Works fine, sensor is populated with the text.
#
- platform: mqtt
state_topic: "washingmachine"
name: "Washing Machine Status"
icon: "mdi:washing-machine"
The MQTT Integration is loaded in HA and shows that it’s connected to “Mosquitto Core” as well as the MQTT Broker is showing in supervisor. Mosquitto Broker version is 5.1
Here’s my Mosquitto config from the add-on in Supervisor. (password and username removed)
logins:
- username: mqttusernameremoved
password: mqttpasswordremoved
anonymous: false
customize:
active: true
folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
And “Discovery” is enabled in the MQTT integration.
Frankly, I’m utterly stumped. I’ve tried rebooting the Pi, rebooting HA and the sensors in HA stay resolutely at “Unknown”. Can’t see anything in the Supervisor log or Core log (under system in HA) that says there’s an MQTT error; and most weirdly the washing machine MQTT sensors is fine; which implies that HA is able to pickup data out of MQTT.
Also, just to check that something running on the HA Pi can see the relevant MQTT Topic, if I use an MQTT-in node in Node-Red and dump it to the Debug window, it shows the MQTT data is present as well in the relevant topic.
I’ve had a look through several of the MQTT topics here, but they don’t seem to match up with this issue where MQTT sensors were working, but now are stuck “Unknown” after a reboot of the data source.
(Also weirdly, I’m also running OpenZwave on HA as I have some Zwave devices, and I used to see a topic “OpenZWave” in MQTT Explorer, but I don’t see that anymore. Zwave devices are working fine.)
Anyone got any advice?
Many thanks in advance!
Dave





