Use shorthand attributes for EnOcean (#99278)

This commit is contained in:
Joost Lekkerkerker 2023-08-30 11:57:56 +02:00 committed by GitHub
parent 38267699e5
commit 7d70b42e4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 61 deletions

View file

@ -60,21 +60,12 @@ class EnOceanBinarySensor(EnOceanEntity, BinarySensorEntity):
device_class: BinarySensorDeviceClass | None,
) -> None:
"""Initialize the EnOcean binary sensor."""
super().__init__(dev_id, dev_name)
self._device_class = device_class
super().__init__(dev_id)
self._attr_device_class = device_class
self.which = -1
self.onoff = -1
self._attr_unique_id = f"{combine_hex(dev_id)}-{device_class}"
@property
def name(self):
"""Return the default name for the binary sensor."""
return self.dev_name
@property
def device_class(self):
"""Return the class of this sensor."""
return self._device_class
self._attr_name = dev_name
def value_changed(self, packet):
"""Fire an event with the data that have changed.