mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Use extend of PLATFORM_SCHEMA (#3199)
This commit is contained in:
parent
8afed2cafa
commit
e324885ff6
@ -9,32 +9,32 @@ import logging
|
|||||||
|
|
||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK,
|
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, PLATFORM_SCHEMA,
|
||||||
SUPPORT_TURN_OFF, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
|
SUPPORT_TURN_OFF, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
|
||||||
SUPPORT_SELECT_SOURCE, MEDIA_TYPE_CHANNEL, MediaPlayerDevice)
|
SUPPORT_SELECT_SOURCE, MEDIA_TYPE_CHANNEL, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PLATFORM, CONF_HOST, CONF_NAME, CONF_ACCESS_TOKEN,
|
CONF_HOST, CONF_NAME, CONF_ACCESS_TOKEN,
|
||||||
STATE_OFF, STATE_PLAYING, STATE_PAUSED, STATE_UNKNOWN)
|
STATE_OFF, STATE_PLAYING, STATE_PAUSED, STATE_UNKNOWN)
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
REQUIREMENTS = ['https://github.com/wokar/pylgnetcast/archive/'
|
REQUIREMENTS = ['https://github.com/wokar/pylgnetcast/archive/'
|
||||||
'v0.2.0.zip#pylgnetcast==0.2.0']
|
'v0.2.0.zip#pylgnetcast==0.2.0']
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DEFAULT_NAME = 'LG TV Remote'
|
||||||
|
|
||||||
|
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(seconds=1)
|
||||||
|
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||||
|
|
||||||
SUPPORT_LGTV = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \
|
SUPPORT_LGTV = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \
|
||||||
SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | \
|
SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | \
|
||||||
SUPPORT_NEXT_TRACK | SUPPORT_TURN_OFF | SUPPORT_SELECT_SOURCE
|
SUPPORT_NEXT_TRACK | SUPPORT_TURN_OFF | SUPPORT_SELECT_SOURCE
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(seconds=1)
|
|
||||||
|
|
||||||
DEFAULT_NAME = 'LG TV Remote'
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = vol.Schema({
|
|
||||||
vol.Required(CONF_PLATFORM): "lg_netcast",
|
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
vol.Optional(CONF_ACCESS_TOKEN, default=None):
|
vol.Optional(CONF_ACCESS_TOKEN, default=None):
|
||||||
@ -46,7 +46,9 @@ PLATFORM_SCHEMA = vol.Schema({
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the LG TV platform."""
|
"""Setup the LG TV platform."""
|
||||||
from pylgnetcast import LgNetCastClient
|
from pylgnetcast import LgNetCastClient
|
||||||
client = LgNetCastClient(config[CONF_HOST], config[CONF_ACCESS_TOKEN])
|
client = LgNetCastClient(config.get(CONF_HOST),
|
||||||
|
config.get(CONF_ACCESS_TOKEN))
|
||||||
|
|
||||||
add_devices([LgTVDevice(client, config[CONF_NAME])])
|
add_devices([LgTVDevice(client, config[CONF_NAME])])
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user