1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Use shorthand attributes in August (#99196)

This commit is contained in:
Joost Lekkerkerker 2023-08-28 15:14:38 +02:00 committed by GitHub
parent 1692d83063
commit 61ff53fcf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 29 deletions

View File

@ -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."""

View File

@ -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}"