Browse Source

fix(services): Complete ir command sending

Copy paste from remote.py was incomplete, and needed some
adjustment for dropping of repeat handling.
Jason Rumney 4 weeks ago
parent
commit
7fe3b59901
1 changed files with 7 additions and 2 deletions
  1. 7 2
      custom_components/tuya_local/services.py

+ 7 - 2
custom_components/tuya_local/services.py

@@ -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
+            )