mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add Ezviz SensorEntity name and translation (#95697)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
f0953dde95
commit
33b3b8947a
@ -18,7 +18,6 @@ from .entity import EzvizEntity
|
|||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||||
"sw_version": SensorEntityDescription(key="sw_version"),
|
|
||||||
"battery_level": SensorEntityDescription(
|
"battery_level": SensorEntityDescription(
|
||||||
key="battery_level",
|
key="battery_level",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
@ -26,19 +25,48 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
|||||||
),
|
),
|
||||||
"alarm_sound_mod": SensorEntityDescription(
|
"alarm_sound_mod": SensorEntityDescription(
|
||||||
key="alarm_sound_mod",
|
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,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"last_alarm_time": SensorEntityDescription(key="last_alarm_time"),
|
|
||||||
"Seconds_Last_Trigger": SensorEntityDescription(
|
"Seconds_Last_Trigger": SensorEntityDescription(
|
||||||
key="Seconds_Last_Trigger",
|
key="Seconds_Last_Trigger",
|
||||||
|
translation_key="seconds_last_trigger",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"supported_channels": SensorEntityDescription(key="supported_channels"),
|
"last_alarm_pic": SensorEntityDescription(
|
||||||
"local_ip": SensorEntityDescription(key="local_ip"),
|
key="last_alarm_pic",
|
||||||
"wan_ip": SensorEntityDescription(key="wan_ip"),
|
translation_key="last_alarm_pic",
|
||||||
"PIR_Status": SensorEntityDescription(key="PIR_Status"),
|
entity_registry_enabled_default=False,
|
||||||
"last_alarm_type_code": SensorEntityDescription(key="last_alarm_type_code"),
|
),
|
||||||
"last_alarm_type_name": SensorEntityDescription(key="last_alarm_type_name"),
|
"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):
|
class EzvizSensor(EzvizEntity, SensorEntity):
|
||||||
"""Representation of a EZVIZ sensor."""
|
"""Representation of a EZVIZ sensor."""
|
||||||
|
|
||||||
coordinator: EzvizDataUpdateCoordinator
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: EzvizDataUpdateCoordinator, serial: str, sensor: str
|
self, coordinator: EzvizDataUpdateCoordinator, serial: str, sensor: str
|
||||||
@ -72,7 +100,6 @@ class EzvizSensor(EzvizEntity, SensorEntity):
|
|||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(coordinator, serial)
|
super().__init__(coordinator, serial)
|
||||||
self._sensor_name = sensor
|
self._sensor_name = sensor
|
||||||
self._attr_name = f"{self._camera_name} {sensor.title()}"
|
|
||||||
self._attr_unique_id = f"{serial}_{self._camera_name}.{sensor}"
|
self._attr_unique_id = f"{serial}_{self._camera_name}.{sensor}"
|
||||||
self.entity_description = SENSOR_TYPES[sensor]
|
self.entity_description = SENSOR_TYPES[sensor]
|
||||||
|
|
||||||
|
@ -98,6 +98,38 @@
|
|||||||
"last_motion_image": {
|
"last_motion_image": {
|
||||||
"name": "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": {
|
"services": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user