From 33b3b8947a806065b7abed5a12d6ccf60a4e121d Mon Sep 17 00:00:00 2001 From: Renier Moorcroft <66512715+RenierM26@users.noreply.github.com> Date: Wed, 19 Jul 2023 13:26:11 +0200 Subject: [PATCH] Add Ezviz SensorEntity name and translation (#95697) Co-authored-by: Franck Nijhof --- homeassistant/components/ezviz/sensor.py | 47 ++++++++++++++++----- homeassistant/components/ezviz/strings.json | 32 ++++++++++++++ 2 files changed, 69 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/ezviz/sensor.py b/homeassistant/components/ezviz/sensor.py index 1a8bfba21fb7a8..9b19148bdb7f63 100644 --- a/homeassistant/components/ezviz/sensor.py +++ b/homeassistant/components/ezviz/sensor.py @@ -18,7 +18,6 @@ PARALLEL_UPDATES = 1 SENSOR_TYPES: dict[str, SensorEntityDescription] = { - "sw_version": SensorEntityDescription(key="sw_version"), "battery_level": SensorEntityDescription( key="battery_level", native_unit_of_measurement=PERCENTAGE, @@ -26,19 +25,48 @@ ), "alarm_sound_mod": SensorEntityDescription( key="alarm_sound_mod", + translation_key="alarm_sound_mod", + entity_registry_enabled_default=False, + ), + "last_alarm_time": SensorEntityDescription( + key="last_alarm_time", + translation_key="last_alarm_time", entity_registry_enabled_default=False, ), - "last_alarm_time": SensorEntityDescription(key="last_alarm_time"), "Seconds_Last_Trigger": SensorEntityDescription( key="Seconds_Last_Trigger", + translation_key="seconds_last_trigger", entity_registry_enabled_default=False, ), - "supported_channels": SensorEntityDescription(key="supported_channels"), - "local_ip": SensorEntityDescription(key="local_ip"), - "wan_ip": SensorEntityDescription(key="wan_ip"), - "PIR_Status": SensorEntityDescription(key="PIR_Status"), - "last_alarm_type_code": SensorEntityDescription(key="last_alarm_type_code"), - "last_alarm_type_name": SensorEntityDescription(key="last_alarm_type_name"), + "last_alarm_pic": SensorEntityDescription( + key="last_alarm_pic", + translation_key="last_alarm_pic", + entity_registry_enabled_default=False, + ), + "supported_channels": SensorEntityDescription( + key="supported_channels", + translation_key="supported_channels", + ), + "local_ip": SensorEntityDescription( + key="local_ip", + translation_key="local_ip", + ), + "wan_ip": SensorEntityDescription( + key="wan_ip", + translation_key="wan_ip", + ), + "PIR_Status": SensorEntityDescription( + key="PIR_Status", + translation_key="pir_status", + ), + "last_alarm_type_code": SensorEntityDescription( + key="last_alarm_type_code", + translation_key="last_alarm_type_code", + ), + "last_alarm_type_name": SensorEntityDescription( + key="last_alarm_type_name", + translation_key="last_alarm_type_name", + ), } @@ -64,7 +92,7 @@ async def async_setup_entry( class EzvizSensor(EzvizEntity, SensorEntity): """Representation of a EZVIZ sensor.""" - coordinator: EzvizDataUpdateCoordinator + _attr_has_entity_name = True def __init__( self, coordinator: EzvizDataUpdateCoordinator, serial: str, sensor: str @@ -72,7 +100,6 @@ def __init__( """Initialize the sensor.""" super().__init__(coordinator, serial) self._sensor_name = sensor - self._attr_name = f"{self._camera_name} {sensor.title()}" self._attr_unique_id = f"{serial}_{self._camera_name}.{sensor}" self.entity_description = SENSOR_TYPES[sensor] diff --git a/homeassistant/components/ezviz/strings.json b/homeassistant/components/ezviz/strings.json index 94a73fc16cd257..909a9b5f9c0966 100644 --- a/homeassistant/components/ezviz/strings.json +++ b/homeassistant/components/ezviz/strings.json @@ -98,6 +98,38 @@ "last_motion_image": { "name": "Last motion image" } + }, + "sensor": { + "alarm_sound_mod": { + "name": "Alarm sound level" + }, + "last_alarm_time": { + "name": "Last alarm time" + }, + "seconds_last_trigger": { + "name": "Seconds since last trigger" + }, + "last_alarm_pic": { + "name": "Last alarm picture URL" + }, + "supported_channels": { + "name": "Supported channels" + }, + "local_ip": { + "name": "Local IP" + }, + "wan_ip": { + "name": "WAN IP" + }, + "pir_status": { + "name": "PIR status" + }, + "last_alarm_type_code": { + "name": "Last alarm type code" + }, + "last_alarm_type_name": { + "name": "Last alarm type name" + } } }, "services": {