Add entity translations to iCloud (#95461)

pull/97066/head
Joost Lekkerkerker 2023-07-22 16:16:39 +02:00 committed by GitHub
parent fe0d33d97c
commit d708c159e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 10 deletions

View File

@ -56,6 +56,9 @@ def add_entities(account: IcloudAccount, async_add_entities, tracked):
class IcloudTrackerEntity(TrackerEntity): class IcloudTrackerEntity(TrackerEntity):
"""Represent a tracked device.""" """Represent a tracked device."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None: def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None:
"""Set up the iCloud tracker entity.""" """Set up the iCloud tracker entity."""
self._account = account self._account = account
@ -67,11 +70,6 @@ class IcloudTrackerEntity(TrackerEntity):
"""Return a unique ID.""" """Return a unique ID."""
return self._device.unique_id return self._device.unique_id
@property
def name(self) -> str:
"""Return the name of the device."""
return self._device.name
@property @property
def location_accuracy(self): def location_accuracy(self):
"""Return the location accuracy of the device.""" """Return the location accuracy of the device."""

View File

@ -56,6 +56,7 @@ class IcloudDeviceBatterySensor(SensorEntity):
_attr_device_class = SensorDeviceClass.BATTERY _attr_device_class = SensorDeviceClass.BATTERY
_attr_native_unit_of_measurement = PERCENTAGE _attr_native_unit_of_measurement = PERCENTAGE
_attr_should_poll = False _attr_should_poll = False
_attr_has_entity_name = True
def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None: def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None:
"""Initialize the battery sensor.""" """Initialize the battery sensor."""
@ -68,11 +69,6 @@ class IcloudDeviceBatterySensor(SensorEntity):
"""Return a unique ID.""" """Return a unique ID."""
return f"{self._device.unique_id}_battery" return f"{self._device.unique_id}_battery"
@property
def name(self) -> str:
"""Sensor name."""
return f"{self._device.name} battery state"
@property @property
def native_value(self) -> int | None: def native_value(self) -> int | None:
"""Battery state percentage.""" """Battery state percentage."""