core
core copied to clipboard
Add device cleanup button to Vodafone Station
Breaking change
Proposed change
Add Device cleanup button to remove state entities no more available in the router itself.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] 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
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
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) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] 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.
- [ ] Untested files have been added to
.coveragerc.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Hey there @paoloantinori, mind taking a look at this pull request as it has been labeled with an integration (vodafone_station) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of vodafone_station can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign vodafone_stationRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Interesting approach!
But, are you aware of this? https://developers.home-assistant.io/docs/device_registry_index/#removing-devices
I'm thinking about doing something similar for the Plugwise integration and did some research. I came to the conclusion that it doesn't make sense to clean the entity-registry, this is done automatically is my impression. Cleaning the device-registry is a good thing, looks like there are two options:
- clean during init, after a restart
- let the User delete a removed device manually, via the
async_remove_config_entry_device()function, resulting in a Delete-button showing up in HA after the device has been removed.
If anyone else cares to share their thoughts/ideas/feedback (HA devs!) on this topic, that would be appreciated :)
Hi, I implemented the same approach I used in fritz.
Device trackers are entities, and if they don't attach to a device, then also the device is created. This code take care of cleanup both things.
entity entries will not be deleted automatically, more over the user can manually delete them as soon as they are not provided by integration anymore.
this "entity registry cleanup" could also be done by the integration itself, either by an own service/button (like @chemelli74 is doing here and has done in fritz integration) or automatically by the integration based on a detection mechanism of no more existing real devices (as lately done in #114573 and #114601) - finally this cleanup has to remove the config entry from the device eq. device_reg.async_update_device(device.id, remove_config_entry_id=config_entry.entry_id)
@mib1185 Thanks for your feedback, and for providing examples :)
I'm also thinking of implementing the opposite: when a new device is added, how would I go about adding this device? Is it possible to do this without an integration-reload?
Sorry @chemelli74 for hijacking your PR!
- @bouwew checkout #103859 😉
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!
Why don't we apply something like described here? https://github.com/home-assistant/developers.home-assistant/pull/2386/files
Merged in dev since this PR is a bit behind to make sure merging it won't cause any lint issues