mirror of
https://github.com/home-assistant/core.git
synced 2025-08-13 09:35:20 +02:00
Disable track buttons when not watching tv.
This commit is contained in:
@@ -25,8 +25,10 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
||||||
|
|
||||||
SUPPORT_PHILIPS_JS = SUPPORT_TURN_OFF | SUPPORT_VOLUME_STEP | \
|
SUPPORT_PHILIPS_JS = SUPPORT_TURN_OFF | SUPPORT_VOLUME_STEP | \
|
||||||
SUPPORT_VOLUME_MUTE | SUPPORT_SELECT_SOURCE | \
|
SUPPORT_VOLUME_MUTE | SUPPORT_SELECT_SOURCE
|
||||||
SUPPORT_NEXT_TRACK | SUPPORT_PREVIOUS_TRACK
|
|
||||||
|
SUPPORT_PHILIPS_JS_TV = SUPPORT_PHILIPS_JS | SUPPORT_NEXT_TRACK | \
|
||||||
|
SUPPORT_PREVIOUS_TRACK
|
||||||
|
|
||||||
DEFAULT_DEVICE = 'default'
|
DEFAULT_DEVICE = 'default'
|
||||||
DEFAULT_HOST = '127.0.0.1'
|
DEFAULT_HOST = '127.0.0.1'
|
||||||
@@ -70,6 +72,8 @@ class PhilipsTV(MediaPlayerDevice):
|
|||||||
self._source_list = []
|
self._source_list = []
|
||||||
self._connfail = 0
|
self._connfail = 0
|
||||||
self._source_mapping = {}
|
self._source_mapping = {}
|
||||||
|
self._watching_tv = None
|
||||||
|
self._channel_name = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@@ -84,6 +88,9 @@ class PhilipsTV(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def supported_media_commands(self):
|
def supported_media_commands(self):
|
||||||
"""Flag of media commands that are supported."""
|
"""Flag of media commands that are supported."""
|
||||||
|
if self._watching_tv:
|
||||||
|
return SUPPORT_PHILIPS_JS_TV
|
||||||
|
else:
|
||||||
return SUPPORT_PHILIPS_JS
|
return SUPPORT_PHILIPS_JS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -108,6 +115,7 @@ class PhilipsTV(MediaPlayerDevice):
|
|||||||
self._source = source
|
self._source = source
|
||||||
if not self._tv.on:
|
if not self._tv.on:
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
self._watching_tv = bool(self._source == 'Watch TV')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def volume_level(self):
|
def volume_level(self):
|
||||||
@@ -154,7 +162,7 @@ class PhilipsTV(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
"""Title of current playing media."""
|
"""Title of current playing media."""
|
||||||
if self._source == 'Watch TV':
|
if self._watching_tv:
|
||||||
if self._channel_name:
|
if self._channel_name:
|
||||||
return '{} - {}'.format(self._source, self._channel_name)
|
return '{} - {}'.format(self._source, self._channel_name)
|
||||||
else:
|
else:
|
||||||
@@ -184,6 +192,8 @@ class PhilipsTV(MediaPlayerDevice):
|
|||||||
else:
|
else:
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
|
||||||
|
self._watching_tv = bool(self._source == 'Watch TV')
|
||||||
|
|
||||||
self._tv.getChannelId()
|
self._tv.getChannelId()
|
||||||
self._tv.getChannels()
|
self._tv.getChannels()
|
||||||
if self._tv.channel_id in self._tv.channels:
|
if self._tv.channel_id in self._tv.channels:
|
||||||
|
Reference in New Issue
Block a user