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):
"""Representation of a EZVIZ sensor."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: EzvizDataUpdateCoordinator,

View file

@ -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,

View file

@ -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

View file

@ -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,

View file

@ -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:

View file

@ -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(

View file

@ -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,

View file

@ -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,

View file

@ -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:

View file

@ -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": {

View file

@ -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:

View file

@ -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