Reolink extend diagnostic data (#119745)
* Add diagnostic info * fix * change order * update tests
This commit is contained in:
parent
c519e12042
commit
3a672642ea
4 changed files with 122 additions and 8 deletions
|
@ -23,7 +23,9 @@ async def async_get_config_entry_diagnostics(
|
|||
for ch in api.channels:
|
||||
IPC_cam[ch] = {}
|
||||
IPC_cam[ch]["model"] = api.camera_model(ch)
|
||||
IPC_cam[ch]["hardware version"] = api.camera_hardware_version(ch)
|
||||
IPC_cam[ch]["firmware version"] = api.camera_sw_version(ch)
|
||||
IPC_cam[ch]["encoding main"] = await api.get_encoding(ch)
|
||||
|
||||
return {
|
||||
"model": api.model,
|
||||
|
@ -42,6 +44,8 @@ async def async_get_config_entry_diagnostics(
|
|||
"stream channels": api.stream_channels,
|
||||
"IPC cams": IPC_cam,
|
||||
"capabilities": api.capabilities,
|
||||
"cmd list": host.update_cmd,
|
||||
"firmware ch list": host.firmware_ch_list,
|
||||
"api versions": api.checked_api_versions,
|
||||
"abilities": api.abilities,
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class ReolinkHost:
|
|||
)
|
||||
|
||||
self.last_wake: float = 0
|
||||
self._update_cmd: defaultdict[str, defaultdict[int | None, int]] = defaultdict(
|
||||
self.update_cmd: defaultdict[str, defaultdict[int | None, int]] = defaultdict(
|
||||
lambda: defaultdict(int)
|
||||
)
|
||||
self.firmware_ch_list: list[int | None] = []
|
||||
|
@ -97,16 +97,16 @@ class ReolinkHost:
|
|||
@callback
|
||||
def async_register_update_cmd(self, cmd: str, channel: int | None = None) -> None:
|
||||
"""Register the command to update the state."""
|
||||
self._update_cmd[cmd][channel] += 1
|
||||
self.update_cmd[cmd][channel] += 1
|
||||
|
||||
@callback
|
||||
def async_unregister_update_cmd(self, cmd: str, channel: int | None = None) -> None:
|
||||
"""Unregister the command to update the state."""
|
||||
self._update_cmd[cmd][channel] -= 1
|
||||
if not self._update_cmd[cmd][channel]:
|
||||
del self._update_cmd[cmd][channel]
|
||||
if not self._update_cmd[cmd]:
|
||||
del self._update_cmd[cmd]
|
||||
self.update_cmd[cmd][channel] -= 1
|
||||
if not self.update_cmd[cmd][channel]:
|
||||
del self.update_cmd[cmd][channel]
|
||||
if not self.update_cmd[cmd]:
|
||||
del self.update_cmd[cmd]
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
|
@ -350,7 +350,7 @@ class ReolinkHost:
|
|||
wake = True
|
||||
self.last_wake = time()
|
||||
|
||||
await self._api.get_states(cmd_list=self._update_cmd, wake=wake)
|
||||
await self._api.get_states(cmd_list=self.update_cmd, wake=wake)
|
||||
|
||||
async def disconnect(self) -> None:
|
||||
"""Disconnect from the API, so the connection will be released."""
|
||||
|
|
|
@ -84,8 +84,10 @@ def reolink_connect_class() -> Generator[MagicMock]:
|
|||
host_mock.model = TEST_HOST_MODEL
|
||||
host_mock.camera_model.return_value = TEST_CAM_MODEL
|
||||
host_mock.camera_name.return_value = TEST_NVR_NAME
|
||||
host_mock.camera_hardware_version.return_value = "IPC_00001"
|
||||
host_mock.camera_sw_version.return_value = "v1.1.0.0.0.0000"
|
||||
host_mock.camera_uid.return_value = TEST_UID
|
||||
host_mock.get_encoding.return_value = "h264"
|
||||
host_mock.firmware_update_available.return_value = False
|
||||
host_mock.session_active = True
|
||||
host_mock.timeout = 60
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
'HTTPS': True,
|
||||
'IPC cams': dict({
|
||||
'0': dict({
|
||||
'encoding main': 'h264',
|
||||
'firmware version': 'v1.1.0.0.0.0000',
|
||||
'hardware version': 'IPC_00001',
|
||||
'model': 'RLC-123',
|
||||
}),
|
||||
}),
|
||||
|
@ -38,7 +40,113 @@
|
|||
'channels': list([
|
||||
0,
|
||||
]),
|
||||
'cmd list': dict({
|
||||
'GetAiAlarm': dict({
|
||||
'0': 5,
|
||||
'null': 5,
|
||||
}),
|
||||
'GetAiCfg': dict({
|
||||
'0': 4,
|
||||
'null': 4,
|
||||
}),
|
||||
'GetAudioAlarm': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetAudioCfg': dict({
|
||||
'0': 2,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetAutoFocus': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetAutoReply': dict({
|
||||
'0': 2,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetBatteryInfo': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetBuzzerAlarmV20': dict({
|
||||
'0': 1,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetChannelstatus': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetEmail': dict({
|
||||
'0': 1,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetEnc': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetFtp': dict({
|
||||
'0': 1,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetIrLights': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetIsp': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetManualRec': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetMdAlarm': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetPirInfo': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetPowerLed': dict({
|
||||
'0': 2,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetPtzCurPos': dict({
|
||||
'0': 1,
|
||||
'null': 1,
|
||||
}),
|
||||
'GetPtzGuard': dict({
|
||||
'0': 2,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetPtzTraceSection': dict({
|
||||
'0': 2,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetPush': dict({
|
||||
'0': 1,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetRec': dict({
|
||||
'0': 1,
|
||||
'null': 2,
|
||||
}),
|
||||
'GetWhiteLed': dict({
|
||||
'0': 3,
|
||||
'null': 3,
|
||||
}),
|
||||
'GetZoomFocus': dict({
|
||||
'0': 2,
|
||||
'null': 2,
|
||||
}),
|
||||
}),
|
||||
'event connection': 'Fast polling',
|
||||
'firmware ch list': list([
|
||||
0,
|
||||
None,
|
||||
]),
|
||||
'firmware version': 'v1.0.0.0.0.0000',
|
||||
'hardware version': 'IPC_00000',
|
||||
'model': 'RLN8-410',
|
||||
|
|
Loading…
Add table
Reference in a new issue