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

Xbox sensor - Extend error handling #11637

Merged
merged 4 commits into from Jan 18, 2018

Conversation

Projects
None yet
5 participants
@ReneNulschDE
Copy link
Contributor

commented Jan 14, 2018

Description:

Add error handling for wrong api key and wrong xuid

Related issue (if applicable): fixes #9016

Checklist:

  • The code change is tested and works locally.

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

ReneNulschDE added some commits Jan 14, 2018

profile = api.get_profile()
if profile.get('error_code', None) is not None:
_LOGGER.error("Can't setup XboxAPI connection. Check your account or "
+ " api key on xboxapi.com. Code: %s Description: %s ",

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jan 14, 2018

Member

Remove the +. It's not needed.

+ " api key on xboxapi.com. Code: %s Description: %s ",
profile.get('error_code', STATE_UNKNOWN),
profile.get('error_message', STATE_UNKNOWN))
return False

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jan 14, 2018

Member

Just return. Nothing is checking this return value.

else:
return False
add_devices(devices, True)
return True

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jan 14, 2018

Member

Remove this.

add_devices(devices, True)
return True

return False

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jan 14, 2018

Member

Same as above.

self.success_init = True
self._gamertag = profile.get('gamertag')
self._picture = profile.get('gamerpicSmallSslImagePath')
else:
_LOGGER.error("Can't get user profile %s. "
+ "Error Code: %s Description: %s",

This comment has been minimized.

Copy link
@MartinHjelmare

This comment has been minimized.

Copy link
@ReneNulschDE

ReneNulschDE Jan 17, 2018

Author Contributor

Thank you for your feedback. I've implemented the requested change.

@@ -34,15 +34,25 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
api = xbox_api.XboxApi(config.get(CONF_API_KEY))
devices = []

# request personal profile to check api connection
profile = api.get_profile()
if profile.get('error_code', None) is not None:

This comment has been minimized.

Copy link
@fabaff

fabaff Jan 15, 2018

Member

You can remove None. It's the default.

This comment has been minimized.

Copy link
@ReneNulschDE

ReneNulschDE Jan 17, 2018

Author Contributor

Thank you for your feedback. I've implemented the requested change.

return False
add_devices(devices, True)

return

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jan 17, 2018

Member

Remove this it's not needed.

@balloob

This comment has been minimized.

Copy link
Member

commented Jan 18, 2018

👍 🌮 nice

@balloob balloob merged commit aad14b8 into home-assistant:dev Jan 18, 2018

5 checks passed

WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.02%) to 93.888%
Details
hound No violations found. Woof!

@ReneNulschDE ReneNulschDE deleted the ReneNulschDE:xboxErrorHandling branch Jan 18, 2018

@balloob balloob referenced this pull request Jan 26, 2018

Merged

0.62 #11921

@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.