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:
parent
0c9a30ab69
commit
114bf0da34
6 changed files with 50 additions and 64 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue