Просмотр исходного кода

fix(services): fix lint errors in new feature addition

Jason Rumney 1 неделя назад
Родитель
Сommit
9391e834b5

+ 0 - 1
custom_components/tuya_local/__init__.py

@@ -909,7 +909,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
         return False
 
     entities = set()
-    has_remote = False
     for e in device_conf.all_entities():
         entities.add(e.entity)
 

+ 1 - 2
custom_components/tuya_local/remote.py

@@ -13,7 +13,7 @@ from itertools import product
 from typing import Any
 
 import voluptuous as vol
-from homeassistant.components import infrared, persistent_notification
+from homeassistant.components import persistent_notification
 from homeassistant.components.remote import (
     ATTR_ALTERNATIVE,
     ATTR_COMMAND_TYPE,
@@ -37,7 +37,6 @@ from .device import TuyaLocalDevice
 from .entity import TuyaLocalEntity
 from .helpers.config import async_tuya_setup_platform
 from .helpers.device_config import TuyaEntityConfig
-from .infrared import TuyaRemoteCommand
 
 _LOGGER = logging.getLogger(__name__)
 

+ 8 - 4
custom_components/tuya_local/services.py

@@ -1,14 +1,16 @@
 """Services for Tuya Local integration."""
 
+import asyncio
 import voluptuous as vol
 
+import homeassistant.components.infrared
 from homeassistant.components.remote import (
     DOMAIN as REMOTE_DOMAIN,
     ATTR_DELAY_SECS,
     DEFAULT_DELAY_SECS,
 )
 from homeassistant.core import HomeAssistant, ServiceCall
-from homeassistant.helpers import entity_registry as er, service
+from homeassistant.helpers import service
 
 from .const import DOMAIN
 from .remote import TuyaLocalRemote
@@ -22,6 +24,8 @@ REMOTE_SEND_IR_COMMAND_SCHEMA = vol.Schema(
     }
 )
 
+_LOGGER = logging.getLogger(__name__)
+
 
 async def async_setup_services(hass: HomeAssistant, entities: list[str]):
     """Set up services for the Tuya Local integration."""
@@ -52,12 +56,12 @@ async def async_handle_send_ir_command(entity, call: ServiceCall):
     delay = call.data.get(ATTR_DELAY_SECS, DEFAULT_DELAY_SECS)
     entity._extract_codes([command], subdevice=device)  # Validate command and get code
     at_least_one_sent = False
-    for _, codes in product(range(repeat), code_list):
+    for _, codes in code_list:
         if at_least_one_sent:
             await asyncio.sleep(delay)
         if len(codes) > 1:
-            code = codes[entity._flags[subdevice]]
-            self._flags[subdevice] ^= 1
+            code = codes[entity._flags[device]]
+            entity._flags[device] ^= 1
         else:
             code = codes[0]
         if code.startswith("rf:"):