Move philips_js imports at top-level (#29003)
This commit is contained in:
parent
6307f383a7
commit
5822deda1d
1 changed files with 7 additions and 8 deletions
|
@ -2,11 +2,14 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from haphilipsjs import PhilipsTV
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA
|
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerDevice
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
|
MEDIA_TYPE_CHANNEL,
|
||||||
SUPPORT_NEXT_TRACK,
|
SUPPORT_NEXT_TRACK,
|
||||||
|
SUPPORT_PLAY_MEDIA,
|
||||||
SUPPORT_PREVIOUS_TRACK,
|
SUPPORT_PREVIOUS_TRACK,
|
||||||
SUPPORT_SELECT_SOURCE,
|
SUPPORT_SELECT_SOURCE,
|
||||||
SUPPORT_TURN_OFF,
|
SUPPORT_TURN_OFF,
|
||||||
|
@ -14,8 +17,6 @@ from homeassistant.components.media_player.const import (
|
||||||
SUPPORT_VOLUME_MUTE,
|
SUPPORT_VOLUME_MUTE,
|
||||||
SUPPORT_VOLUME_SET,
|
SUPPORT_VOLUME_SET,
|
||||||
SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_STEP,
|
||||||
MEDIA_TYPE_CHANNEL,
|
|
||||||
SUPPORT_PLAY_MEDIA,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_VERSION,
|
CONF_API_VERSION,
|
||||||
|
@ -70,20 +71,18 @@ def _inverted(data):
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Philips TV platform."""
|
"""Set up the Philips TV platform."""
|
||||||
import haphilipsjs
|
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
api_version = config.get(CONF_API_VERSION)
|
api_version = config.get(CONF_API_VERSION)
|
||||||
turn_on_action = config.get(CONF_ON_ACTION)
|
turn_on_action = config.get(CONF_ON_ACTION)
|
||||||
|
|
||||||
tvapi = haphilipsjs.PhilipsTV(host, api_version)
|
tvapi = PhilipsTV(host, api_version)
|
||||||
on_script = Script(hass, turn_on_action) if turn_on_action else None
|
on_script = Script(hass, turn_on_action) if turn_on_action else None
|
||||||
|
|
||||||
add_entities([PhilipsTV(tvapi, name, on_script)])
|
add_entities([PhilipsTVMediaPlayer(tvapi, name, on_script)])
|
||||||
|
|
||||||
|
|
||||||
class PhilipsTV(MediaPlayerDevice):
|
class PhilipsTVMediaPlayer(MediaPlayerDevice):
|
||||||
"""Representation of a Philips TV exposing the JointSpace API."""
|
"""Representation of a Philips TV exposing the JointSpace API."""
|
||||||
|
|
||||||
def __init__(self, tv, name, on_script):
|
def __init__(self, tv, name, on_script):
|
||||||
|
|
Loading…
Add table
Reference in a new issue