Skip to content

Fix device_registry cleanup behavior#35977

Merged
MartinHjelmare merged 3 commits intohome-assistant:devfrom
alengwenus:fix_device_cleanup
May 23, 2020
Merged

Fix device_registry cleanup behavior#35977
MartinHjelmare merged 3 commits intohome-assistant:devfrom
alengwenus:fix_device_cleanup

Conversation

@alengwenus
Copy link
Copy Markdown
Contributor

@alengwenus alengwenus commented May 22, 2020

Proposed change

PR #35106 introduced the async_cleanup callback in device_registry.py which ensures that all devices without reference to an entity or reference to a config_entry are removed from the device registry.
Other than stated in the PR, all devices are removed which are not referenced by an entity.
Currently there is no check if instead they are referenced by a config_entry. The latter occurs for example for hubs or hardware devices containing many sensors. Those devices are usually not directly linked to an entity but managed by a config_entry.

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

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
  • The code has been formatted using Black (black --fast 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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant probot-home-assistant Bot added bugfix core small-pr PRs with less than 30 lines. labels May 22, 2020
@alengwenus alengwenus changed the title Fix device cleanup behavior Fix device_registry cleanup behavior May 22, 2020
@alengwenus alengwenus force-pushed the fix_device_cleanup branch from 448b217 to 0927533 Compare May 22, 2020 21:20
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

@MartinHjelmare MartinHjelmare merged commit 919f324 into home-assistant:dev May 23, 2020
@MartinHjelmare MartinHjelmare added this to the 0.110.2 milestone May 23, 2020
@alengwenus alengwenus deleted the fix_device_cleanup branch May 23, 2020 08:00
frenck pushed a commit that referenced this pull request May 24, 2020
* Fix: Only decives which are not referenced by an entity or a config_entry are removed

* Adapted test for async_cleanup

* Changed variable names
@frenck frenck mentioned this pull request May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Devices with reference to existing config_entry are removed from device_registry at startup

4 participants