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
pull/21606/head
ehendrix23 2019-03-02 16:54:03 -07:00 committed by Anders Melchiorsen
parent b8eebda541
commit 833f17de04
3 changed files with 15 additions and 5 deletions

View File

@ -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:

View File

@ -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),
})

View File

@ -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.