Update Lutron in callback (#108779)

* Update Lutron in callback

* Update Lutron in callback

* Remove abstractmethod

* Don't do IO in constructor

* Split fetching and setting
This commit is contained in:
Joost Lekkerkerker 2024-01-25 12:54:31 +01:00 committed by GitHub
parent 0c9a30ab69
commit 114bf0da34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 50 additions and 64 deletions

View file

@ -52,13 +52,11 @@ class LutronOccupancySensor(LutronDevice, BinarySensorEntity):
_lutron_device: OccupancyGroup
_attr_device_class = BinarySensorDeviceClass.OCCUPANCY
@property
def is_on(self) -> bool:
"""Return true if the binary sensor is on."""
# Error cases will end up treated as unoccupied.
return self._lutron_device.state == OccupancyGroup.State.OCCUPIED
@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Return the state attributes."""
return {"lutron_integration_id": self._lutron_device.id}
def _update_attrs(self) -> None:
"""Update the state attributes."""
self._attr_is_on = self._lutron_device.state == OccupancyGroup.State.OCCUPIED