-
-
Notifications
You must be signed in to change notification settings - Fork 28.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
Added Twitch v5 support to the twitch platform #16428
Conversation
@@ -72,15 +81,15 @@ def entity_picture(self): | |||
# pylint: disable=no-member | |||
def update(self): | |||
"""Update device state.""" | |||
from twitch.api import v3 as twitch | |||
stream = twitch.streams.by_channel(self._channel).get('stream') | |||
id = self._client.users.translate_usernames_to_ids([self._channel])[0].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.
local variable 'id' is assigned to but never used
line too long (81 > 79 characters)
@@ -34,16 +37,22 @@ | |||
def setup_platform(hass, config, add_entities, discovery_info=None): | |||
"""Set up the Twitch platform.""" | |||
channels = config.get(CONF_CHANNELS, []) | |||
from twitch import TwitchClient as TwitchClient | |||
client=TwitchClient(client_id=config.get(CONF_CLIENTID)) |
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
channels = config.get(CONF_CHANNELS, []) | ||
client=TwitchClient(client_id=config.get(CONF_CLIENTID)) |
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
channels = config.get(CONF_CHANNELS, []) | ||
|
||
add_entities([TwitchSensor(channel) for channel in channels], True) | ||
client=TwitchClient(client_id=config.get(CONF_CLIENTID)) |
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
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.
tests/testing_config/.storage/core.entity_registry
should be part of this PR.
i assume this shoulent be in there, I have removed it from my branch |
return False | ||
else: | ||
_LOGGER.error("Test API call failed") | ||
return False |
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.
indentation is not a multiple of four
_LOGGER.error("Test API call failed, Check your client_id") | ||
return False | ||
else: | ||
_LOGGER.error("Test API call failed") |
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.
indentation is not a multiple of four
client.ingests.get_server_list() | ||
except HTTPError: | ||
_LOGGER.error("Client ID is not valid") | ||
return False |
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.
Nothing is checking this return value.
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.
the orignial code did check this by checking for a 400 error, for the endpoint im using 400 error should only be caused by a missing client id
if http_error.response.status_code == 400:
_LOGGER.error("Test API call failed, Check your client_id")
else:
_LOGGER.error("Test API call failed")
return False```
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.
No, nothing is checking this return value. Don't return False
, just return
.
THIS IS A BREAKING CHANGE
Description:
This is an update that changes the library use for the twitch sensor, this is a breaking change due to api Changes on twitch's side where all api users require a client_id. I have also made it set the sensor icon to the channels logo when they are not live, as it looks nice.
Middle is live, the others are offline
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6201
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
.If the code does not interact with devices: