Skip to content

Add device cleanup to Vodafone Station#116024

Merged
chemelli74 merged 31 commits into
home-assistant:devfrom
chemelli74:chemelli74-vodafone-cleanup
Feb 3, 2025
Merged

Add device cleanup to Vodafone Station#116024
chemelli74 merged 31 commits into
home-assistant:devfrom
chemelli74:chemelli74-vodafone-cleanup

Conversation

@chemelli74
Copy link
Copy Markdown
Contributor

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!)
  • 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

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • 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:

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 running python3 -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:

@home-assistant
Copy link
Copy Markdown
Contributor

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 close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign vodafone_station Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@bouwew
Copy link
Copy Markdown
Contributor

bouwew commented Apr 23, 2024

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 :)

@chemelli74
Copy link
Copy Markdown
Contributor Author

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.

@mib1185
Copy link
Copy Markdown
Member

mib1185 commented Apr 24, 2024

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)

@bouwew
Copy link
Copy Markdown
Contributor

bouwew commented Apr 24, 2024

@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!

@mib1185
Copy link
Copy Markdown
Member

mib1185 commented Apr 24, 2024

@chemelli74 chemelli74 requested a review from mib1185 May 8, 2024 08:47
Copy link
Copy Markdown
Member

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

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

Hi @chemelli74
sorry delayed response - there are just some small comments from my side

Comment thread homeassistant/components/vodafone_station/coordinator.py Outdated
Comment thread homeassistant/components/vodafone_station/coordinator.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft May 8, 2024 17:07
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented May 8, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@chemelli74 chemelli74 force-pushed the chemelli74-vodafone-cleanup branch from 9abd0a8 to 5ad3213 Compare May 12, 2024 13:32
@chemelli74 chemelli74 marked this pull request as ready for review May 12, 2024 13:32
@home-assistant home-assistant Bot requested a review from mib1185 May 12, 2024 13:32
Comment thread homeassistant/components/vodafone_station/coordinator.py Outdated
Copy link
Copy Markdown
Member

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

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

LGTM, thx @chemelli74 👍

frenck
frenck previously requested changes May 18, 2024
Comment thread homeassistant/components/vodafone_station/button.py Outdated
@github-actions
Copy link
Copy Markdown

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!

@github-actions
Copy link
Copy Markdown

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!

@github-actions github-actions Bot added the stale label Sep 18, 2024
@chemelli74 chemelli74 removed the stale label Sep 18, 2024
@chemelli74 chemelli74 force-pushed the chemelli74-vodafone-cleanup branch from 18c8937 to 9aedef0 Compare October 25, 2024 18:23
@home-assistant home-assistant Bot marked this pull request as draft January 23, 2025 17:30
@chemelli74 chemelli74 marked this pull request as ready for review January 31, 2025 12:22
@home-assistant home-assistant Bot requested a review from joostlek January 31, 2025 12:22
Comment thread homeassistant/components/vodafone_station/coordinator.py Outdated
Comment thread homeassistant/components/vodafone_station/helpers.py Outdated
Comment thread homeassistant/components/vodafone_station/helpers.py Outdated
Comment thread homeassistant/components/vodafone_station/helpers.py Outdated
Comment thread homeassistant/components/vodafone_station/helpers.py Outdated
Comment thread homeassistant/components/vodafone_station/helpers.py Outdated
Comment thread homeassistant/components/vodafone_station/coordinator.py Outdated
Comment thread homeassistant/components/vodafone_station/helpers.py
Comment thread homeassistant/components/vodafone_station/helpers.py
Comment thread homeassistant/components/vodafone_station/coordinator.py
Comment thread tests/components/vodafone_station/test_coordinator.py
@bdraco
Copy link
Copy Markdown
Member

bdraco commented Feb 3, 2025

Merged in dev since this PR is a bit behind to make sure merging it won't cause any lint issues

@chemelli74 chemelli74 merged commit 1680adf into home-assistant:dev Feb 3, 2025
@chemelli74 chemelli74 deleted the chemelli74-vodafone-cleanup branch February 3, 2025 19:49
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants