Skip to content

Commit

Permalink
Add Ezviz SensorEntity name and translation (home-assistant#95697)
Browse files Browse the repository at this point in the history
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
  • Loading branch information
RenierM26 and frenck committed Jul 19, 2023
1 parent f0953dd commit 33b3b89
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 10 deletions.
47 changes: 37 additions & 10 deletions homeassistant/components/ezviz/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,55 @@
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,
device_class=SensorDeviceClass.BATTERY,
),
"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",
),
}


Expand All @@ -64,15 +92,14 @@ 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
) -> None:
"""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]

Expand Down
32 changes: 32 additions & 0 deletions homeassistant/components/ezviz/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 33b3b89

Please sign in to comment.