File tree Expand file tree Collapse file tree
homeassistant/components/synology_dsm
tests/components/synology_dsm Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from dataclasses import dataclass
66from 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+ )
913from homeassistant .helpers .entity import EntityDescription
1014from 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 ,
Original file line number Diff line number Diff line change 1515 CONF_USERNAME ,
1616)
1717from 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
2020from .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+ }
You can’t perform that action at this time.
0 commit comments