6666 key = "last_alarm_type_name" ,
6767 translation_key = "last_alarm_type_name" ,
6868 ),
69+ "Record_Mode" : SensorEntityDescription (
70+ key = "Record_Mode" ,
71+ translation_key = "record_mode" ,
72+ entity_registry_enabled_default = False ,
73+ ),
74+ "battery_camera_work_mode" : SensorEntityDescription (
75+ key = "battery_camera_work_mode" ,
76+ translation_key = "battery_camera_work_mode" ,
77+ entity_registry_enabled_default = False ,
78+ ),
79+ "powerStatus" : SensorEntityDescription (
80+ key = "powerStatus" ,
81+ translation_key = "power_status" ,
82+ entity_registry_enabled_default = False ,
83+ ),
84+ "OnlineStatus" : SensorEntityDescription (
85+ key = "OnlineStatus" ,
86+ translation_key = "online_status" ,
87+ entity_registry_enabled_default = False ,
88+ ),
6989}
7090
7191
@@ -76,16 +96,26 @@ async def async_setup_entry(
7696) -> None :
7797 """Set up EZVIZ sensors based on a config entry."""
7898 coordinator = entry .runtime_data
99+ entities : list [EzvizSensor ] = []
79100
80- async_add_entities (
81- [
101+ for camera , sensors in coordinator . data . items ():
102+ entities . extend (
82103 EzvizSensor (coordinator , camera , sensor )
83- for camera in coordinator .data
84- for sensor , value in coordinator .data [camera ].items ()
85- if sensor in SENSOR_TYPES
86- if value is not None
87- ]
88- )
104+ for sensor , value in sensors .items ()
105+ if sensor in SENSOR_TYPES and value is not None
106+ )
107+
108+ optionals = sensors .get ("optionals" , {})
109+ entities .extend (
110+ EzvizSensor (coordinator , camera , optional_key )
111+ for optional_key in ("powerStatus" , "OnlineStatus" )
112+ if optional_key in optionals
113+ )
114+
115+ if "mode" in optionals .get ("Record_Mode" , {}):
116+ entities .append (EzvizSensor (coordinator , camera , "mode" ))
117+
118+ async_add_entities (entities )
89119
90120
91121class EzvizSensor (EzvizEntity , SensorEntity ):
0 commit comments