Skip to content

Add options to ignore shared/managed Plex clients#31738

Merged
balloob merged 10 commits into
home-assistant:devfrom
jjlawren:plex_ignore_shares
Feb 19, 2020
Merged

Add options to ignore shared/managed Plex clients#31738
balloob merged 10 commits into
home-assistant:devfrom
jjlawren:plex_ignore_shares

Conversation

@jjlawren
Copy link
Copy Markdown
Contributor

@jjlawren jjlawren commented Feb 11, 2020

Proposed change

The Plex integration currently adds every visible Plex client as a separate media_player entity. This makes some installations very unwieldy as large number of shared clients are dynamically created.

This PR allows you to choose which Plex users' players will create media_player entities via the integration's config options.

It also adds an option (YAML and config option) which ignores shared & managed users as they're granted access to the Plex server.

All clients will still be counted by the integration's sensor for currently playing sessions.

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

Example entry for configuration.yaml:

# Example configuration.yaml
plex:
   host: 10.0.0.5
   token: <PLEX_TOKEN>
   media_player:
     ignore_new_shared_users: true

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

Comment thread homeassistant/components/plex/config_flow.py Outdated
Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

@jjlawren
Copy link
Copy Markdown
Contributor Author

If anyone else is willing to validate these changes before we merge, I'd really appreciate it. I'm not certain that this will work in every Plex installation.

@codecov

This comment has been minimized.

@jjlawren jjlawren changed the title WIP: Add option to ignore shared/managed Plex clients WIP: Add options to ignore shared/managed Plex clients Feb 15, 2020
@jjlawren
Copy link
Copy Markdown
Contributor Author

Updating this PR to use the new multi-select config option UI when that's available (home-assistant/frontend#4247 / #31798). Still WIP for now.

@jjlawren jjlawren requested a review from balloob February 18, 2020 18:58
@jjlawren jjlawren changed the title WIP: Add options to ignore shared/managed Plex clients Add options to ignore shared/managed Plex clients Feb 18, 2020
Comment thread homeassistant/components/plex/config_flow.py Outdated
Comment thread homeassistant/components/plex/server.py Outdated
Copy link
Copy Markdown
Member

@Kane610 Kane610 left a comment

Choose a reason for hiding this comment

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

Smaller comments from me, looks good!

Comment thread homeassistant/components/plex/config_flow.py
Comment thread homeassistant/components/plex/config_flow.py
Comment thread homeassistant/components/plex/config_flow.py
Comment thread homeassistant/components/plex/server.py Outdated
Comment thread homeassistant/components/plex/server.py Outdated
@balloob balloob merged commit 0213f43 into home-assistant:dev Feb 19, 2020
mock_plex_server = MockPlexServer(load_users=False)

MOCK_SERVER_ID = MOCK_SERVERS[0][config_flow.CONF_SERVER_IDENTIFIER]
hass.data[config_flow.DOMAIN] = {
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Feb 19, 2020

Choose a reason for hiding this comment

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

Here we're mocking integration code. It would be more robust to just patch the library server and set up the integration so we don't need to mock our own 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.

Agree, but there are currently no tests which actually set up the integration. I'd like to do that in the future.

@jjlawren jjlawren deleted the plex_ignore_shares branch February 19, 2020 02:33
@lock lock Bot locked and limited conversation to collaborators Feb 21, 2020
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.

5 participants