core
core copied to clipboard
Add integration for Belgian weather provider meteo.be
Proposed change
This PR adds an integration to support the Royal Meteorological Institute of Belgium as a weather provider. The code is from a custom component I wrote: https://github.com/jdejaegh/irm-kmi-ha
This implementation only contains code for the weather platform to keep the PR as small as possible. I plan to submit subsequent PR once this one is merged. The goal is to reach the same features as in the custom component.
Code is documented with doc string, comments and tested with 17 unit tests. I'll look at how to add documentation for users in the coming days and open a PR for that as well.
This is my first contribution to Home Assistant Core so please point to resources I may have missed :slightly_smiling_face:
Note about the +7,677 lines: this is not all Python code, most of it are JSON test fixtures. There are 838 lines of actual component code and 613 lines of tests.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [X] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
- Link to documentation pull request: home-assistant/home-assistant.io#38978
- Link to dependency: https://github.com/jdejaegh/irm-kmi-api
- Link to custom component: https://github.com/jdejaegh/irm-kmi-ha
Checklist
- [X] The code change is tested and works locally.
- [X] Local tests pass. Your PR cannot be merged unless tests pass
- [X] There is no commented out code in this PR.
- [X] I have followed the development checklist
- [X] I have followed the perfect PR recommendations
- [X] The code has been formatted using Ruff (
ruff format homeassistant tests) - [X] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [X] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [X] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Bronze quality scale check-list
- [X]
action-setup- Service actions are registered in async_setup. No actions are registered - [X]
appropriate-polling- If it's a polling integration, set an appropriate polling interval. 7 minutes interval https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/coordinator.py#L43 - [X]
brands- Has branding assets available for the integration. https://github.com/home-assistant/brands/pull/5017 - [X]
common-modules- Place common patterns in common modules. - [X]
config-flow-test-coverage- Full test coverage for the config flow.
Show coverage report as of commit 04c50331514da7d63bb62240cfd5d4e72eabc31c
---------- coverage: platform linux, python 3.13.3-final-0 -----------
Name Stmts Miss Cover Missing
-------------------------------------------------------------------------------
homeassistant/components/irm_kmi/__init__.py 20 1 95% 24
homeassistant/components/irm_kmi/config_flow.py 50 0 100%
homeassistant/components/irm_kmi/const.py 17 0 100%
homeassistant/components/irm_kmi/coordinator.py 48 2 96% 84-88
homeassistant/components/irm_kmi/data.py 8 0 100%
homeassistant/components/irm_kmi/repairs.py 51 2 96% 56, 61
homeassistant/components/irm_kmi/types.py 14 0 100%
homeassistant/components/irm_kmi/utils.py 25 4 84% 24, 39, 49, 62
homeassistant/components/irm_kmi/weather.py 84 7 92% 103, 130, 136, 145-151, 157
-------------------------------------------------------------------------------
TOTAL 317 16 95%
Results (3.13s):
17 passed
- [X]
config-flow- Integration needs to be able to be set up via the UI- [X] Uses
data_descriptionto give context to fields. https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/strings.json#L18-L21 https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/strings.json#L55-L57 - [X] Uses
ConfigEntry.dataandConfigEntry.optionscorrectly.ConfigEntry.datais for initial configuration flow andConfigEntry.optionsis when the users modifies the options after first setup. The relevant data is accessed properly https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/utils.py#L45-L50
- [X] Uses
- [X]
dependency-transparency- Dependency transparency. MIT License, hosted on PyPI https://github.com/jdejaegh/irm-kmi-api - [X]
docs-actions- The documentation describes the provided service actions that can be used. Only provides common weather actions, but documentation links to those See this PR for all docs related items https://github.com/home-assistant/home-assistant.io/pull/38978 - [X]
docs-high-level-description- The documentation includes a high-level description of the integration brand, product, or service - [X]
docs-installation-instructions- The documentation provides step-by-step installation instructions for the integration, including, if needed, prerequisites - [X]
docs-removal-instructions- The documentation provides removal instructions - [X]
entity-event-setup- Entity events are subscribed in the correct lifecycle methods. No entity subscribe to event - [X]
entity-unique-id- Entities have a unique ID. Yes, unique is derived from the zone name which is unique https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/config_flow.py#L79 https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/weather.py#L48 - [X]
has-entity-name- Entities use has_entity_name = True https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/weather.py#L40 - [X]
runtime-data- Use ConfigEntry.runtime_data to store runtime data. Coordinator and API client are stored there https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/types.py#L15-L21 https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/init.py#L17 - [X]
test-before-configure- Test a connection in the config flow. https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/config_flow.py#L61-L73 - [X]
test-before-setup- Check during integration initialization if we are able to set it up correctly. https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/init.py#L19-L24 - [X]
unique-config-entry- Don't allow the same device or service to be able to be set up twice. A zone can only be configured once. It will abort as the zone is used for unique id https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/config_flow.py#L79-L80
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
Quality scale check-list
Bronze
- [X]
action-setup- Service actions are registered in async_setup. No actions are registered - [X]
appropriate-polling- If it's a polling integration, set an appropriate polling interval. 7 minutes interval https://github.com/home-assistant/core/blob/04c50331514da7d63bb62240cfd5d4e72eabc31c/homeassistant/components/irm_kmi/coordinator.py#L43 - [X]
brands- Has branding assets available for the integration. https://github.com/home-assistant/brands/pull/5017 - [X]
common-modules- Place common patterns in common modules. - [X]
config-flow-test-coverage- Full test coverage for the config flow.
Show coverage report as of commit 87450bc487c933501d040376762f1ba19211e3c7
= tests coverage =
_ coverage: platform linux, python 3.13.7-final-0 _
Name Stmts Miss Cover Missing
-------------------------------------------------------------------------------
homeassistant/components/irm_kmi/__init__.py 17 1 94% 40
homeassistant/components/irm_kmi/config_flow.py 47 0 100%
homeassistant/components/irm_kmi/const.py 12 0 100%
homeassistant/components/irm_kmi/coordinator.py 32 2 94% 70-74
homeassistant/components/irm_kmi/data.py 9 0 100%
homeassistant/components/irm_kmi/entity.py 12 0 100%
homeassistant/components/irm_kmi/utils.py 7 1 86% 16
homeassistant/components/irm_kmi/weather.py 63 5 92% 106, 119-125, 131
-------------------------------------------------------------------------------
TOTAL 199 9 95%
Results (1.29s):
10 passed
- [X]
config-flow- Integration needs to be able to be set up via the UI- [X] Uses
data_descriptionto give context to fields. - [X] Uses
ConfigEntry.dataandConfigEntry.optionscorrectly.
- [X] Uses
- [X]
dependency-transparency- Dependency transparency. MIT License, hosted on PyPI https://github.com/jdejaegh/irm-kmi-api - [X]
docs-actions- The documentation describes the provided service actions that can be used. Only provides common weather actions, but documentation links to those See this PR for all docs related items https://github.com/home-assistant/home-assistant.io/pull/38978 - [X]
docs-high-level-description- The documentation includes a high-level description of the integration brand, product, or service - [X]
docs-installation-instructions- The documentation provides step-by-step installation instructions for the integration, including, if needed, prerequisites - [X]
docs-removal-instructions- The documentation provides removal instructions - [X]
entity-event-setup- Entity events are subscribed in the correct lifecycle methods. No entity subscribe to event - [X]
entity-unique-id- Entities have a unique ID. Yes, unique id is derived from the city and country. Integration cannot be setup twice for the same location - [X]
has-entity-name- Entities use has_entity_name = True https://github.com/home-assistant/core/blob/87450bc487c933501d040376762f1ba19211e3c7/homeassistant/components/irm_kmi/entity.py#L17 - [X]
runtime-data- Use ConfigEntry.runtime_data to store runtime data. Coordinator is stored there https://github.com/home-assistant/core/blob/87450bc487c933501d040376762f1ba19211e3c7/homeassistant/components/irm_kmi/init.py#L24 - [X]
test-before-configure- Test a connection in the config flow. https://github.com/home-assistant/core/blob/87450bc487c933501d040376762f1ba19211e3c7/homeassistant/components/irm_kmi/config_flow.py#L67-L76 - [X]
test-before-setup- Check during integration initialization if we are able to set it up correctly. - [X]
unique-config-entry- Don't allow the same device or service to be able to be set up twice. A location can only be configured once. It will abort as the location is used for unique id https://github.com/home-assistant/core/blob/87450bc487c933501d040376762f1ba19211e3c7/homeassistant/components/irm_kmi/config_flow.py#L84-L86
Silver
- [X]
action-exceptions- Service actions raise exceptions when encountering failures No actions are registered - [X]
config-entry-unloading- Support config entry unloading Done https://github.com/home-assistant/core/blob/87450bc487c933501d040376762f1ba19211e3c7/homeassistant/components/irm_kmi/init.py#L33-L35 - [X]
docs-configuration-parameters- The documentation describes all integration configuration options https://github.com/home-assistant/home-assistant.io/pull/38978 - [X]
docs-installation-parameters- The documentation describes all integration installation parameters - [x]
entity-unavailable- Mark entity unavailable if appropriate https://github.com/home-assistant/core/blob/4e9351ae2340afd4ddb791dc6e0845b49431e8a3/homeassistant/components/irm_kmi/weather.py#L56-L59 - [X]
integration-owner- Has an integration owner @jdejaegh - [x]
log-when-unavailable- If internet/device/service is unavailable, log once when unavailable and once when back connected https://github.com/home-assistant/core/blob/4e9351ae2340afd4ddb791dc6e0845b49431e8a3/homeassistant/components/irm_kmi/coordinator.py#L72-L81 - [x]
parallel-updates- Number of parallel updates is specified - [X]
reauthentication-flow- Reauthentication needs to be available via the UI There is no authentication for this integration - [ ]
test-coverage- Above 95% test coverage for all integration modules
Gold
- [X]
devices- The integration creates devices Device info is added as part of the BaseEntity class https://github.com/home-assistant/core/blob/8ece5680f243ce0a20e75b20d3e68cd3e82e07b7/homeassistant/components/irm_kmi/entity.py#L18-L28 - [ ]
diagnostics- Implements diagnostics - [X]
discovery-update-info- Integration uses discovery info to update network information Exempt: The integration does not look for devices on the network. It uses an online API. - [X]
discovery- Devices can be discovered Same as previous - [X]
docs-data-update- The documentation describes how data is updated. Done https://github.com/home-assistant/home-assistant.io/pull/38978 - [ ]
docs-examples- The documentation provides automation examples the user can use. - [X]
docs-known-limitations- The documentation describes known limitations of the integration (not to be confused with bugs) Mentioned in the documentation https://github.com/home-assistant/home-assistant.io/pull/38978 - [X]
docs-supported-devices- The documentation describes known supported / unsupported devices Exempt: This rule also does not apply to integrations that don't integrate physical devices. - [X]
docs-supported-functions- The documentation describes the supported functionality, including entities, and platforms Done https://github.com/home-assistant/home-assistant.io/pull/38978 - [ ]
docs-troubleshooting- The documentation provides troubleshooting information - [X]
docs-use-cases- The documentation describes use cases to illustrate how this integration can be used Seems clear from the first sentence of the documentation - [X]
dynamic-devices- Devices added after integration setup - [ ]
entity-category- Entities are assigned an appropriate EntityCategory Current entity does not have a category. Leaving todo as I plan to implement more entities in future PRs. - [ ]
entity-device-class- Entities use device classes where possible Only weather entity currently. Leaving todo as I plan to implement more entities in future PRs. - [ ]
entity-disabled-by-default- Integration disables less popular (or noisy) entities - [ ]
entity-translations- Entities have translated names - [ ]
exception-translations- Exception messages are translatable - [ ]
icon-translations- Entities implement icon translations - [X]
reconfiguration-flow- Integrations should have a reconfigure flow Exempt: there is no configuration per se, just a zone to pick - [X]
repair-issues- Repair issues and repair flows are used when user intervention is needed There are no repairs implemented - [X]
stale-devices- Stale devices are removed Device cannot become stale
Platinum
- [X]
async-dependency- Dependency is asyncirm-kmi-apiuses async functions where possible (namely, http requests with aiohttp) - [X]
inject-websession- The integration dependency supports passing in a websessionirm-kmi-apiuses aiohttp for requests and need a client to provided when creating an instance of the API client https://github.com/home-assistant/core/blob/8ece5680f243ce0a20e75b20d3e68cd3e82e07b7/homeassistant/components/irm_kmi/init.py#L19-L25 - [ ]
strict-typing- Strict typing
Requested changes were addressed: either implementing the suggested change (and marking conversation as resolved) or explaining the decision. I left 2 conversations as unresolved with a comment: reviewer's opinion on those two is welcome.
PR is ready for review
Implementing configuration flow using latitude and longitude instead of a zone to simplify the code (https://github.com/home-assistant/core/pull/144689#discussion_r2103175608). Converted to draft until this is done Edit: done in commit 1ea8bb0
Implementing configuration flow using latitude and longitude instead of a zone to simplify the code (#144689 (comment)). Converted to draft until this is done Edit: done in commit 1ea8bb0
I can't wait for this shiny custom integration to get accepted into core. Thank you for making the changes!
Done the following:
- Rebased to match
home-assistant/core/dev - Addressed reviewers' comments (thanks for your reviews)
- Updated documentation PR https://github.com/home-assistant/home-assistant.io/pull/38978
The PR is ready for review
Updated the code based on the comments and replied to the questions. I marked as resolved all the comments I addressed. I left one comment open because reviewer's input would be appreciated.
The PR has been rebased on the dev branch after committing the changes.
Thanks to the reviewers for their comments and time :)
Thanks for the comments
I addressed the comments and closed them when fully addressed. Two discussions are still open and feedback is welcome:
- https://github.com/home-assistant/core/pull/144689#discussion_r2267609906 about what to do if current weather were to go missing
- https://github.com/home-assistant/core/pull/144689#discussion_r2267710655 about language selector. Given the feedback, I would stick with the current implementation and names in English in
strings.json
This PR is ready for review
Double check this one btw https://github.com/home-assistant/core/pull/144689#discussion_r2267451906
Thanks for the comments. Here is a summary of the changes:
- I addressed the comments and updated the code accordingly
- I checked the quality scale and updated the criteria if needed (in the YAML file and here https://github.com/home-assistant/core/pull/144689#issuecomment-2892175369)
- I rebased this branch on core/dev
I have been a bit busy offline in past few weeks, hence the delay before I could look into the PR.
I'll also have a look at the documentation PR to see if everything is up-to-date with the latest changes.
This PR is ready for review
CI is failing on dev
I think there is some incorrect mocking https://github.com/home-assistant/core/actions/runs/17942073838/job/51021452752?pr=152805
CI is failing on dev
I think there is some incorrect mocking https://github.com/home-assistant/core/actions/runs/17942073838/job/51021452752?pr=152805
#152812 Fixes the issue