|
|
@@ -16,7 +16,7 @@ from homeassistant.helpers import service
|
|
|
|
|
|
from .const import DOMAIN
|
|
|
from .infrared import TuyaRemoteCommand
|
|
|
-from .remote import TuyaLocalRemote
|
|
|
+from .remote import TuyaLocalRemote, FLAG_SAVE_DELAY
|
|
|
|
|
|
REMOTE_SEND_IR_COMMAND_SCHEMA = {
|
|
|
vol.Required("emitter_entity_id"): cv.entity_id,
|
|
|
@@ -58,7 +58,7 @@ async def async_handle_send_ir_command(entity, call: ServiceCall):
|
|
|
[command], subdevice=device
|
|
|
) # Validate command and get code
|
|
|
at_least_one_sent = False
|
|
|
- for _, codes in code_list:
|
|
|
+ for codes in code_list:
|
|
|
if at_least_one_sent:
|
|
|
await asyncio.sleep(delay)
|
|
|
if len(codes) > 1:
|
|
|
@@ -73,3 +73,8 @@ async def async_handle_send_ir_command(entity, call: ServiceCall):
|
|
|
entity.hass, emitter, cmd=TuyaRemoteCommand(code=code)
|
|
|
)
|
|
|
at_least_one_sent = True
|
|
|
+
|
|
|
+ if at_least_one_sent:
|
|
|
+ entity._flag_storage.async_delay_save(
|
|
|
+ lambda: entity._flags, FLAG_SAVE_DELAY
|
|
|
+ )
|