Use shorthand attributes in Vera (#99893)
This commit is contained in:
parent
6b265120b3
commit
e143bdf2f5
7 changed files with 34 additions and 80 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue