Add entity translations to EZVIZ (#98123)

This commit is contained in:
Joost Lekkerkerker 2023-08-10 23:49:14 +02:00 committed by GitHub
parent aacb8aecfc
commit 86f94662eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 17 deletions

View File

@ -54,8 +54,6 @@ async def async_setup_entry(
class EzvizBinarySensor(EzvizEntity, BinarySensorEntity): class EzvizBinarySensor(EzvizEntity, BinarySensorEntity):
"""Representation of a EZVIZ sensor.""" """Representation of a EZVIZ sensor."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: EzvizDataUpdateCoordinator, coordinator: EzvizDataUpdateCoordinator,

View File

@ -103,7 +103,6 @@ class EzvizButtonEntity(EzvizEntity, ButtonEntity):
"""Representation of a EZVIZ button entity.""" """Representation of a EZVIZ button entity."""
entity_description: EzvizButtonEntityDescription entity_description: EzvizButtonEntityDescription
_attr_has_entity_name = True
def __init__( def __init__(
self, self,

View File

@ -170,6 +170,8 @@ async def async_setup_entry(
class EzvizCamera(EzvizEntity, Camera): class EzvizCamera(EzvizEntity, Camera):
"""An implementation of a EZVIZ security camera.""" """An implementation of a EZVIZ security camera."""
_attr_name = None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
@ -192,7 +194,6 @@ class EzvizCamera(EzvizEntity, Camera):
self._ffmpeg_arguments = ffmpeg_arguments self._ffmpeg_arguments = ffmpeg_arguments
self._ffmpeg = get_ffmpeg_manager(hass) self._ffmpeg = get_ffmpeg_manager(hass)
self._attr_unique_id = serial self._attr_unique_id = serial
self._attr_name = self.data["name"]
if camera_password: if camera_password:
self._attr_supported_features = CameraEntityFeature.STREAM self._attr_supported_features = CameraEntityFeature.STREAM

View File

@ -14,6 +14,8 @@ from .coordinator import EzvizDataUpdateCoordinator
class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity): class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity):
"""Generic entity encapsulating common features of EZVIZ device.""" """Generic entity encapsulating common features of EZVIZ device."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: EzvizDataUpdateCoordinator, coordinator: EzvizDataUpdateCoordinator,

View File

@ -38,8 +38,6 @@ async def async_setup_entry(
class EzvizLastMotion(EzvizEntity, ImageEntity): class EzvizLastMotion(EzvizEntity, ImageEntity):
"""Return Last Motion Image from Ezviz Camera.""" """Return Last Motion Image from Ezviz Camera."""
_attr_has_entity_name = True
def __init__( def __init__(
self, hass: HomeAssistant, coordinator: EzvizDataUpdateCoordinator, serial: str self, hass: HomeAssistant, coordinator: EzvizDataUpdateCoordinator, serial: str
) -> None: ) -> None:

View File

@ -44,7 +44,7 @@ async def async_setup_entry(
class EzvizLight(EzvizEntity, LightEntity): class EzvizLight(EzvizEntity, LightEntity):
"""Representation of a EZVIZ light.""" """Representation of a EZVIZ light."""
_attr_has_entity_name = True _attr_translation_key = "light"
_attr_color_mode = ColorMode.BRIGHTNESS _attr_color_mode = ColorMode.BRIGHTNESS
_attr_supported_color_modes = {ColorMode.BRIGHTNESS} _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
@ -60,7 +60,6 @@ class EzvizLight(EzvizEntity, LightEntity):
== DeviceCatagories.BATTERY_CAMERA_DEVICE_CATEGORY.value == DeviceCatagories.BATTERY_CAMERA_DEVICE_CATEGORY.value
) )
self._attr_unique_id = f"{serial}_Light" self._attr_unique_id = f"{serial}_Light"
self._attr_name = "Light"
self._attr_is_on = self.data["switches"][DeviceSwitchType.ALARM_LIGHT.value] self._attr_is_on = self.data["switches"][DeviceSwitchType.ALARM_LIGHT.value]
self._attr_brightness = round( self._attr_brightness = round(
percentage_to_ranged_value( percentage_to_ranged_value(

View File

@ -47,7 +47,7 @@ class EzvizNumberEntityDescription(
NUMBER_TYPE = EzvizNumberEntityDescription( NUMBER_TYPE = EzvizNumberEntityDescription(
key="detection_sensibility", key="detection_sensibility",
name="Detection sensitivity", translation_key="detection_sensibility",
icon="mdi:eye", icon="mdi:eye",
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
native_min_value=0, native_min_value=0,

View File

@ -63,8 +63,6 @@ async def async_setup_entry(
class EzvizSelect(EzvizEntity, SelectEntity): class EzvizSelect(EzvizEntity, SelectEntity):
"""Representation of a EZVIZ select entity.""" """Representation of a EZVIZ select entity."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: EzvizDataUpdateCoordinator, coordinator: EzvizDataUpdateCoordinator,

View File

@ -92,8 +92,6 @@ async def async_setup_entry(
class EzvizSensor(EzvizEntity, SensorEntity): class EzvizSensor(EzvizEntity, SensorEntity):
"""Representation of a EZVIZ sensor.""" """Representation of a EZVIZ sensor."""
_attr_has_entity_name = True
def __init__( def __init__(
self, coordinator: EzvizDataUpdateCoordinator, serial: str, sensor: str self, coordinator: EzvizDataUpdateCoordinator, serial: str, sensor: str
) -> None: ) -> None:

View File

@ -132,6 +132,16 @@
"name": "Encryption" "name": "Encryption"
} }
}, },
"light": {
"light": {
"name": "[%key:component::light::title%]"
}
},
"number": {
"detection_sensibility": {
"name": "Detection sensitivity"
}
},
"sensor": { "sensor": {
"alarm_sound_mod": { "alarm_sound_mod": {
"name": "Alarm sound level" "name": "Alarm sound level"
@ -201,6 +211,11 @@
"follow_movement": { "follow_movement": {
"name": "Follow movement" "name": "Follow movement"
} }
},
"update": {
"firmware": {
"name": "[%key:component::update::entity_component::firmware::name%]"
}
} }
}, },
"services": { "services": {

View File

@ -134,8 +134,6 @@ async def async_setup_entry(
class EzvizSwitch(EzvizEntity, SwitchEntity): class EzvizSwitch(EzvizEntity, SwitchEntity):
"""Representation of a EZVIZ sensor.""" """Representation of a EZVIZ sensor."""
_attr_has_entity_name = True
def __init__( def __init__(
self, coordinator: EzvizDataUpdateCoordinator, serial: str, switch_number: int self, coordinator: EzvizDataUpdateCoordinator, serial: str, switch_number: int
) -> None: ) -> None:

View File

@ -24,7 +24,7 @@ PARALLEL_UPDATES = 1
UPDATE_ENTITY_TYPES = UpdateEntityDescription( UPDATE_ENTITY_TYPES = UpdateEntityDescription(
key="version", key="version",
name="Firmware update", translation_key="firmware",
device_class=UpdateDeviceClass.FIRMWARE, device_class=UpdateDeviceClass.FIRMWARE,
) )
@ -49,7 +49,6 @@ async def async_setup_entry(
class EzvizUpdateEntity(EzvizEntity, UpdateEntity): class EzvizUpdateEntity(EzvizEntity, UpdateEntity):
"""Representation of a EZVIZ Update entity.""" """Representation of a EZVIZ Update entity."""
_attr_has_entity_name = True
_attr_supported_features = ( _attr_supported_features = (
UpdateEntityFeature.INSTALL UpdateEntityFeature.INSTALL
| UpdateEntityFeature.PROGRESS | UpdateEntityFeature.PROGRESS