-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Support for non-clients, NVidia shield, dynamic grouping, extra metad… #6054
Conversation
Hi @JesseWebDotCom, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
# or when casting to an Nvidia shield running a plex server | ||
if self.local: | ||
return None | ||
#No mute since Shield only supports volume 2-100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block comment should start with '# '
thumb_response = requests.get(thumb_url, verify=False) | ||
if thumb_response.status_code != 200: | ||
_LOGGER.debug( | ||
'Using art because thumbnail was not found: content id %s', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
@@ -62,6 +91,17 @@ def config_from_file(filename, config=None): | |||
|
|||
def setup_platform(hass, config, add_devices_callback, discovery_info=None): | |||
"""Setup the Plex platform.""" | |||
|
|||
#optional parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block comment should start with '# '
from homeassistant.loader import get_component | ||
from homeassistant.helpers.event import (track_utc_time_change) | ||
import homeassistant.helpers.config_validation as cv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
STATE_UNKNOWN) | ||
SUPPORT_PLAY, SUPPORT_VOLUME_MUTE, SUPPORT_TURN_OFF, SUPPORT_SEEK, | ||
PLATFORM_SCHEMA, MediaPlayerDevice) | ||
from homeassistant.const import (DEVICE_DEFAULT_NAME, STATE_IDLE, STATE_OFF, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
'homeassistant.const.STATE_UNKNOWN' imported but unused
import json | ||
import logging | ||
import os | ||
from datetime import timedelta | ||
from urllib.parse import urlparse | ||
|
||
import voluptuous as vol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
from requests.packages.urllib3.exceptions import InsecureRequestWarning | ||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | ||
|
||
import asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module level import not at top of file
I can't sign the CLA - the web page spinner never stops (tried from multiple browsers, clients, and networks). |
@JesseWebDotCom Can you provide a full list of changes? |
My original documentation is here: change log (hopefully that’s everything):
|
# with a loopback address, the device must be local or casting | ||
for client in self.device.server.clients(): | ||
if "127.0.0.1" in client.baseurl: | ||
if client.machineIdentifier == self.device.machineIdentifier: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more readable on one line but I'll change it if you need me to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do, as we have strict requirements on PEP8 compliance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so I'm not sure how to fix this as I got an auto message each way I went
for client in self.device.server.clients(): | ||
if "127.0.0.1" in client.baseurl: | ||
if client.machineIdentifier == \ | ||
self.device.machineIdentifier: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line with same indent as next logical line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boo, will fix (hopefully)
for client in self.device.server.clients(): | ||
if "127.0.0.1" in client.baseurl: | ||
if client.machineIdentifier == \ | ||
self.device.machineIdentifier: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line missing indentation or outdented
@JesseWebDotCom You can use |
Thanks. Already use pylint in Atom.io combined with Atom beautify using yapf. It usually fixes everything automatically. Just added flake8 for good measure. |
Never mind, I see how to update the documentation. I'll start doing that now and submit for review. |
>>>>>>> 4201005ca8ff3f7b584e5cbb9f3464f65c8ce2a9 | ||
|
||
# set groups with updated memberships | ||
set_group_members(hass, GROUP_ACTIVE_DEVICES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore, I pushed a new update (fix3) that works and doesn't include the junk text above
active_entity_id_list.append(client.entity_id) | ||
>>>>>>> 4201005ca8ff3f7b584e5cbb9f3464f65c8ce2a9 | ||
|
||
# set groups with updated memberships |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected indentation (comment)
inactive_entity_id_list.append(client.entity_id) | ||
else: | ||
active_entity_id_list.append(client.entity_id) | ||
>>>>>>> 4201005ca8ff3f7b584e5cbb9f3464f65c8ce2a9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace around operator
else: | ||
active_entity_id_list.append(client.entity_id) | ||
======= | ||
if not client.hidden: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected indentation
client.entity_id) | ||
else: | ||
active_entity_id_list.append(client.entity_id) | ||
======= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace around operator
if client.entity_id: | ||
<<<<<<< HEAD | ||
# do not add if hidden | ||
client_states = hass.states.get(client.entity_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected indentation
for machine_identifier, client in plex_clients.items(): | ||
if client.entity_id: | ||
<<<<<<< HEAD | ||
# do not add if hidden |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected indentation (comment)
|
||
for machine_identifier, client in plex_clients.items(): | ||
if client.entity_id: | ||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines after class or function definition, found 0
expected an indented block
IndentationError: expected an indented block
missing whitespace around bitwise or shift operator
missing whitespace around operator
Any word on when this and the documentation (home-assistant/home-assistant.io#2094) will get officially incorporated? |
if self.session and self.session.player: | ||
if ((frozen_seconds > | ||
int(self.optional_config[CONF_MAX_FROZEN_PAUSED])) and | ||
(self.session.player.state == 'paused' or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need one space here.
@JesseWebDotCom Looks like the build is failing.....there are some simple errors that can be fixed. |
|
||
def set_group_members(hass, group_entity_id, member_entity_id_list): | ||
"""Creates group if doesn't exist and sets memberships""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to end in a period
"""Create group if doesn't exist and set memberships."""
self.name.lower().replace('-', '_')) | ||
|
||
def refresh(self, device, session): | ||
"""Refresh key device data""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Refresh key device data."""
self._make = make | ||
|
||
def force_idle(self): | ||
"""Force client to idle""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Force client to idle."""
|
||
@property | ||
def app_name(self): | ||
"""Library name of playing media""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Return the library name of playing media."""
I'm still getting a session based client and a regular client from the |
@Teagan42 - what's your recommendation? Also, how can I replicate this? |
SUPPORT_TURN_OFF | SUPPORT_VOLUME_MUTE) | ||
|
||
# only show controls when we know what device is connecting | ||
if not self._make: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an elif
? It's overwriting the two if
s before this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, those are missing return statements - will add
if config.get(CONF_INCLUDE_NON_CLIENTS): | ||
for machine_identifier, session in plex_sessions.items(): | ||
if (machine_identifier not in plex_clients | ||
and machine_identifier is not None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be to prevent dupes:
and session.player.machineIdentifier is not None):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add, test, and check in (for this one spot) - thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup this fixes dupe issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so this is odd - at first load, with this change, I don't get dupes, but after it sits for a bit, I get dupes... let me investigate more...
@JesseWebDotCom I'm not sure what is causing duplicate clients, I'm still digging. |
@Teagan42 - Standing by |
So, I added the machine identifier to the state attributes - when it first loads, only the first two show up (yay), but after another pass, the second two show up (empty machine identifiers)
So, some how, we're getting empty machine identifiers into the plex clients. Not sure where, again still digging - Not sure how no one else is seeing this issue... |
Even more interesting, realized I don't have the include non clients flag set in my config... |
@JesseWebDotCom if you got time in about an hour we can hop on a video call and I can show you what I'm seeing. |
Unfortunately I'm at a family event. Perhaps you can send me a clip. Also, what's your setup (I think I have every plex client in the world - maybe I can reproduce the issue)? |
I am having issues with my Amazon Fire TVs (haven't even checked the two sticks I have up stairs). On first pass, the AFTVs are added (as expected), but second pass (the refresh) it seems to duplicate them as non-devices. When I turn on the |
Scratch that: TV (Non-Client) Only shows up once ✅ Here's an image (I have 2 Amazon Fire TVs - so you'll see both duplicated): |
Fire Sticks have same issue as the TVs |
Top to bottom: |
I have other things to work on tonight - if you can dig in, let me know otherwise I'll try to look tomorrow |
When you see the duplicate devices, go to http://IP:PORT/status/sessions (ip = plex server) and post the results (make sure it doesn't include any sensitive information). My suspicion is you are either getting blank machine identifiers or duplicate identifiers. If so, that's a big problem as thats the only way to uniquely identify a player (other than a hack like using the client ip). |
Also, what do you have for a plex server? Are you casting in any of these scenarios? And what is the compared behavior in the existing media_player.plex component? |
So the code looks good. This can be merged once the bugs found by @Teagan42 fixed or avoided. |
Bugs were all on my setup, my bad. All is good.
…On Mar 15, 2017 11:04 PM, "Paulus Schoutsen" ***@***.***> wrote:
So the code looks good. This can be merged once the bugs found by
@Teagan42 <https://github.com/Teagan42> fixed or avoided.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6054 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC2fZV20QCbxBLwkEnGni3Km81yYj6Ykks5rmMLqgaJpZM4MD1_B>
.
|
Thanks @JesseWebDotCom for the work and @Teagan42 for testing! 🎉 💃 🐬 🍺 |
Awesome, thanks for teaching |
@JesseWebDotCom Thanks for hanging on! We thought that this was such a great pull request and show of effort it was deserving of its own tweet! Cherish it, we don't hand those out lightly 😳 |
Thanks. Hey, I believe I have one more change to make which is a fix to the new show all controls option (it won't work as is). Can I still submit that as a new commit here or is it too late? I just tried to submit and it doesn't look like it worked: Also, how can I tell if my associated documentation pull request is approved and ready to be released at the same time as this component? |
This is my first contribution so forgive me if I misstep.
A full breakdown of the updates are here:
If you agree with the direction and or changes, I can start drafting the updated version of:
https://home-assistant.io/components/media_player.plex/
Let me know if there is an official process for updating documentation
Thanks