Skip to content

Commit e7aa672

Browse files
tomwilkiemib1185
andauthored
Register MAC address connections on Synology DSM hub device (home-assistant#169085)
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com> Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
1 parent 99185bf commit e7aa672

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

homeassistant/components/synology_dsm/entity.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
from dataclasses import dataclass
66
from typing import TYPE_CHECKING, Any
77

8-
from homeassistant.helpers.device_registry import DeviceInfo
8+
from homeassistant.helpers.device_registry import (
9+
CONNECTION_NETWORK_MAC,
10+
DeviceInfo,
11+
format_mac,
12+
)
913
from homeassistant.helpers.entity import EntityDescription
1014
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1115

@@ -56,6 +60,9 @@ def __init__(
5660
)
5761
self._attr_device_info = DeviceInfo(
5862
identifiers={(DOMAIN, information.serial)},
63+
connections={
64+
(CONNECTION_NETWORK_MAC, format_mac(mac)) for mac in network.macs
65+
},
5966
name=network.hostname,
6067
manufacturer="Synology",
6168
model=information.model,

tests/components/synology_dsm/test_sensor.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
CONF_USERNAME,
1616
)
1717
from homeassistant.core import HomeAssistant
18-
from homeassistant.helpers import entity_registry as er
18+
from homeassistant.helpers import device_registry as dr, entity_registry as er
1919

2020
from .common import (
2121
mock_dsm_external_usb_devices_usb0,
@@ -356,3 +356,17 @@ async def test_no_external_usb(
356356
"""Test Synology DSM without USB."""
357357
sensor = hass.states.get("sensor.nas_meontheinternet_com_usb_disk_1_device_size")
358358
assert sensor is None
359+
360+
361+
async def test_hub_device_info_mac_connections(
362+
hass: HomeAssistant,
363+
setup_dsm_with_usb: MagicMock,
364+
) -> None:
365+
"""Test that the hub DeviceInfo includes MAC address connections."""
366+
dev_reg = dr.async_get(hass)
367+
device = dev_reg.async_get_device(identifiers={(DOMAIN, SERIAL)})
368+
assert device is not None
369+
assert device.connections == {
370+
("mac", "00:11:32:xx:xx:59"),
371+
("mac", "00:11:32:xx:xx:5a"),
372+
}

0 commit comments

Comments
 (0)