diff --git a/custom_components/localtuya/coordinator.py b/custom_components/localtuya/coordinator.py index 0dc58ad5a..96e396c37 100644 --- a/custom_components/localtuya/coordinator.py +++ b/custom_components/localtuya/coordinator.py @@ -104,7 +104,7 @@ def is_connecting(self): @property def connected(self): """Return if connected to device.""" - return self._interface is not None + return self._interface and self._interface.is_connected @property def is_subdevice(self): @@ -396,7 +396,7 @@ async def _async_refresh(self, _now): def _dispatch_status(self): signal = f"localtuya_{self._device_config.id}" - async_dispatcher_send(self._hass, signal, self._status) + dispatcher_send(self._hass, signal, self._status) def _handle_event(self, old_status: dict, new_status: dict, deviceID=None): """Handle events in HA when devices updated.""" @@ -434,7 +434,7 @@ def fire_event(event, data: dict): def _shutdown_entities(self, now=None): """Shutdown device entities""" - if self.is_sleep: + if self.is_sleep or self.connected: return if self.is_subdevice: @@ -442,9 +442,8 @@ def _shutdown_entities(self, now=None): else: self.warning(f"Disconnected: waiting for discovery broadcast") - if not self.connected: - signal = f"localtuya_{self._device_config.id}" - dispatcher_send(self._hass, signal, None) + signal = f"localtuya_{self._device_config.id}" + dispatcher_send(self._hass, signal, None) @callback def status_updated(self, status: dict): diff --git a/custom_components/localtuya/manifest.json b/custom_components/localtuya/manifest.json index a752c5751..bd2489e2e 100644 --- a/custom_components/localtuya/manifest.json +++ b/custom_components/localtuya/manifest.json @@ -9,5 +9,5 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/xZetsubou/hass-localtuya/issues", "requirements": [], - "version": "2024.5.0" + "version": "2024.6.0" }