Use shorthand attributes in Vera (#99893)

This commit is contained in:
Joost Lekkerkerker 2023-09-12 15:23:12 +02:00 committed by GitHub
parent 6b265120b3
commit e143bdf2f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 80 deletions

View file

@ -32,20 +32,16 @@ async def async_setup_entry(
class VeraBinarySensor(VeraDevice[veraApi.VeraBinarySensor], BinarySensorEntity):
"""Representation of a Vera Binary Sensor."""
_attr_is_on = False
def __init__(
self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData
) -> None:
"""Initialize the binary_sensor."""
self._state = False
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
@property
def is_on(self) -> bool | None:
"""Return true if sensor is on."""
return self._state
def update(self) -> None:
"""Get the latest data and update the state."""
super().update()
self._state = self.vera_device.is_tripped
self._attr_is_on = self.vera_device.is_tripped