Add mac to Reolink IPC cam device info (#140822)

* Add mac to Reolink IPC cams

* Add test

* check mac none
This commit is contained in:
starkillerOG 2025-03-26 00:31:01 +01:00 committed by GitHub
parent e78a19ae3e
commit 840613f43d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -178,8 +178,13 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
else:
self._dev_id = f"{self._host.unique_id}_ch{dev_ch}"
connections = set()
if mac := self._host.api.baichuan.mac_address(dev_ch):
connections.add((CONNECTION_NETWORK_MAC, mac))
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._dev_id)},
connections=connections,
via_device=(DOMAIN, self._host.unique_id),
name=self._host.api.camera_name(dev_ch),
model=self._host.api.camera_model(dev_ch),

View File

@ -35,6 +35,7 @@ TEST_PASSWORD = "password"
TEST_PASSWORD2 = "new_password"
TEST_MAC = "aa:bb:cc:dd:ee:ff"
TEST_MAC2 = "ff:ee:dd:cc:bb:aa"
TEST_MAC_CAM = "11:22:33:44:55:66"
DHCP_FORMATTED_MAC = "aabbccddeeff"
TEST_UID = "ABC1234567D89EFG"
TEST_UID_CAM = "DEF7654321D89GHT"
@ -142,6 +143,7 @@ def reolink_connect_class() -> Generator[MagicMock]:
# Disable tcp push by default for tests
host_mock.baichuan.port = TEST_BC_PORT
host_mock.baichuan.events_active = False
host_mock.baichuan.mac_address.return_value = TEST_MAC_CAM
host_mock.baichuan.privacy_mode.return_value = False
host_mock.baichuan.day_night_state.return_value = "day"
host_mock.baichuan.subscribe_events.side_effect = ReolinkError("Test error")