Skip to content

Commit

Permalink
Simplify WS Change Channel Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba authored Oct 18, 2020
1 parent 042a778 commit 112e34d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions custom_components/samsungtv_tizen/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,28 +756,26 @@ async def async_play_media(self, media_type, media_id, **kwargs):
await self.hass.async_add_job(self._smartthings_keys, f"ST_CH{media_id}")
else:
#Change to TV source before changing channel
await self.hass.async_add_job(self._smartthings_keys, "ST_TV")
self.hass.async_add_job(self._smartthings_keys, "ST_TV")
time.sleep(5)
smartthings.device_update(self)
if self._cloud_channel != media_id:
await self.hass.async_add_job(self._smartthings_keys, f"ST_CH{media_id}")
else:
keychain = ""
for digit in media_id:
keychain += "KEY_{}+".format(digit)
keychain += "KEY_ENTER"
if self._running_app == 'TV/HDMI':
for digit in media_id:
await self.hass.async_add_job(self.send_command, "KEY_" + digit)
await self.hass.async_add_job(self.send_command, "KEY_ENTER")
self.async_play_media(MEDIA_TYPE_KEY, keychain)
else:
for source in self._source_list:
if source.lower().find("tv") != -1:
await self.hass.async_add_job(self.async_select_source, source)
self.hass.async_add_job(self.async_select_source, source)
else:
await self.hass.async_add_job(self.send_command, "KEY_SOURCE")
time.sleep(0.5)
await self.hass.async_add_job(self.send_command, "KEY_ENTER")
self.async_play_media(MEDIA_TYPE_KEY, "KEY_SOURCE+KEY_ENTER")
time.sleep(5)
for digit in media_id:
await self.hass.async_add_job(self.send_command, "KEY_" + digit)
await self.hass.async_add_job(self.send_command, "KEY_ENTER")
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 112e34d

Please sign in to comment.