Skip to content

Commit

Permalink
Support for Homekit device_class: tv
Browse files Browse the repository at this point in the history
Support for Homekit `device_class: tv`
  • Loading branch information
gerard33 authored Jul 17, 2019
1 parent 633943e commit 57a8a87
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions custom_components/braviatv_psk/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,34 @@
MediaPlayerDevice, PLATFORM_SCHEMA)
try:
from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, SUPPORT_TURN_ON,
SUPPORT_TURN_OFF, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_SET, SUPPORT_SELECT_SOURCE,
MEDIA_TYPE_TVSHOW, SUPPORT_STOP)
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK,
SUPPORT_TURN_ON, SUPPORT_TURN_OFF, SUPPORT_VOLUME_MUTE, SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_STEP, SUPPORT_VOLUME_SET,
SUPPORT_SELECT_SOURCE, SUPPORT_STOP, MEDIA_TYPE_TVSHOW)
except ImportError:
from homeassistant.components.media_player import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, SUPPORT_TURN_ON,
SUPPORT_TURN_OFF, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_SET, SUPPORT_SELECT_SOURCE,
MEDIA_TYPE_TVSHOW, SUPPORT_STOP)
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK,
SUPPORT_TURN_ON, SUPPORT_TURN_OFF, SUPPORT_VOLUME_MUTE, SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_STEP, SUPPORT_VOLUME_SET,
SUPPORT_SELECT_SOURCE, SUPPORT_STOP, MEDIA_TYPE_TVSHOW)
from homeassistant.const import (
CONF_HOST, CONF_NAME, CONF_MAC, STATE_OFF, STATE_ON)
import homeassistant.helpers.config_validation as cv

__version__ = '0.2.8'
__version__ = '0.3.0'

REQUIREMENTS = ['pySonyBraviaPSK==0.1.7']

_LOGGER = logging.getLogger(__name__)

SUPPORT_BRAVIA = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \
SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET | \
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | \
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PLAY_MEDIA | \
SUPPORT_SELECT_SOURCE | SUPPORT_PLAY | SUPPORT_STOP
SUPPORT_BRAVIA = \
SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE | \
SUPPORT_VOLUME_SET | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | \
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PLAY_MEDIA | \
SUPPORT_SELECT_SOURCE | SUPPORT_PLAY | SUPPORT_STOP

DEFAULT_NAME = 'Sony Bravia TV'
DEVICE_CLASS_TV = 'tv'

# Config file
CONF_PSK = 'psk'
Expand Down Expand Up @@ -121,6 +122,7 @@ def __init__(self, host, psk, mac, name, amp, android, source_filter):
self._volume = None
self._start_time = None
self._end_time = None
self._device_class = DEVICE_CLASS_TV

if mac:
self._unique_id = '{}-{}'.format(mac, name)
Expand Down Expand Up @@ -301,6 +303,11 @@ def media_content_id(self):
"""Content ID of current playing media."""
return self._channel_name

@property
def device_class(self):
"""Return the device class of the media player."""
return self._device_class

def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
self._braviarc.set_volume_level(volume)
Expand Down

0 comments on commit 57a8a87

Please sign in to comment.