From 86f94662eb2909cadaa658ba225914bfdee0af47 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Thu, 10 Aug 2023 23:49:14 +0200 Subject: [PATCH] Add entity translations to EZVIZ (#98123) --- homeassistant/components/ezviz/binary_sensor.py | 2 -- homeassistant/components/ezviz/button.py | 1 - homeassistant/components/ezviz/camera.py | 3 ++- homeassistant/components/ezviz/entity.py | 2 ++ homeassistant/components/ezviz/image.py | 2 -- homeassistant/components/ezviz/light.py | 3 +-- homeassistant/components/ezviz/number.py | 2 +- homeassistant/components/ezviz/select.py | 2 -- homeassistant/components/ezviz/sensor.py | 2 -- homeassistant/components/ezviz/strings.json | 15 +++++++++++++++ homeassistant/components/ezviz/switch.py | 2 -- homeassistant/components/ezviz/update.py | 3 +-- 12 files changed, 22 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/ezviz/binary_sensor.py b/homeassistant/components/ezviz/binary_sensor.py index 3ed61d8fc3d..81697e2772c 100644 --- a/homeassistant/components/ezviz/binary_sensor.py +++ b/homeassistant/components/ezviz/binary_sensor.py @@ -54,8 +54,6 @@ async def async_setup_entry( class EzvizBinarySensor(EzvizEntity, BinarySensorEntity): """Representation of a EZVIZ sensor.""" - _attr_has_entity_name = True - def __init__( self, coordinator: EzvizDataUpdateCoordinator, diff --git a/homeassistant/components/ezviz/button.py b/homeassistant/components/ezviz/button.py index 1c04de956c6..2199f82a476 100644 --- a/homeassistant/components/ezviz/button.py +++ b/homeassistant/components/ezviz/button.py @@ -103,7 +103,6 @@ class EzvizButtonEntity(EzvizEntity, ButtonEntity): """Representation of a EZVIZ button entity.""" entity_description: EzvizButtonEntityDescription - _attr_has_entity_name = True def __init__( self, diff --git a/homeassistant/components/ezviz/camera.py b/homeassistant/components/ezviz/camera.py index 7f03aef1d97..083e433952f 100644 --- a/homeassistant/components/ezviz/camera.py +++ b/homeassistant/components/ezviz/camera.py @@ -170,6 +170,8 @@ async def async_setup_entry( class EzvizCamera(EzvizEntity, Camera): """An implementation of a EZVIZ security camera.""" + _attr_name = None + def __init__( self, hass: HomeAssistant, @@ -192,7 +194,6 @@ class EzvizCamera(EzvizEntity, Camera): self._ffmpeg_arguments = ffmpeg_arguments self._ffmpeg = get_ffmpeg_manager(hass) self._attr_unique_id = serial - self._attr_name = self.data["name"] if camera_password: self._attr_supported_features = CameraEntityFeature.STREAM diff --git a/homeassistant/components/ezviz/entity.py b/homeassistant/components/ezviz/entity.py index ccf273a970b..d3720170c29 100644 --- a/homeassistant/components/ezviz/entity.py +++ b/homeassistant/components/ezviz/entity.py @@ -14,6 +14,8 @@ from .coordinator import EzvizDataUpdateCoordinator class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity): """Generic entity encapsulating common features of EZVIZ device.""" + _attr_has_entity_name = True + def __init__( self, coordinator: EzvizDataUpdateCoordinator, diff --git a/homeassistant/components/ezviz/image.py b/homeassistant/components/ezviz/image.py index 3de4f55a9d4..aeb8eafe68f 100644 --- a/homeassistant/components/ezviz/image.py +++ b/homeassistant/components/ezviz/image.py @@ -38,8 +38,6 @@ async def async_setup_entry( class EzvizLastMotion(EzvizEntity, ImageEntity): """Return Last Motion Image from Ezviz Camera.""" - _attr_has_entity_name = True - def __init__( self, hass: HomeAssistant, coordinator: EzvizDataUpdateCoordinator, serial: str ) -> None: diff --git a/homeassistant/components/ezviz/light.py b/homeassistant/components/ezviz/light.py index 9702959649d..558072658d3 100644 --- a/homeassistant/components/ezviz/light.py +++ b/homeassistant/components/ezviz/light.py @@ -44,7 +44,7 @@ async def async_setup_entry( class EzvizLight(EzvizEntity, LightEntity): """Representation of a EZVIZ light.""" - _attr_has_entity_name = True + _attr_translation_key = "light" _attr_color_mode = ColorMode.BRIGHTNESS _attr_supported_color_modes = {ColorMode.BRIGHTNESS} @@ -60,7 +60,6 @@ class EzvizLight(EzvizEntity, LightEntity): == DeviceCatagories.BATTERY_CAMERA_DEVICE_CATEGORY.value ) self._attr_unique_id = f"{serial}_Light" - self._attr_name = "Light" self._attr_is_on = self.data["switches"][DeviceSwitchType.ALARM_LIGHT.value] self._attr_brightness = round( percentage_to_ranged_value( diff --git a/homeassistant/components/ezviz/number.py b/homeassistant/components/ezviz/number.py index 74d496ef6c1..e4d39894d85 100644 --- a/homeassistant/components/ezviz/number.py +++ b/homeassistant/components/ezviz/number.py @@ -47,7 +47,7 @@ class EzvizNumberEntityDescription( NUMBER_TYPE = EzvizNumberEntityDescription( key="detection_sensibility", - name="Detection sensitivity", + translation_key="detection_sensibility", icon="mdi:eye", entity_category=EntityCategory.CONFIG, native_min_value=0, diff --git a/homeassistant/components/ezviz/select.py b/homeassistant/components/ezviz/select.py index ef1dd785392..369a429dbe6 100644 --- a/homeassistant/components/ezviz/select.py +++ b/homeassistant/components/ezviz/select.py @@ -63,8 +63,6 @@ async def async_setup_entry( class EzvizSelect(EzvizEntity, SelectEntity): """Representation of a EZVIZ select entity.""" - _attr_has_entity_name = True - def __init__( self, coordinator: EzvizDataUpdateCoordinator, diff --git a/homeassistant/components/ezviz/sensor.py b/homeassistant/components/ezviz/sensor.py index 9b19148bdb7..aecf25c2c78 100644 --- a/homeassistant/components/ezviz/sensor.py +++ b/homeassistant/components/ezviz/sensor.py @@ -92,8 +92,6 @@ async def async_setup_entry( class EzvizSensor(EzvizEntity, SensorEntity): """Representation of a EZVIZ sensor.""" - _attr_has_entity_name = True - def __init__( self, coordinator: EzvizDataUpdateCoordinator, serial: str, sensor: str ) -> None: diff --git a/homeassistant/components/ezviz/strings.json b/homeassistant/components/ezviz/strings.json index 590f95029c6..3e8797e7c02 100644 --- a/homeassistant/components/ezviz/strings.json +++ b/homeassistant/components/ezviz/strings.json @@ -132,6 +132,16 @@ "name": "Encryption" } }, + "light": { + "light": { + "name": "[%key:component::light::title%]" + } + }, + "number": { + "detection_sensibility": { + "name": "Detection sensitivity" + } + }, "sensor": { "alarm_sound_mod": { "name": "Alarm sound level" @@ -201,6 +211,11 @@ "follow_movement": { "name": "Follow movement" } + }, + "update": { + "firmware": { + "name": "[%key:component::update::entity_component::firmware::name%]" + } } }, "services": { diff --git a/homeassistant/components/ezviz/switch.py b/homeassistant/components/ezviz/switch.py index 337a7080506..4089b0ae393 100644 --- a/homeassistant/components/ezviz/switch.py +++ b/homeassistant/components/ezviz/switch.py @@ -134,8 +134,6 @@ async def async_setup_entry( class EzvizSwitch(EzvizEntity, SwitchEntity): """Representation of a EZVIZ sensor.""" - _attr_has_entity_name = True - def __init__( self, coordinator: EzvizDataUpdateCoordinator, serial: str, switch_number: int ) -> None: diff --git a/homeassistant/components/ezviz/update.py b/homeassistant/components/ezviz/update.py index 3acc1032514..6a80a579080 100644 --- a/homeassistant/components/ezviz/update.py +++ b/homeassistant/components/ezviz/update.py @@ -24,7 +24,7 @@ PARALLEL_UPDATES = 1 UPDATE_ENTITY_TYPES = UpdateEntityDescription( key="version", - name="Firmware update", + translation_key="firmware", device_class=UpdateDeviceClass.FIRMWARE, ) @@ -49,7 +49,6 @@ async def async_setup_entry( class EzvizUpdateEntity(EzvizEntity, UpdateEntity): """Representation of a EZVIZ Update entity.""" - _attr_has_entity_name = True _attr_supported_features = ( UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS