WIP Plex purge unavailable clients#12823
Closed
ryanm101 wants to merge 7 commits intohome-assistant:devfrom
ryanm101:plex_purge
Closed
WIP Plex purge unavailable clients#12823ryanm101 wants to merge 7 commits intohome-assistant:devfrom ryanm101:plex_purge
ryanm101 wants to merge 7 commits intohome-assistant:devfrom
ryanm101:plex_purge
Conversation
houndci-bot
reviewed
Mar 1, 2018
|
|
||
| @property | ||
| def unavailable_time(self): | ||
| """Returns the timedelta showing how long client has been unavailable""" |
| self._media_image_url = thumb_url | ||
|
|
||
| def set_availability(self, available): | ||
| """Sets the device as available/unavailable and notes the time it was set unavailable""" |
| print("************************Adding") | ||
| add_devices_callback(new_plex_clients) | ||
|
|
||
| # Figure out if device is unavailable and if it should be removed or not |
balloob
reviewed
Mar 1, 2018
| cv.boolean, | ||
| vol.Optional(CONF_PURGE_UNAVAILABLE_CLIENTS, default=True): | ||
| cv.boolean, | ||
| vol.Optional(CONF_CLIENT_PURGE_INTERVAL, default=0): |
Member
There was a problem hiding this comment.
Use cv.time_period. That will return in a timedelta. Then use value.total_seconds() to get back to seconds.
Member
There was a problem hiding this comment.
Oh, and use vol.All(cv.time_period, cv.positive_timedelta)) to make sure it's a positive duration.
balloob
reviewed
Mar 1, 2018
| if config.get(CONF_PURGE_UNAVAILABLE_CLIENTS)\ | ||
| and cclient.unavailable_time is not None \ | ||
| and cclient.marked_for_purge is not True \ | ||
| and cclient.unavailable_time.seconds > config_purge_int: |
Member
There was a problem hiding this comment.
If unavailable_time is a timedelta, use total_seconds()
Contributor
Author
There was a problem hiding this comment.
Will do, but what is the benefit of doing it that way? or is it purely stylistic to keep with the project norms?
OverloadUT
reviewed
Mar 1, 2018
| CONF_USE_CUSTOM_ENTITY_IDS = 'use_custom_entity_ids' | ||
| CONF_SHOW_ALL_CONTROLS = 'show_all_controls' | ||
| CONF_PURGE_UNAVAILABLE_CLIENTS = 'purge_unavailable_clients' | ||
| CONF_CLIENT_PURGE_INTERVAL = 'client_purge_interval' |
Contributor
There was a problem hiding this comment.
- Do we call them "clients" anywhere else? I think "player" is a better term. Client is code, player is user-facing. :) But if there's already precedent here then just do what's consistent.
- I would remove the word purge here. Purge sounds like a retroactive destruction, removing all history of a thing. I suggest a softer word like "remove"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fully Fixes: #10074
Adds two new cfg options:
CONF_PURGE_UNAVAILABLE_CLIENTS = 'purge_unavailable_clients' (bool default TRUE)
CONF_CLIENT_PURGE_INTERVAL = 'client_purge_interval' (INT default 0)
These options need to be added to docs
This keeps previous expected behaviour of removing unavailable clients immediately but allows users that to fine tune that behaviour and can also be disabled if required.
supersedes: #12811