From 61ff53fcf7e7297658b756bf3ad086f825cd2aa9 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 28 Aug 2023 15:14:38 +0200 Subject: [PATCH] Use shorthand attributes in August (#99196) --- homeassistant/components/august/camera.py | 12 ++---------- homeassistant/components/august/sensor.py | 23 ++++------------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/homeassistant/components/august/camera.py b/homeassistant/components/august/camera.py index 4c3c124953ab..e618c2d49d51 100644 --- a/homeassistant/components/august/camera.py +++ b/homeassistant/components/august/camera.py @@ -45,22 +45,14 @@ class AugustCamera(AugustEntityMixin, Camera): self._image_url = None self._image_content = None self._attr_unique_id = f"{self._device_id:s}_camera" + self._attr_motion_detection_enabled = True + self._attr_brand = DEFAULT_NAME @property def is_recording(self) -> bool: """Return true if the device is recording.""" return self._device.has_subscription - @property - def motion_detection_enabled(self) -> bool: - """Return the camera motion detection status.""" - return True - - @property - def brand(self): - """Return the camera brand.""" - return DEFAULT_NAME - @property def model(self): """Return the camera model.""" diff --git a/homeassistant/components/august/sensor.py b/homeassistant/components/august/sensor.py index 2c688ae76159..12ed3a885580 100644 --- a/homeassistant/components/august/sensor.py +++ b/homeassistant/components/august/sensor.py @@ -185,7 +185,7 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, SensorEntity): self._operated_keypad = None self._operated_autorelock = None self._operated_time = None - self._entity_picture = None + self._attr_unique_id = f"{self._device_id}_lock_operator" self._update_from_data() @callback @@ -201,7 +201,7 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, SensorEntity): self._operated_remote = lock_activity.operated_remote self._operated_keypad = lock_activity.operated_keypad self._operated_autorelock = lock_activity.operated_autorelock - self._entity_picture = lock_activity.operator_thumbnail_url + self._attr_entity_picture = lock_activity.operator_thumbnail_url @property def extra_state_attributes(self): @@ -236,7 +236,7 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, SensorEntity): self._attr_native_value = last_state.state if ATTR_ENTITY_PICTURE in last_state.attributes: - self._entity_picture = last_state.attributes[ATTR_ENTITY_PICTURE] + self._attr_entity_picture = last_state.attributes[ATTR_ENTITY_PICTURE] if ATTR_OPERATION_REMOTE in last_state.attributes: self._operated_remote = last_state.attributes[ATTR_OPERATION_REMOTE] if ATTR_OPERATION_KEYPAD in last_state.attributes: @@ -244,16 +244,6 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, SensorEntity): if ATTR_OPERATION_AUTORELOCK in last_state.attributes: self._operated_autorelock = last_state.attributes[ATTR_OPERATION_AUTORELOCK] - @property - def entity_picture(self): - """Return the entity picture to use in the frontend, if any.""" - return self._entity_picture - - @property - def unique_id(self) -> str: - """Get the unique id of the device sensor.""" - return f"{self._device_id}_lock_operator" - class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[_T]): """Representation of an August sensor.""" @@ -272,8 +262,8 @@ class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[_T]): """Initialize the sensor.""" super().__init__(data, device) self.entity_description = description - self._old_device = old_device self._attr_unique_id = f"{self._device_id}_{description.key}" + self.old_unique_id = f"{old_device.device_id}_{description.key}" self._update_from_data() @callback @@ -281,8 +271,3 @@ class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[_T]): """Get the latest state of the sensor.""" self._attr_native_value = self.entity_description.value_fn(self._detail) self._attr_available = self._attr_native_value is not None - - @property - def old_unique_id(self) -> str: - """Get the old unique id of the device sensor.""" - return f"{self._old_device.device_id}_{self.entity_description.key}"