Use shorthand attributes in SPC (#100217)
parent
4e202eb376
commit
71c4f675e0
|
@ -64,6 +64,7 @@ class SpcAlarm(alarm.AlarmControlPanelEntity):
|
||||||
"""Initialize the SPC alarm panel."""
|
"""Initialize the SPC alarm panel."""
|
||||||
self._area = area
|
self._area = area
|
||||||
self._api = api
|
self._api = api
|
||||||
|
self._attr_name = area.name
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call for adding new entities."""
|
"""Call for adding new entities."""
|
||||||
|
@ -80,11 +81,6 @@ class SpcAlarm(alarm.AlarmControlPanelEntity):
|
||||||
"""Call update method."""
|
"""Call update method."""
|
||||||
self.async_schedule_update_ha_state(True)
|
self.async_schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._area.name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def changed_by(self) -> str:
|
def changed_by(self) -> str:
|
||||||
"""Return the user the last change was triggered by."""
|
"""Return the user the last change was triggered by."""
|
||||||
|
|
|
@ -53,6 +53,8 @@ class SpcBinarySensor(BinarySensorEntity):
|
||||||
def __init__(self, zone: Zone) -> None:
|
def __init__(self, zone: Zone) -> None:
|
||||||
"""Initialize the sensor device."""
|
"""Initialize the sensor device."""
|
||||||
self._zone = zone
|
self._zone = zone
|
||||||
|
self._attr_name = zone.name
|
||||||
|
self._attr_device_class = _get_device_class(zone.type)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call for adding new entities."""
|
"""Call for adding new entities."""
|
||||||
|
@ -69,17 +71,7 @@ class SpcBinarySensor(BinarySensorEntity):
|
||||||
"""Call update method."""
|
"""Call update method."""
|
||||||
self.async_schedule_update_ha_state(True)
|
self.async_schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._zone.name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Whether the device is switched on."""
|
"""Whether the device is switched on."""
|
||||||
return self._zone.input == ZoneInput.OPEN
|
return self._zone.input == ZoneInput.OPEN
|
||||||
|
|
||||||
@property
|
|
||||||
def device_class(self) -> BinarySensorDeviceClass | None:
|
|
||||||
"""Return the device class."""
|
|
||||||
return _get_device_class(self._zone.type)
|
|
||||||
|
|
Loading…
Reference in New Issue