Mosquitto, MQTT & Watermeter via AI on the Edge

Hi folks,

While the whole area of MQTT is super new to me I managed to set up an “AI on the edge ESP32” to read my watermeter and send data via MQTT to HomeAssistant.
(Using the latest Mosquitto broker from the Add-On store and the MQTT Service which discovered the watermeter successfully then)
So far everything is basically running as expected.

Whats confusing and nagging though is, that after a restart of the watermeter-device the same turns into “unavailable” in HA.

Based on the Mosquitto Logs something still seems to be going on when the device is coming up again:

2026-01-11 06:54:36: Client watermeter disconnected.
2026-01-11 06:54:55: New connection from 192.168.245.217:61378 on port 1883.
2026-01-11 06:54:55: New client connected from 192.168.245.217:61378 as watermeter (p2, c1, k450, u'HA_MQTT').
2026-01-11 06:55:49: New connection from 192.168.245.217:61380 on port 1883.
2026-01-11 06:55:49: Client watermeter already connected, closing old connection.

This situation persists until I reboot the HA machine completely (not tested if restarting HA only would do the job - restarting Mosquitto only didnt seem to help though)

After the reboot everything works well again.
The only information around the watermeter that is then showing up in the Mosquitto log is:

2026-01-11 07:03:33: New connection from 192.168.245.217:51455 on port 1883.
2026-01-11 07:03:34: New client connected from 192.168.245.217:51455 as watermeter (p2, c1, k450, u'HA_MQTT').

Nevertheless I would love if a restart of the watermeter-device wouldnt cause this situation.
Especially while fine-tuning AI on the edge restarts are required pretty often, so having to reboot HA then as well is pretty cumbersome…

Does anyone have an idea how to address this?

Thanks a lot in advance!

You might need to add a retain flag in the correct place.

I have the exact same line in my log - but the watermeter reconnects without problems.

Sometimes it takes 5 minutes (until the watermeter takes a new snapshot) before I get a valid read-out, but that is about it.

I agree with Sir Goodenough - use the retain messages option in the watermeter settings:

Thanks a lot for the feedback and input!

Seems I was really simply not patient enough - when I do wait for about 10-15 minutes things settle again and start to work.
Waiting for one new transmission (usually all 3 minutes, but not so sure anymore if thats really a good idea :thinking:) doesnt do the job - but usually thats not critical… :slightly_smiling_face:

Thanks again!