Hi all,
The tldr; is that I have an MQTT sensor that simply isn’t updating, but I can’t for the life of me figure out why, or what to look at next.
THE SCENARIO
I have a Python script that I run on a particular host that, among other things, records the time it last ran in a specific topic. I have a corresponding sensor in HA that picks this up and displays it for me.
Until recently my MQTT server was running in a mosquitto docker image on a Raspberry Pi. A couple of weeks ago, I migrated a bunch of docker containers (including mosquitto) over to a beefier machine, in a different subnet (I have a few VLANs for various purposes).
Since then, this particular sensor has steadfastly refused to update. All other sensors that are subscribed to adjacent topics are still working just fine.
THE DETAILS
I have a sensor with the entity ID of sensor.internet_last_tested
, configured thusly:
- platform: mqtt
state_topic: "internet/lasttest"
force_update: true
name: 'Internet last tested'
NOTE: I only recently turned on force_update
to see if it would help. It didn’t.
MQTT is configured thusly:
mqtt:
broker: 192.168.254.15
port: 1883
Like I said, I have other topics adjacent to this. These topics are updated by the very same Python script (unchanged, except to point to the new MQTT server), and all sensors that depend on these other topics are updating just fine, but this particular sensor stubbornly refuses.
So, I turned on debug logging and ran some mosquitto_pub commands from the host that runs the Python script (another Raspberry Pi). This is where my confusion kicks into high gear.
I can see the updated topic is picked up by HA. I can see that it claims to update the sensor. But the state of the sensor is still false:
HA’s debug log tells me the following:
hass | 2020-08-19T07:15:14.002406553Z 2020-08-19 17:15:13 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on internet/lasttest: b'11:38 18-Aug-2021'
hass | 2020-08-19T07:15:14.005202747Z 2020-08-19 17:15:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.internet_last_tested, old_state=<state sensor.internet_last_tested=17:09 19-Aug-2020; friendly_name=Internet last tested @ 2020-08-19T17:14:26.756810+10:00>, new_state=<state sensor.internet_last_tested=11:38 18-Aug-2021; friendly_name=Internet last tested @ 2020-08-19T17:15:13.988074+10:00>>
hass | 2020-08-19T07:15:14.018599338Z 2020-08-19 17:15:14 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1872557008] Sending {'id': 14, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sensor.internet_last_tested, old_state=<state sensor.internet_last_tested=17:09 19-Aug-2020; friendly_name=Internet last tested @ 2020-08-19T17:14:26.756810+10:00>, new_state=<state sensor.internet_last_tested=11:38 18-Aug-2021; friendly_name=Internet last tested @ 2020-08-19T17:15:13.988074+10:00>>}
(NOTE: topic message is arbitrary text I sent in the command to make sure the value is actually changing
I’m all out of ideas on where to look next.
PLEASE HELP!