Skip to content

Commit

Permalink
Move philips_js imports at top-level
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentame committed Nov 24, 2019
1 parent 94f8e63 commit 624b744
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions homeassistant/components/philips_js/media_player.py
Expand Up @@ -2,20 +2,21 @@
from datetime import timedelta
import logging

from haphilipsjs import PhilipsTV
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 (
MEDIA_TYPE_CHANNEL,
SUPPORT_NEXT_TRACK,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SELECT_SOURCE,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
MEDIA_TYPE_CHANNEL,
SUPPORT_PLAY_MEDIA,
)
from homeassistant.const import (
CONF_API_VERSION,
Expand Down Expand Up @@ -70,20 +71,18 @@ def _inverted(data):

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Philips TV platform."""
import haphilipsjs

name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
api_version = config.get(CONF_API_VERSION)
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

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."""

def __init__(self, tv, name, on_script):
Expand Down

0 comments on commit 624b744

Please sign in to comment.