From 1f66821256d8911f79c25afb825f688234c86bd0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Thu, 30 Apr 2020 23:08:15 -0500 Subject: [PATCH] Support num_repeats for directv remote (#34982) --- homeassistant/components/directv/remote.py | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/directv/remote.py b/homeassistant/components/directv/remote.py index 776ce7a229b..9665b0aea17 100644 --- a/homeassistant/components/directv/remote.py +++ b/homeassistant/components/directv/remote.py @@ -5,7 +5,7 @@ from typing import Any, Callable, Iterable, List from directv import DIRECTV, DIRECTVError -from homeassistant.components.remote import RemoteEntity +from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType @@ -95,12 +95,15 @@ class DIRECTVRemote(DIRECTVEntity, RemoteEntity): blue, chanup, chandown, prev, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, dash, enter """ - for single_command in command: - try: - await self.dtv.remote(single_command, self._address) - except DIRECTVError: - _LOGGER.exception( - "Sending command %s to device %s failed", - single_command, - self._device_id, - ) + num_repeats = kwargs[ATTR_NUM_REPEATS] + + for _ in range(num_repeats): + for single_command in command: + try: + await self.dtv.remote(single_command, self._address) + except DIRECTVError: + _LOGGER.exception( + "Sending command %s to device %s failed", + single_command, + self._device_id, + )