Skip to content

Conversation

@Endymion78
Copy link
Contributor

@Endymion78 Endymion78 commented Dec 16, 2025

Previously, linux2mqtt stopped if MQTT broker was unavailable on startup.
Also, metrics online statuses were sent on first connection to MQTT broker only, so metrics stayed offline in case of broker restart.

This proposal modifies the code to avoid stopping execution if connection to the MQTT broker can't be established on startup and to send online statuses when establishing connection.

Discovery topics are also modified so each metric availability depends on the metric status and linuxmqtt status and to add
linux and linux2mqtt versions to device in discovery topics.

Troubleshooting is made easier by adding optional logging to directory with --logdir command line parameter and improving MQTT connection events logging

@github-actions github-actions bot added the 📖 documentation Improvements or additions to documentation label Dec 16, 2025
@Endymion78 Endymion78 marked this pull request as ready for review December 16, 2025 13:35
@miaucl miaucl self-requested a review December 23, 2025 21:13
Copy link
Owner

@miaucl miaucl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, this looks like quite some improvements. I admit, I also had some issues with it but nothing to annoying to motivate me to go over it. Appreciate your effort and I will surely test it but it looks already quite nice. There are just two minor details open.

  • typo
  • the mypy workflow seems to have a problem with the mqtt library callback version

@github-actions github-actions bot added the ♻️ dependencies Pull requests that update a dependency file label Dec 24, 2025
@Endymion78
Copy link
Contributor Author

Hi, thanks for your comments.
I fixed the typo.
I also solved the mypy workflow's error by removing types-paho-mqtt from requirements_dev.txt as it is outdated and type annotations or type stubs are included in paho-mqtt package V2.0.0 or newer (cf https://pypi.org/project/types-paho-mqtt/1.6.0.20240321/, description page).
Waiting for your feedback, I wish you a merry Christmas !

@miaucl
Copy link
Owner

miaucl commented Dec 24, 2025

Hi, thanks for your comments.

I fixed the typo.

I also solved the mypy workflow's error by removing types-paho-mqtt from requirements_dev.txt as it is outdated and type annotations or type stubs are included in paho-mqtt package V2.0.0 or newer (cf https://pypi.org/project/types-paho-mqtt/1.6.0.20240321/, description page).

Waiting for your feedback, I wish you a merry Christmas !

Thx, you too :)

Did not know they are outdated. Good to know as i will have to Patch my other libs as well.

Will test it in the following days but looks good👍

@miaucl miaucl self-requested a review December 31, 2025 22:18
@miaucl miaucl force-pushed the handle-mqtt-reconnection branch from 20b14a7 to 987e685 Compare January 1, 2026 16:30
@miaucl
Copy link
Owner

miaucl commented Jan 1, 2026

Had to fix another problem first #82 and rebased your PR afterwards. It will also be >=3.12 from here on, as psutil changes quite significantly between the versions.

@Endymion78 Could you please verify again on your side as well that everything still works as you intend?

Copy link
Owner

@miaucl miaucl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builds and runs on my test setup!

@Endymion78
Copy link
Contributor Author

I confirm that everything is OK on my end as well.

@miaucl miaucl merged commit affdd4c into miaucl:master Jan 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖 documentation Improvements or additions to documentation ♻️ dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants