Skip to content

Commit

Permalink
Hive: Fix error when device goes offline (home-assistant#133848)
Browse files Browse the repository at this point in the history
  • Loading branch information
KJonline authored Dec 24, 2024
1 parent 6fc1cfd commit 33435fa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions homeassistant/components/hive/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ async def async_update(self) -> None:
await self.hive.session.updateData(self.device)
self.device = await self.hive.sensor.getSensor(self.device)
self.attributes = self.device.get("attributes", {})
self._attr_is_on = self.device["status"]["state"]

if self.device["hiveType"] != "Connectivity":
self._attr_available = self.device["deviceData"].get("online")
self._attr_available = (
self.device["deviceData"].get("online") and "status" in self.device
)
else:
self._attr_available = True

if self._attr_available:
self._attr_is_on = self.device["status"].get("state")


class HiveSensorEntity(HiveEntity, BinarySensorEntity):
"""Hive Sensor Entity."""
Expand Down

0 comments on commit 33435fa

Please sign in to comment.