Use shorthand attributes in iCloud (#99390)

* Use shorthand attributes in iCloud

* Use shorthand attributes in iCloud
pull/99397/head
Joost Lekkerkerker 2023-08-31 12:37:21 +02:00 committed by GitHub
parent 2c545ef3d2
commit 7ead5c44ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 21 deletions

View File

@ -64,11 +64,7 @@ class IcloudTrackerEntity(TrackerEntity):
self._account = account
self._device = device
self._unsub_dispatcher: CALLBACK_TYPE | None = None
@property
def unique_id(self) -> str:
"""Return a unique ID."""
return self._device.unique_id
self._attr_unique_id = device.unique_id
@property
def location_accuracy(self):

View File

@ -63,11 +63,14 @@ class IcloudDeviceBatterySensor(SensorEntity):
self._account = account
self._device = device
self._unsub_dispatcher: CALLBACK_TYPE | None = None
@property
def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._device.unique_id}_battery"
self._attr_unique_id = f"{device.unique_id}_battery"
self._attr_device_info = DeviceInfo(
configuration_url="https://icloud.com/",
identifiers={(DOMAIN, device.unique_id)},
manufacturer="Apple",
model=device.device_model,
name=device.name,
)
@property
def native_value(self) -> int | None:
@ -87,17 +90,6 @@ class IcloudDeviceBatterySensor(SensorEntity):
"""Return default attributes for the iCloud device entity."""
return self._device.extra_state_attributes
@property
def device_info(self) -> DeviceInfo:
"""Return the device information."""
return DeviceInfo(
configuration_url="https://icloud.com/",
identifiers={(DOMAIN, self._device.unique_id)},
manufacturer="Apple",
model=self._device.device_model,
name=self._device.name,
)
async def async_added_to_hass(self) -> None:
"""Register state update callback."""
self._unsub_dispatcher = async_dispatcher_connect(