mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Implement play media to set a channel based on (by priority): (#13934)
- exact channel number - exact channel name - similar channel name temp
This commit is contained in:
parent
add0afe31a
commit
998d8c1771
@ -344,6 +344,42 @@ class LgWebOSDevice(MediaPlayerDevice):
|
|||||||
self._current_source = source_dict['label']
|
self._current_source = source_dict['label']
|
||||||
self._client.set_input(source_dict['id'])
|
self._client.set_input(source_dict['id'])
|
||||||
|
|
||||||
|
def play_media(self, media_type, media_id, **kwargs):
|
||||||
|
"""Play a piece of media."""
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Call play media type <%s>, Id <%s>", media_type, media_id)
|
||||||
|
|
||||||
|
if media_type == MEDIA_TYPE_CHANNEL:
|
||||||
|
_LOGGER.debug("Searching channel...")
|
||||||
|
partial_match_channel_id = None
|
||||||
|
|
||||||
|
for channel in self._client.get_channels():
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Checking channel number <%s>, name <%s>, id <%s>...",
|
||||||
|
channel['channelNumber'],
|
||||||
|
channel['channelName'],
|
||||||
|
channel['channelId'])
|
||||||
|
if media_id == channel['channelNumber']:
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Perfect match on channel number: switching!")
|
||||||
|
self._client.set_channel(channel['channelId'])
|
||||||
|
return
|
||||||
|
elif media_id.lower() == channel['channelName'].lower():
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Perfect match on channel name: switching!")
|
||||||
|
self._client.set_channel(channel['channelId'])
|
||||||
|
return
|
||||||
|
elif media_id.lower() in channel['channelName'].lower():
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Partial match on channel name: saving it...")
|
||||||
|
partial_match_channel_id = channel['channelId']
|
||||||
|
|
||||||
|
if partial_match_channel_id is not None:
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Using partial match on channel name: switching!")
|
||||||
|
self._client.set_channel(partial_match_channel_id)
|
||||||
|
return
|
||||||
|
|
||||||
def media_play(self):
|
def media_play(self):
|
||||||
"""Send play command."""
|
"""Send play command."""
|
||||||
self._playing = True
|
self._playing = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user