Merge branch 'stability_fixes' of github.com:rospogrigio/localtuya into stability_fixes
This commit is contained in:
@@ -81,7 +81,6 @@ async def async_setup_entry(
|
||||
]
|
||||
|
||||
if entities_to_setup:
|
||||
|
||||
tuyainterface = hass.data[DOMAIN][TUYA_DEVICES][dev_id]
|
||||
|
||||
dps_config_fields = list(get_dps_for_platform(flow_schema))
|
||||
@@ -196,7 +195,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 +232,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 +263,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]}")
|
||||
|
Reference in New Issue
Block a user