littleyoda / Home-Assistant-Tripower-X-MQTT

Script which reads out the current measured values of an inverter of the SMA Tripower x (STP XX-50) series and makes them available via MQTT Home Assistant.
The Unlicense
10 stars 3 forks source link

no mqtt updates after some time #3

Open littleyoda opened 1 year ago

littleyoda commented 1 year ago

for documentation:

the library ha-mqtt-discoverable does not send updates to Home Assistant after some time. It seems that the mqtt connection has been interrupted and the library does not reconnect.

As a needed feature is missing in the current version of ha-mqtt-discoverable, Version 0.4.1 is still needed. So a test with the current version is not possible

see https://github.com/unixorn/ha-mqtt-discoverable/issues/84

miquelbeltran commented 1 year ago

I noticed this as well, so I modified the script to run it every minute using a cron job rather than having it running in a continuous loop. Running the script every minute seems to work for me, link to my fork: https://github.com/miquelbeltran/Home-Assistant-Tripower-X-MQTT

Notice that I do a for in range(2) because I need to loop at least twice for all the info to be reported correctly, I am not sure if that's an issue with the ha-mqtt-discoverable library. I've thought about migrating to a more recent version but it was too much work.

littleyoda commented 1 year ago

Thanks for the changes. I integrated some of them.

2 loops: Based on our idea, I added a "ExitAfter" Parameter to the yaml-File. ExitAfter: 2

no updates: when the update stops, I receive debug messages of this kind

state publication results: (4, 7240)
state publication results: (4, 7241)
state publication results: (4, 7242)
state publication results: (4, 7243)

(0 has been changed to 4)

According to the source code, there are the return values from the mqtt library

                pub = self.mqtt_client.publish(
                    config_topic, config_message, retain=True
                )
                logging.debug(f"state publication results: {pub}")
                self.configured[metric_config] = True

And from the paho-mqtt-library client.py:MQTT_ERR_NO_CONN = 4

I assume a reconnect or similar is missing.

But I don't want to debug the old versions of the ha-mqtt-discoverable library. But also I cannot use the current version, because of the missing feature. hope that the developers of ha-mqtt-discoverable will add the removed feature back.