Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/improve support for Glances v4 container & network format and improve v4 unit tests #42

Merged

Conversation

wittypluck
Copy link
Contributor

@wittypluck wittypluck commented Jun 3, 2024

This PR adds support for the Glances v4 container format change, while retaining compatibility with earlier versions of HA.
=> Fixes issue #41

The PR also addresses another issue in Glances v4, where Glances sends an incomplete network sensor when the module is disabled. The code was reworked to be more robust when Glances sends incomplete data.

Finally the PR adds dedicated unit tests for v4 data (parametrized test for get_ha_sensor_data).

Related HA issue : home-assistant/core#118632
Related Glances issue : nicolargo/glances#2815

As there are now 3 different formats of API for the containers, I have opted for a test on the Glances version rather than looking for the various possibilities.

To sum up the formats :

  • 3.3 and before: section is called "dockers", data provided in a dict with an embedded list under the key "containers"
  • 3.4: section is called "containers", data provided in a dict with an embedded list under the key "containers"
  • 4.0: section is called "containers", data provided in a list

@wittypluck wittypluck marked this pull request as ready for review June 7, 2024 08:22
@wittypluck wittypluck marked this pull request as draft June 7, 2024 09:35
@wittypluck wittypluck changed the title Add support for Glances v4 container format Add/improve support for Glances v4 container & network format and improve v4 unit tests Jun 7, 2024
@wittypluck wittypluck marked this pull request as ready for review June 7, 2024 09:56
@wittypluck
Copy link
Contributor Author

Hello @fabaff,
I think this PR addresses all the issues raised until now on Glances v4 in Home Assistant.
Let me know if you have any comments, and if you can package an updated version of the library.
Thanks !

Copy link
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

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

Thanks a lot for all the work.

@fabaff fabaff merged commit 8dfaaf9 into home-assistant-ecosystem:master Jun 9, 2024
2 checks passed
@wittypluck
Copy link
Contributor Author

Thank you !

@wittypluck wittypluck deleted the glances-v4-containers branch July 24, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants