From d708c159e748fde3e2a13333c21afbff4b455602 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sat, 22 Jul 2023 16:16:39 +0200 Subject: [PATCH] Add entity translations to iCloud (#95461) --- homeassistant/components/icloud/device_tracker.py | 8 +++----- homeassistant/components/icloud/sensor.py | 6 +----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/icloud/device_tracker.py b/homeassistant/components/icloud/device_tracker.py index d9bd215d2a1..6cabe51fff5 100644 --- a/homeassistant/components/icloud/device_tracker.py +++ b/homeassistant/components/icloud/device_tracker.py @@ -56,6 +56,9 @@ def add_entities(account: IcloudAccount, async_add_entities, tracked): class IcloudTrackerEntity(TrackerEntity): """Represent a tracked device.""" + _attr_has_entity_name = True + _attr_name = None + def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None: """Set up the iCloud tracker entity.""" self._account = account @@ -67,11 +70,6 @@ class IcloudTrackerEntity(TrackerEntity): """Return a unique ID.""" return self._device.unique_id - @property - def name(self) -> str: - """Return the name of the device.""" - return self._device.name - @property def location_accuracy(self): """Return the location accuracy of the device.""" diff --git a/homeassistant/components/icloud/sensor.py b/homeassistant/components/icloud/sensor.py index e7c982607cb..01aabc5871c 100644 --- a/homeassistant/components/icloud/sensor.py +++ b/homeassistant/components/icloud/sensor.py @@ -56,6 +56,7 @@ class IcloudDeviceBatterySensor(SensorEntity): _attr_device_class = SensorDeviceClass.BATTERY _attr_native_unit_of_measurement = PERCENTAGE _attr_should_poll = False + _attr_has_entity_name = True def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None: """Initialize the battery sensor.""" @@ -68,11 +69,6 @@ class IcloudDeviceBatterySensor(SensorEntity): """Return a unique ID.""" return f"{self._device.unique_id}_battery" - @property - def name(self) -> str: - """Sensor name.""" - return f"{self._device.name} battery state" - @property def native_value(self) -> int | None: """Battery state percentage."""