Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plex mark devices unavailable if they 'vanish' and clear media #12811

Merged
merged 8 commits into from Mar 9, 2018
Merged

Plex mark devices unavailable if they 'vanish' and clear media #12811

merged 8 commits into from Mar 9, 2018

Conversation

ryanm101
Copy link
Contributor

@ryanm101 ryanm101 commented Mar 1, 2018

Partial Fix for:
#10074

if a client vanishes it will persist in UI however it is marked Unavailable and media images are cleared

@@ -407,6 +414,11 @@ def _set_media_image(self):

self._media_image_url = thumb_url

def set_availability(self,available):

Choose a reason for hiding this comment

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

missing whitespace after ','

@ryanm101 ryanm101 changed the title Marks Devices unavailable if they 'vanish' and clears media Plex mark devices unavailable if they 'vanish' and clear media Mar 1, 2018
@ryanm101 ryanm101 closed this Mar 1, 2018
@ryanm101 ryanm101 reopened this Mar 1, 2018
@ryanm101 ryanm101 closed this Mar 1, 2018
@ryanm101 ryanm101 reopened this Mar 2, 2018
@ryanm101 ryanm101 closed this Mar 2, 2018
@ryanm101 ryanm101 reopened this Mar 2, 2018
@ryanm101 ryanm101 closed this Mar 2, 2018
@ryanm101 ryanm101 reopened this Mar 2, 2018
@ryanm101 ryanm101 closed this Mar 2, 2018
@ryanm101 ryanm101 reopened this Mar 2, 2018
@ryanm101 ryanm101 closed this Mar 2, 2018
@ryanm101 ryanm101 reopened this Mar 2, 2018
@ryanm101 ryanm101 closed this Mar 2, 2018
@ryanm101 ryanm101 reopened this Mar 2, 2018
@@ -259,6 +265,7 @@ def __init__(self, config, device, session, plex_sessions,
"""Initialize the Plex device."""
self._app_name = ''
self._device = None
self._is_device_available = False
Copy link
Member

Choose a reason for hiding this comment

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

Please use self._available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -189,6 +192,9 @@ def update_devices():
if new_plex_clients:
add_devices_callback(new_plex_clients)

for cid in hass.data[PLEX_DATA].keys():
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes this could be moved.

@@ -154,11 +154,14 @@ def update_devices():
return

new_plex_clients = []
available_ids = []
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer available_client_ids here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that would make more sense

@syssi
Copy link
Member

syssi commented Mar 3, 2018

Did you see self._is_player_available? What's the difference?

Copy link
Member

@syssi syssi left a comment

Choose a reason for hiding this comment

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

Just remove all your code 😉 and use _is_player_available as identifier for def available. There is a bug somewhere. Please don't implement duplicated logic.

@ryanm101
Copy link
Contributor Author

ryanm101 commented Mar 4, 2018

@syssi Removing all my code and using player available results in player IDLE not unavailable.

Renamed '_is_device_available' to '_available'
Renamed 'available_ids' to 'available_client_ids'
@@ -185,6 +188,9 @@ def update_devices():
# force devices to idle that do not have a valid session
if client.session is None:
client.force_idle()

Choose a reason for hiding this comment

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

blank line contains whitespace

@ryanm101
Copy link
Contributor Author

ryanm101 commented Mar 9, 2018

@syssi leaving _is_player_available till next cleanup (i've to add code to remove unavailable clients and update api to 3.0.6). But Have added prev comments

@balloob Can this make 0.65?

@ryanm101 ryanm101 mentioned this pull request Mar 9, 2018
2 tasks
@balloob balloob added this to the 0.65 milestone Mar 9, 2018
@balloob balloob merged commit ecaf018 into home-assistant:dev Mar 9, 2018
@ryanm101 ryanm101 deleted the plex_markUnavaileable branch March 9, 2018 17:28
balloob pushed a commit that referenced this pull request Mar 9, 2018
* Marks Devices unavailable if they 'vanish' and clears media

* Fixed PEP8 complaint

* Fixed Linting

* Lint Fix

* Fix redine of id

* More lint fixes

* Removed redundant loop for setting availability of client
Renamed '_is_device_available' to '_available'
Renamed 'available_ids' to 'available_client_ids'

* removed whitespace per houndCI
@balloob balloob mentioned this pull request Mar 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants