Use voluptuous for dweet, transmission, and twitch sensor (#2802)
* Use voluptuous for dweet, transmission, and twitch sensor * Extent platform, ordering, and consts * Clean-up
This commit is contained in:
1 parent
ada4de3ffb
commit
c74e167a7b
5 files changed
+107
-69
No files matched your search
@@ -4,8 +4,15 @@ Support for the Twitch stream status.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.twitch/
|
||||
"""
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
CONF_CHANNELS = 'channels'
|
||||
STATE_STREAMING = 'streaming'
|
||||
STATE_OFFLINE = 'offline'
|
||||
ATTR_GAME = 'game'
|
||||
@@ -13,14 +20,21 @@ ATTR_TITLE = 'title'
|
||||
ICON = 'mdi:twitch'
|
||||
|
||||
REQUIREMENTS = ['python-twitch==1.3.0']
|
||||
DOMAIN = 'twitch'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_CHANNELS, default=[]):
|
||||
vol.All(cv.ensure_list, [cv.string]),
|
||||
})
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Twitch platform."""
|
||||
add_devices(
|
||||
[TwitchSensor(channel) for channel in config.get('channels', [])])
|
||||
channels = config.get(CONF_CHANNELS, [])
|
||||
|
||||
add_devices([TwitchSensor(channel) for channel in channels])
|
||||
|
||||
|
||||
class TwitchSensor(Entity):
|
||||
|
||||
Reference in new issue
Block a user