diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index 547bad3..1018934 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -196,7 +196,9 @@ class TuyaDevice(pytuya.TuyaListener, pytuya.ContextualLogger): ) self._interface.add_dps_to_request(self.dps_to_request) except Exception: # pylint: disable=broad-except - self.warning(f"Connect to {self._dev_config_entry[CONF_HOST]} failed attempting to connect") + self.warning( + f"Connect to {self._dev_config_entry[CONF_HOST]} failed attempting to connect" + ) if self._interface is not None: await self._interface.close() self._interface = None @@ -231,14 +233,10 @@ class TuyaDevice(pytuya.TuyaListener, pytuya.ContextualLogger): self._interface.start_heartbeat() self.status_updated(status) else: - self.error( - f"Initial state update failed, giving up: %r", ex - ) + self.error(f"Initial state update failed, giving up: %r", ex) # return except (UnicodeDecodeError, json.decoder.JSONDecodeError) as ex: - self.exception( - f"Initial state update failed, trying key update" - ) + self.exception(f"Initial state update failed, trying key update") await self.update_local_key() if self._interface is not None: @@ -266,12 +264,12 @@ class TuyaDevice(pytuya.TuyaListener, pytuya.ContextualLogger): if ( CONF_SCAN_INTERVAL in self._dev_config_entry - and self._dev_config_entry[CONF_SCAN_INTERVAL] > 0 + and int(self._dev_config_entry[CONF_SCAN_INTERVAL]) > 0 ): self._unsub_interval = async_track_time_interval( self._hass, self._async_refresh, - timedelta(seconds=self._dev_config_entry[CONF_SCAN_INTERVAL]), + timedelta(seconds=int(self._dev_config_entry[CONF_SCAN_INTERVAL])), ) self.info(f"Successfully connected to {self._dev_config_entry[CONF_HOST]}") diff --git a/custom_components/localtuya/config_flow.py b/custom_components/localtuya/config_flow.py index 09374e5..0e72e09 100644 --- a/custom_components/localtuya/config_flow.py +++ b/custom_components/localtuya/config_flow.py @@ -140,7 +140,7 @@ def options_schema(entities): ["3.1", "3.2", "3.3", "3.4"] ), vol.Required(CONF_ENABLE_DEBUG, default=False): bool, - vol.Optional(CONF_SCAN_INTERVAL): cv.string, + vol.Optional(CONF_SCAN_INTERVAL): int, vol.Optional(CONF_MANUAL_DPS): cv.string, vol.Optional(CONF_RESET_DPIDS): cv.string, vol.Required( diff --git a/custom_components/localtuya/pytuya/__init__.py b/custom_components/localtuya/pytuya/__init__.py index a6870cd..cfa0618 100644 --- a/custom_components/localtuya/pytuya/__init__.py +++ b/custom_components/localtuya/pytuya/__init__.py @@ -449,7 +449,9 @@ class MessageDispatcher(ContextualLogger): try: await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) except asyncio.TimeoutError: - self.warning("Command %d timed out waiting for sequence number %d", cmd, seqno) + self.warning( + "Command %d timed out waiting for sequence number %d", cmd, seqno + ) del self.listeners[seqno] raise