Add Ezviz SensorEntity name and translation (#95697)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>pull/96900/head
parent
f0953dde95
commit
33b3b8947a
|
@ -18,7 +18,6 @@ from .entity import EzvizEntity
|
|||
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 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"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 @@ class EzvizSensor(EzvizEntity, SensorEntity):
|
|||
"""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]
|
||||
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue