-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Add Libre Hardware Monitor integration #140449
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
base: dev
Are you sure you want to change the base?
Add Libre Hardware Monitor integration #140449
Conversation
3cf04fc
to
457ff11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few things you have to consider for a new integration. First of all, the PR scope has to be kept small. Only implement the user config flow, the reconfigure flow can be added in a follow-up PR.
Also variable/configurable scan interval is not allowed in core integrations.
Hi @tr4nt0r thanks for the feedback. Regarding the reconfigure flow: sure I can take this out and submit it in a follow-up PR. Regarding the configurable scan interval: could you point me to the developer docs where it is outlined that it cannot be configurable? I found the custom polling interval docs before, but it does not really say that a configurable scan interval is disallowed. |
457ff11
to
c1f6f18
Compare
Please note that someone is taking on the work on open hardware monitor and there's a PR for that at the moment. Is the API of both applications the same? |
Hi @joostlek Here's my thought process when I started working on implementing this integration from scratch:
After a quick look at the other PR for
Regarding the API, Libre Hardware Monitor seems to be backwards compatible, which is why the current |
I am also not saying which one is better, PRs should be well scoped, so I don't think comparing PRs is fair here, as new integrations are always bigger and contain more feature than an integration that is trying to modernize. |
cc @LazyTarget just as an FYI. We just discussed this in the architecture meeting, and we think its fine to have them co-exist. |
Glad to hear that, thanks for clarifying and sorry for the hassle. If someone could give me a quick hint why the tests on the CI are complaining about missing |
They are not optional for the quality_scale rule :) |
c1f6f18
to
c5f5867
Compare
What ARE the odds?! 😄 Cool to see that we both identify the need for an update, and interesting to see our different takes (even not all to different) |
@joostlek |
With the migration to the UI we should import the YAML config and that is an expected breaking change |
Yep, I guess it really was time to finally update this as LHM is such a nice tool and the legacy integration was increasingly becoming a pain point. |
5c0c784
to
259f931
Compare
There were a couple of code coverage warnings which are now resolved, so this is now ready for review. |
259f931
to
babf625
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like mentioned in the other comment, In my case Libre Open Hardware Monitor is not able to get any sensors from my motherboard, which failed the startup.
Everything else looks and works great, truly good job!
* add mock_config_entry fixture * combine error config flow tests * remove unnecessary config flow test
bb84471
to
8bb9cc5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new integration for Libre Hardware Monitor to replace the legacy Open Hardware Monitor integration. The changes include implementing a config flow with proper error handling, rebuilding the coordinator and sensor entities for improved robustness and maintainability, and adding comprehensive tests and dependency updates to support quality scale silver.
Reviewed Changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/components/librehardwaremonitor/test_sensor.py | Tests for sensor creation, update, and handling of missing data. |
tests/components/librehardwaremonitor/test_coordinator.py | Tests for coordinator error handling, data refresh, and orphaned device removal. |
tests/components/librehardwaremonitor/test_config_flow.py | Tests for proper error messaging and flow recovery in the config flow. |
tests/components/librehardwaremonitor/conftest.py | Common fixtures and sample data for the Libre Hardware Monitor tests. |
tests/components/librehardwaremonitor/snapshots/* | Snapshot tests ensuring sensor state consistency. |
requirements_test_all.txt / requirements_all.txt | Dependency updates to include the librehardwaremonitor-api package. |
mypy.ini | Updated mypy configuration for the new integration. |
homeassistant/components/librehardwaremonitor/sensor.py | Implementation of sensor entities with formatted numeric values. |
homeassistant/components/librehardwaremonitor/coordinator.py | Coordinator that fetches data and handles device changes, including orphan device removal. |
homeassistant/components/librehardwaremonitor/config_flow.py | Config flow implementation with error handling for connectivity and missing devices. |
homeassistant/components/librehardwaremonitor/manifest.json, quality_scale.yaml, etc. | Integration metadata and quality scale configuration. |
DeviceId(next(iter(device.identifiers))[1]): DeviceName(device.name) | ||
for device in device_entries | ||
if device.identifiers and device.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more robust approach to extract the identifier by filtering the identifiers for the one associated with the integration rather than using next(iter(...)) directly, which may be error-prone if multiple identifiers are present.
DeviceId(next(iter(device.identifiers))[1]): DeviceName(device.name) | |
for device in device_entries | |
if device.identifiers and device.name | |
DeviceId( | |
identifier[1] | |
): DeviceName(device.name) | |
for device in device_entries | |
if device.identifiers and device.name | |
for identifier in device.identifiers | |
if identifier[0] == DOMAIN |
Copilot uses AI. Check for mistakes.
Proposed change
The current Open Hardware Monitor legacy integration is for a software that has not been updated in more than 4 years. It's successor is Libre Hardware Monitor.
While the legacy integration technically also works for Libre Hardware Monitor, it has many issues and is not maintained.
This integration has been rewritten from scratch following the best practices from the current developer docs, providing:
configurable scan intervaladd only user selected hardware devicesreconfigure anytime via UI reconfigure flowIn my opinion, we should deprecate the legacy integration and redirect users to this one.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: