From 71c4f675e0eb15944fa00b05495b157a6a2cf1aa Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 12 Sep 2023 18:01:05 +0200 Subject: [PATCH] Use shorthand attributes in SPC (#100217) --- homeassistant/components/spc/alarm_control_panel.py | 6 +----- homeassistant/components/spc/binary_sensor.py | 12 ++---------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/spc/alarm_control_panel.py b/homeassistant/components/spc/alarm_control_panel.py index b78703666bc..ace352b2ba0 100644 --- a/homeassistant/components/spc/alarm_control_panel.py +++ b/homeassistant/components/spc/alarm_control_panel.py @@ -64,6 +64,7 @@ class SpcAlarm(alarm.AlarmControlPanelEntity): """Initialize the SPC alarm panel.""" self._area = area self._api = api + self._attr_name = area.name async def async_added_to_hass(self) -> None: """Call for adding new entities.""" @@ -80,11 +81,6 @@ class SpcAlarm(alarm.AlarmControlPanelEntity): """Call update method.""" self.async_schedule_update_ha_state(True) - @property - def name(self) -> str: - """Return the name of the device.""" - return self._area.name - @property def changed_by(self) -> str: """Return the user the last change was triggered by.""" diff --git a/homeassistant/components/spc/binary_sensor.py b/homeassistant/components/spc/binary_sensor.py index c4aaefdd518..a43551567e6 100644 --- a/homeassistant/components/spc/binary_sensor.py +++ b/homeassistant/components/spc/binary_sensor.py @@ -53,6 +53,8 @@ class SpcBinarySensor(BinarySensorEntity): def __init__(self, zone: Zone) -> None: """Initialize the sensor device.""" 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: """Call for adding new entities.""" @@ -69,17 +71,7 @@ class SpcBinarySensor(BinarySensorEntity): """Call update method.""" self.async_schedule_update_ha_state(True) - @property - def name(self) -> str: - """Return the name of the device.""" - return self._zone.name - @property def is_on(self) -> bool: """Whether the device is switched on.""" return self._zone.input == ZoneInput.OPEN - - @property - def device_class(self) -> BinarySensorDeviceClass | None: - """Return the device class.""" - return _get_device_class(self._zone.type)