Maintenance 2nd (#4106)

* Add link to docs

* Fix link

* Update line breaks

* Update ordering

* Align vera platofrm to only use add_devices
(instead od add_devices_callback)

* Remove line break

* Use consts

* Update ordering

* Update ordering

* Use const, create default name, use string formatting

* Update ordering

* Use const

* Update import style

* Update ordering and line breaks

* update line breaks

* Set default port

* Set defaults and update ordering

* Update ordering

* Minor style updates

* Update ordering, defaults, line breaks, and readability

* Use constants

* Add line breaks

* use string formatting

* Update line breaks

* Update logger
This commit is contained in:
Fabian Affolter authored and GitHub committed 2016-10-30 09:58:34 +01:00
1 parent e6ece4bf6d
commit 9f2aae1357
28 files changed
+272 -271

No files matched your search

+8 -9
View File
@@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.xbox_live/
"""
import logging
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
@@ -12,14 +13,14 @@ from homeassistant.const import (CONF_API_KEY, STATE_UNKNOWN)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
ICON = 'mdi:xbox'
REQUIREMENTS = ['xboxapi==0.1.1']
_LOGGER = logging.getLogger(__name__)
CONF_XUID = 'xuid'
ICON = 'mdi:xbox'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_XUID): vol.All(cv.ensure_list, [cv.string])
@@ -28,7 +29,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Xbox platform."""
"""Set up the Xbox platform."""
from xboxapi import xbox_api
api = xbox_api.XboxApi(config.get(CONF_API_KEY))
devices = []
@@ -59,8 +60,7 @@ class XboxSensor(Entity):
# get profile info
profile = self._api.get_user_profile(self._xuid)
if profile.get('success', True) \
and profile.get('code', 0) != 28:
if profile.get('success', True) and profile.get('code', 0) != 28:
self.success_init = True
self._gamertag = profile.get('Gamertag')
self._picture = profile.get('GameDisplayPicRaw')
@@ -84,8 +84,7 @@ class XboxSensor(Entity):
for device in self._presence:
for title in device.get('titles'):
attributes[
'{} {}'.format(device.get('type'),
title.get('placement'))
'{} {}'.format(device.get('type'), title.get('placement'))
] = title.get('name')
return attributes