mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 18:18:21 +00:00
Add EZVIZ battery camera power status and online status sensor (#146822)
This commit is contained in:
parent
d43f21c2e2
commit
9394546668
@ -66,6 +66,26 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
|||||||
key="last_alarm_type_name",
|
key="last_alarm_type_name",
|
||||||
translation_key="last_alarm_type_name",
|
translation_key="last_alarm_type_name",
|
||||||
),
|
),
|
||||||
|
"Record_Mode": SensorEntityDescription(
|
||||||
|
key="Record_Mode",
|
||||||
|
translation_key="record_mode",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
|
"battery_camera_work_mode": SensorEntityDescription(
|
||||||
|
key="battery_camera_work_mode",
|
||||||
|
translation_key="battery_camera_work_mode",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
|
"powerStatus": SensorEntityDescription(
|
||||||
|
key="powerStatus",
|
||||||
|
translation_key="power_status",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
|
"OnlineStatus": SensorEntityDescription(
|
||||||
|
key="OnlineStatus",
|
||||||
|
translation_key="online_status",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,16 +96,26 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up EZVIZ sensors based on a config entry."""
|
"""Set up EZVIZ sensors based on a config entry."""
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
entities: list[EzvizSensor] = []
|
||||||
|
|
||||||
async_add_entities(
|
for camera, sensors in coordinator.data.items():
|
||||||
[
|
entities.extend(
|
||||||
EzvizSensor(coordinator, camera, sensor)
|
EzvizSensor(coordinator, camera, sensor)
|
||||||
for camera in coordinator.data
|
for sensor, value in sensors.items()
|
||||||
for sensor, value in coordinator.data[camera].items()
|
if sensor in SENSOR_TYPES and value is not None
|
||||||
if sensor in SENSOR_TYPES
|
)
|
||||||
if value is not None
|
|
||||||
]
|
optionals = sensors.get("optionals", {})
|
||||||
)
|
entities.extend(
|
||||||
|
EzvizSensor(coordinator, camera, optional_key)
|
||||||
|
for optional_key in ("powerStatus", "OnlineStatus")
|
||||||
|
if optional_key in optionals
|
||||||
|
)
|
||||||
|
|
||||||
|
if "mode" in optionals.get("Record_Mode", {}):
|
||||||
|
entities.append(EzvizSensor(coordinator, camera, "mode"))
|
||||||
|
|
||||||
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
class EzvizSensor(EzvizEntity, SensorEntity):
|
class EzvizSensor(EzvizEntity, SensorEntity):
|
||||||
|
@ -147,6 +147,18 @@
|
|||||||
},
|
},
|
||||||
"last_alarm_type_name": {
|
"last_alarm_type_name": {
|
||||||
"name": "Last alarm type name"
|
"name": "Last alarm type name"
|
||||||
|
},
|
||||||
|
"record_mode": {
|
||||||
|
"name": "Record mode"
|
||||||
|
},
|
||||||
|
"battery_camera_work_mode": {
|
||||||
|
"name": "Battery work mode"
|
||||||
|
},
|
||||||
|
"power_status": {
|
||||||
|
"name": "Power status"
|
||||||
|
},
|
||||||
|
"online_status": {
|
||||||
|
"name": "Online status"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user