Skip to content

Commit

Permalink
Fix Changing Channels
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Oct 21, 2020
1 parent 738678c commit 000d2e7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions custom_components/samsungtv_tizen/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,10 @@ def media_previous_track(self):


async def async_play_media(self, media_type, media_id, **kwargs):
"""Support changing a channel."""
_LOGGER.debug("Trying to change %s to %s",media_type,media_id)
# Type channel
if media_type == MEDIA_TYPE_CHANNEL:
"""Support changing a channel."""
_LOGGER.debug("Trying to change %s to %s",media_type,media_id)
try:
cv.positive_int(media_id)
except vol.Invalid:
Expand All @@ -767,15 +767,18 @@ async def async_play_media(self, media_type, media_id, **kwargs):
keychain += "KEY_{}+".format(digit)
keychain += "KEY_ENTER"
if self._running_app == 'TV/HDMI':
self.async_play_media(MEDIA_TYPE_KEY, keychain)
self.hass.async_add_job(self.async_play_media, MEDIA_TYPE_KEY, keychain)
else:
found_source = False
for source in self._source_list:
if source.lower().find("tv") != -1:
self.hass.async_add_job(self.async_select_source, source)
else:
self.async_play_media(MEDIA_TYPE_KEY, "KEY_SOURCE+KEY_ENTER")
time.sleep(5)
self.async_play_media(MEDIA_TYPE_KEY, keychain)
if source.lower() in ["tv", "live tv", "livetv"]:
found_source = True
await self.hass.async_add_job(self.async_select_source, source)
time.sleep(2)
break
if found_source == False:
keychain = "KEY_EXIT+KEY_EXIT+{}".format(keychain)
self.hass.async_add_job(self.async_play_media, MEDIA_TYPE_KEY, keychain)
# Launch an app
elif media_type == MEDIA_TYPE_APP:
await self.hass.async_add_job(self.send_command, media_id, "run_app")
Expand Down

0 comments on commit 000d2e7

Please sign in to comment.