Add more diagnostic info to Reolink (#139436)

* Add diagnostic info

* Bump reolink-aio to 0.12.1

* Add tests
This commit is contained in:
starkillerOG 2025-02-27 18:39:01 +01:00 committed by GitHub
parent a339fbaa82
commit 9502dbee56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 47 additions and 0 deletions

View File

@ -25,6 +25,14 @@ async def async_get_config_entry_diagnostics(
IPC_cam[ch]["firmware version"] = api.camera_sw_version(ch)
IPC_cam[ch]["encoding main"] = await api.get_encoding(ch)
chimes: dict[int, dict[str, Any]] = {}
for chime in api.chime_list:
chimes[chime.dev_id] = {}
chimes[chime.dev_id]["channel"] = chime.channel
chimes[chime.dev_id]["name"] = chime.name
chimes[chime.dev_id]["online"] = chime.online
chimes[chime.dev_id]["event_types"] = chime.chime_event_types
return {
"model": api.model,
"hardware version": api.hardware_version,
@ -41,9 +49,11 @@ async def async_get_config_entry_diagnostics(
"channels": api.channels,
"stream channels": api.stream_channels,
"IPC cams": IPC_cam,
"Chimes": chimes,
"capabilities": api.capabilities,
"cmd list": host.update_cmd,
"firmware ch list": host.firmware_ch_list,
"api versions": api.checked_api_versions,
"abilities": api.abilities,
"BC_abilities": api.baichuan.abilities,
}

View File

@ -123,6 +123,8 @@ def reolink_connect_class() -> Generator[MagicMock]:
"{'host':'TEST_RESPONSE','channel':'TEST_RESPONSE'}"
)
reolink_connect.chime_list = []
# enums
host_mock.whiteled_mode.return_value = 1
host_mock.whiteled_mode_list.return_value = ["off", "auto"]
@ -137,6 +139,10 @@ def reolink_connect_class() -> Generator[MagicMock]:
host_mock.baichuan.events_active = False
host_mock.baichuan.privacy_mode.return_value = False
host_mock.baichuan.subscribe_events.side_effect = ReolinkError("Test error")
host_mock.baichuan.abilities = {
0: {"chnID": 0, "aitype": 34615},
"Host": {"pushAlarm": 7},
}
yield host_mock_class

View File

@ -1,6 +1,27 @@
# serializer version: 1
# name: test_entry_diagnostics
dict({
'BC_abilities': dict({
'0': dict({
'aitype': 34615,
'chnID': 0,
}),
'Host': dict({
'pushAlarm': 7,
}),
}),
'Chimes': dict({
'12345678': dict({
'channel': 0,
'event_types': list([
'md',
'people',
'visitor',
]),
'name': 'Test chime',
'online': True,
}),
}),
'HTTP(S) port': 1234,
'HTTPS': True,
'IPC cams': dict({
@ -41,6 +62,10 @@
0,
]),
'cmd list': dict({
'DingDongOpt': dict({
'0': 2,
'null': 2,
}),
'GetAiAlarm': dict({
'0': 5,
'null': 5,
@ -81,6 +106,10 @@
'0': 2,
'null': 4,
}),
'GetDingDongCfg': dict({
'0': 3,
'null': 3,
}),
'GetEmail': dict({
'0': 1,
'null': 2,

View File

@ -2,6 +2,7 @@
from unittest.mock import MagicMock
from reolink_aio.api import Chime
from syrupy.assertion import SnapshotAssertion
from homeassistant.core import HomeAssistant
@ -15,6 +16,7 @@ async def test_entry_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
reolink_connect: MagicMock,
test_chime: Chime,
config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None: