From 833f17de04fec6cf0552632bd52f2dca9de654c2 Mon Sep 17 00:00:00 2001 From: ehendrix23 Date: Sat, 2 Mar 2019 16:54:03 -0700 Subject: [PATCH] Add parameter hold_secs for Harmony remote send command (#19650) * Update requirements Updated requirements * Small bump for aioharmony Small version bump increase for aioharmony * Add attributes Add firmware and config version attributes * Add hold for button press on send_command * Fix requirements file For some reason aioharmony ended up in there as a duplicate. Fixed it. * Revert rebase changes Revert some changes that should have been reverted back as part of rebase. * Updated based on review Removed HOLD_SECS from platform schema (configuration) Updated getting kwargs in async_send_command Updated debug log to include delay_secs --- homeassistant/components/harmony/remote.py | 13 ++++++++----- homeassistant/components/remote/__init__.py | 3 +++ homeassistant/components/remote/services.yaml | 4 ++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/harmony/remote.py b/homeassistant/components/harmony/remote.py index 4ea199bdcd1..78f2674243c 100644 --- a/homeassistant/components/harmony/remote.py +++ b/homeassistant/components/harmony/remote.py @@ -7,9 +7,8 @@ import voluptuous as vol from homeassistant.components import remote from homeassistant.components.remote import ( - ATTR_ACTIVITY, ATTR_DELAY_SECS, ATTR_DEVICE, ATTR_NUM_REPEATS, - DEFAULT_DELAY_SECS, DOMAIN, PLATFORM_SCHEMA -) + ATTR_ACTIVITY, ATTR_DELAY_SECS, ATTR_DEVICE, ATTR_HOLD_SECS, + ATTR_NUM_REPEATS, DEFAULT_DELAY_SECS, DOMAIN, PLATFORM_SCHEMA) from homeassistant.const import ( ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_PORT, EVENT_HOMEASSISTANT_STOP ) @@ -340,8 +339,12 @@ class HarmonyRemote(remote.RemoteDevice): _LOGGER.error("%s: Device %s is invalid", self.name, device) return - num_repeats = kwargs.get(ATTR_NUM_REPEATS) + num_repeats = kwargs[ATTR_NUM_REPEATS] delay_secs = kwargs.get(ATTR_DELAY_SECS, self._delay_secs) + hold_secs = kwargs[ATTR_HOLD_SECS] + _LOGGER.debug("Sending commands to device %s holding for %s seconds " + "with a delay of %s seconds", + device, hold_secs, delay_secs) # Creating list of commands to send. snd_cmnd_list = [] @@ -350,7 +353,7 @@ class HarmonyRemote(remote.RemoteDevice): send_command = SendCommandDevice( device=device_id, command=single_command, - delay=0 + delay=hold_secs ) snd_cmnd_list.append(send_command) if delay_secs > 0: diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index b7923596039..de79adc9f0e 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -23,6 +23,7 @@ ATTR_COMMAND = 'command' ATTR_DEVICE = 'device' ATTR_NUM_REPEATS = 'num_repeats' ATTR_DELAY_SECS = 'delay_secs' +ATTR_HOLD_SECS = 'hold_secs' DOMAIN = 'remote' DEPENDENCIES = ['group'] @@ -40,6 +41,7 @@ SERVICE_SYNC = 'sync' DEFAULT_NUM_REPEATS = 1 DEFAULT_DELAY_SECS = 0.4 +DEFAULT_HOLD_SECS = 0 REMOTE_SERVICE_SCHEMA = vol.Schema({ vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids, @@ -55,6 +57,7 @@ REMOTE_SERVICE_SEND_COMMAND_SCHEMA = REMOTE_SERVICE_SCHEMA.extend({ vol.Optional( ATTR_NUM_REPEATS, default=DEFAULT_NUM_REPEATS): cv.positive_int, vol.Optional(ATTR_DELAY_SECS): vol.Coerce(float), + vol.Optional(ATTR_HOLD_SECS, default=DEFAULT_HOLD_SECS): vol.Coerce(float), }) diff --git a/homeassistant/components/remote/services.yaml b/homeassistant/components/remote/services.yaml index 1fb4b048707..62615f28714 100644 --- a/homeassistant/components/remote/services.yaml +++ b/homeassistant/components/remote/services.yaml @@ -42,6 +42,10 @@ send_command: delay_secs: description: An optional value that specifies that number of seconds you want to wait in between repeated commands. If not specified, the default of 0.4 seconds will be used. example: '0.75' + hold_secs: + description: An optional value that specifies that number of seconds you want to have it held before the release is send. If not specified, the release will be send immediately after the press. + example: '2.5' + harmony_sync: description: Syncs the remote's configuration.