www-ShapeLabs-de / Judo-i-soft-save-plus-to-mqtt-bridge

A small device to write and read settings to Judo i-soft safe+ water softening system with homeassistant
MIT License
24 stars 8 forks source link

missing entries after mqtt broker restart #13

Closed LineF closed 12 months ago

LineF commented 12 months ago

When the mqtt broker restarts, afterwards in some sensor config entries the entries "device_class" and "state_class" are missing. After restarting getjudo.py the entries are available again.

I think the problem is that in procedure "entity()" the self.entity_type is being changed from "total_increasing" to "sensor". So after loosing mqtt connection and trying an reconnect there is no more entity with "total_increasing" and the entries get deleted.

A test showed me that after killing mosquitto and restarting it it would restore the retained entry correctly but after 1-2 secs they disappear. This only happens if getjudo.py is running between killing and restarting mosquitto.

Martin

www-ShapeLabs-de commented 12 months ago

Hello this may be related to the HA autoconfig/discovery principle. I do not see any need for action here. Probably this is rather a HA problem. Could it be that you also have a problem with your broker, if you seem to have to restart it regularly?

LineF commented 12 months ago

Hello, yes, this is for the HA autodiscovery. And - indeed - I discovered the problem with a faulty version of mosquitto, my mqtt broker.

In the meanwhile it is stable again, so the problem is not so urgent. But the problem will still araise if the mqtt broker is being updated and therefore being stopped/restarted. All retained mqtt entries (getjudo and other sources) come up as they were before the broker restart but then after a very short time (0-2 secs) when getjudo reconnects it drops the two entries.

It is not a HA problem. You can check the problem e.g. with MQTT Explorer (mqtt debugging tool). Connect it to your mqtt broker, start getjudo.py and then restart the broker. You will see that the entries state_class and device_class will disappear.

From my low developer sight i suspect that after the initial start of getjudo all entries are generated correctly. But in the code the entity_type is changed from total_increasing to sensor. Then after being disconnected by the broker shutdown and an automatic reconnect of getjudo the global variables still have the changed value "sensor". So these entries won't be regenerated correctly.

Greetings, Martin