diff --git a/homeassistant/components/abode/__init__.py b/homeassistant/components/abode/__init__.py index 4e7709f9bf7..be474661eac 100644 --- a/homeassistant/components/abode/__init__.py +++ b/homeassistant/components/abode/__init__.py @@ -251,17 +251,13 @@ class AbodeEntity(Entity): """Initialize Abode entity.""" self._data = data self._available = True + self._attr_should_poll = data.polling @property def available(self): """Return the available state.""" return self._available - @property - def should_poll(self): - """Return the polling state.""" - return self._data.polling - async def async_added_to_hass(self): """Subscribe to Abode connection status updates.""" await self.hass.async_add_executor_job( @@ -291,6 +287,8 @@ class AbodeDevice(AbodeEntity): """Initialize Abode device.""" super().__init__(data) self._device = device + self._attr_name = device.name + self._attr_unique_id = device.device_uuid async def async_added_to_hass(self): """Subscribe to device events.""" @@ -312,11 +310,6 @@ class AbodeDevice(AbodeEntity): """Update device state.""" self._device.refresh() - @property - def name(self): - """Return the name of the device.""" - return self._device.name - @property def extra_state_attributes(self): """Return the state attributes.""" @@ -328,11 +321,6 @@ class AbodeDevice(AbodeEntity): "device_type": self._device.type, } - @property - def unique_id(self): - """Return a unique ID to use for this device.""" - return self._device.device_uuid - @property def device_info(self): """Return device registry information for this entity.""" @@ -355,22 +343,13 @@ class AbodeAutomation(AbodeEntity): """Initialize for Abode automation.""" super().__init__(data) self._automation = automation + self._attr_name = automation.name + self._attr_unique_id = automation.automation_id + self._attr_extra_state_attributes = { + ATTR_ATTRIBUTION: ATTRIBUTION, + "type": "CUE automation", + } def update(self): """Update automation state.""" self._automation.refresh() - - @property - def name(self): - """Return the name of the automation.""" - return self._automation.name - - @property - def extra_state_attributes(self): - """Return the state attributes.""" - return {ATTR_ATTRIBUTION: ATTRIBUTION, "type": "CUE automation"} - - @property - def unique_id(self): - """Return a unique ID to use for this automation.""" - return self._automation.automation_id diff --git a/homeassistant/components/abode/alarm_control_panel.py b/homeassistant/components/abode/alarm_control_panel.py index 6d0c030e3e1..0cc1b500ff4 100644 --- a/homeassistant/components/abode/alarm_control_panel.py +++ b/homeassistant/components/abode/alarm_control_panel.py @@ -28,10 +28,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities): class AbodeAlarm(AbodeDevice, alarm.AlarmControlPanelEntity): """An alarm_control_panel implementation for Abode.""" - @property - def icon(self): - """Return the icon.""" - return ICON + _attr_icon = ICON + _attr_code_arm_required = False + _attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY @property def state(self): @@ -46,16 +45,6 @@ class AbodeAlarm(AbodeDevice, alarm.AlarmControlPanelEntity): state = None return state - @property - def code_arm_required(self): - """Whether the code is required for arm actions.""" - return False - - @property - def supported_features(self) -> int: - """Return the list of supported features.""" - return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY - def alarm_disarm(self, code=None): """Send disarm command.""" self._device.set_standby() diff --git a/homeassistant/components/abode/sensor.py b/homeassistant/components/abode/sensor.py index e3ececb62d9..f1f744a5511 100644 --- a/homeassistant/components/abode/sensor.py +++ b/homeassistant/components/abode/sensor.py @@ -41,23 +41,15 @@ class AbodeSensor(AbodeDevice, SensorEntity): """Initialize a sensor for an Abode device.""" super().__init__(data, device) self._sensor_type = sensor_type - self._name = f"{self._device.name} {SENSOR_TYPES[self._sensor_type][0]}" - self._device_class = SENSOR_TYPES[self._sensor_type][1] - - @property - def name(self): - """Return the name of the sensor.""" - return self._name - - @property - def device_class(self): - """Return the device class.""" - return self._device_class - - @property - def unique_id(self): - """Return a unique ID to use for this device.""" - return f"{self._device.device_uuid}-{self._sensor_type}" + self._attr_name = f"{device.name} {SENSOR_TYPES[sensor_type][0]}" + self._attr_device_class = SENSOR_TYPES[self._sensor_type][1] + self._attr_unique_id = f"{device.device_uuid}-{sensor_type}" + if self._sensor_type == CONST.TEMP_STATUS_KEY: + self._attr_unit_of_measurement = device.temp_unit + elif self._sensor_type == CONST.HUMI_STATUS_KEY: + self._attr_unit_of_measurement = device.humidity_unit + elif self._sensor_type == CONST.LUX_STATUS_KEY: + self._attr_unit_of_measurement = device.lux_unit @property def state(self): @@ -68,13 +60,3 @@ class AbodeSensor(AbodeDevice, SensorEntity): return self._device.humidity if self._sensor_type == CONST.LUX_STATUS_KEY: return self._device.lux - - @property - def unit_of_measurement(self): - """Return the units of measurement.""" - if self._sensor_type == CONST.TEMP_STATUS_KEY: - return self._device.temp_unit - if self._sensor_type == CONST.HUMI_STATUS_KEY: - return self._device.humidity_unit - if self._sensor_type == CONST.LUX_STATUS_KEY: - return self._device.lux_unit diff --git a/homeassistant/components/abode/switch.py b/homeassistant/components/abode/switch.py index 0985ce5ce2a..75c13962c43 100644 --- a/homeassistant/components/abode/switch.py +++ b/homeassistant/components/abode/switch.py @@ -48,6 +48,8 @@ class AbodeSwitch(AbodeDevice, SwitchEntity): class AbodeAutomationSwitch(AbodeAutomation, SwitchEntity): """A switch implementation for Abode automations.""" + _attr_icon = ICON + async def async_added_to_hass(self): """Set up trigger automation service.""" await super().async_added_to_hass() @@ -73,8 +75,3 @@ class AbodeAutomationSwitch(AbodeAutomation, SwitchEntity): def is_on(self): """Return True if the automation is enabled.""" return self._automation.is_enabled - - @property - def icon(self): - """Return the robot icon to match Home Assistant automations.""" - return ICON