Skip to content

Improve Plex device handling#48369

Merged
balloob merged 5 commits into
home-assistant:devfrom
jjlawren:plex_ignore_transient_devices
Mar 31, 2021
Merged

Improve Plex device handling#48369
balloob merged 5 commits into
home-assistant:devfrom
jjlawren:plex_ignore_transient_devices

Conversation

@jjlawren
Copy link
Copy Markdown
Contributor

@jjlawren jjlawren commented Mar 26, 2021

Breaking change

Devices representing Plex Web media_player devices will be removed. Any automations, scenes, or scripts based on the device will need to be changed to use the media_player entity.

Proposed change

This PR removes orphaned devices where the user has removed the associated media_player entity.

The method for assigning devices for certain Plex media_player entities is also changing. Plex Web and Plex for Sonos media_player entities represent potentially transient apps or external services. For example, a new Plex Web device is created for each browser login. These should not have permanent devices attached to them. This PR migrates the entities to a new shared "Plex Clients" service. This will also allow cleanup of the old individual devices during a subsequent restart.

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.

The integration reached or maintains the following Integration Quality Scale:

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

To help with the load of incoming pull requests:

@jjlawren jjlawren changed the title Ignore and clean up transient Plex devices Clean up Plex devices, ignore transient devices Mar 26, 2021
@jjlawren jjlawren changed the title Clean up Plex devices, ignore transient devices Improve Plex device handling Mar 29, 2021
@jjlawren jjlawren marked this pull request as ready for review March 29, 2021 20:11
Comment thread homeassistant/components/plex/__init__.py Outdated
Comment thread homeassistant/components/plex/__init__.py Outdated
if self.machine_identifier is None:
return None

if self.device_product in TRANSIENT_DEVICE_MODELS:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we just return None?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I originally wanted to delete the current devices, but that also removed the associated entities. This moves them to a new service device instead so the old device can get safely removed by the new orphan cleanup code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW, I think I'd actually prefer to not have any devices attached to these entities, but returning None doesn't disassociate them from existing devices.

@balloob balloob merged commit be71d62 into home-assistant:dev Mar 31, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 1, 2021
@jjlawren jjlawren deleted the plex_ignore_transient_devices branch May 31, 2022 17:49
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.

Device registry does not clean itself when no entity linked to it

3 participants