YoLink fix cover incorrect state (#104975)

* Fix cover incorrect state

* Change entity to unavailable
pull/113887/head
Matrix 2024-03-20 23:45:21 +08:00 committed by GitHub
parent 0e7e1cb34f
commit 3b0ac469d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -60,11 +60,13 @@ class YoLinkCoverEntity(YoLinkEntity, CoverEntity):
"""Update HA Entity State."""
if (state_val := state.get("state")) is None:
return
if self.coordinator.paired_device is None:
if self.coordinator.paired_device is None or state_val == "error":
self._attr_is_closed = None
self._attr_available = False
self.async_write_ha_state()
elif state_val in ["open", "closed"]:
self._attr_is_closed = state_val == "closed"
self._attr_available = True
self.async_write_ha_state()
async def toggle_garage_state(self) -> None: