Skip to content

Commit

Permalink
Add Key Chaining and SmartThings Keys to play_media service
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Mar 4, 2020
1 parent 7d75282 commit fd93e42
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion custom_components/samsungtv_tizen/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,22 @@ async def async_play_media(self, media_type, media_id, **kwargs):
_LOGGER.error('Media ID must be a string (ex: "KEY_HOME"')
return

await self.hass.async_add_job(self.send_command, media_id)
source_key = media_id

if source_key.startswith("ST_"):
if source_key.startswith("ST_HDMI"):
smartthings.send_command(self, source_key.replace("ST_", ""), "selectsource")
elif source_key == "ST_TV":
smartthings.send_command(self, "digitalTv", "selectsource")
elif "+" in source_key:
all_source_keys = source_key.split("+")
for this_key in all_source_keys:
if this_key.isdigit():
time.sleep(int(this_key)/1000)
else:
await self.hass.async_add_job(self.send_command, this_key)
else:
await self.hass.async_add_job(self.send_command, source_key)

# Play media
elif media_type == MEDIA_TYPE_URL:
Expand Down

0 comments on commit fd93e42

Please sign in to comment.