Skip to content

Commit

Permalink
Set Default Delay in Key Chaining to 500ms
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba authored Oct 18, 2020
1 parent b2cb5d9 commit 042a778
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/samsungtv_tizen/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
DEFAULT_NAME = "Samsung TV Remote"
DEFAULT_PORT = 8001
DEFAULT_TIMEOUT = 3
DEFAULT_KEY_CHAIN_DELAY = 0.5
DEFAULT_UPDATE_METHOD = "ping"
DEFAULT_SOURCE_LIST = '{"TV": "KEY_TV", "HDMI": "KEY_HDMI"}'
CONF_UPDATE_METHOD = "update_method"
Expand Down Expand Up @@ -790,14 +791,19 @@ async def async_play_media(self, media_type, media_id, **kwargs):
source_key = media_id
if "+" in source_key:
all_source_keys = source_key.split("+")
last_was_delay = True
for this_key in all_source_keys:
if this_key.isdigit():
last_was_delay = True
time.sleep(int(this_key)/1000)
else:
if last_was_delay == False:
time.sleep(DEFAULT_KEY_CHAIN_DELAY)
last_was_delay = False
if this_key.startswith("ST_"):
await self.hass.async_add_job(self._smartthings_keys, this_key)
self.hass.async_add_job(self._smartthings_keys, this_key)
else:
await self.hass.async_add_job(self.send_command, this_key)
self.hass.async_add_job(self.send_command, this_key)
elif source_key.startswith("ST_"):
await self.hass.async_add_job(self._smartthings_keys, source_key)
else:
Expand Down

0 comments on commit 042a778

Please sign in to comment.