Skip to content

Commit 0458e6a

Browse files
agnersclaude
andauthored
Allow mdns and llmnr to be None in NetworkInterface (#285)
Disabled interfaces (e.g. unconfigured VLANs) return null for mdns and llmnr fields. Update the model to accept None and add a test fixture and assertions to cover this case. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ed6132e commit 0458e6a

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

aiohasupervisor/models/network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class NetworkInterface(ResponseData):
141141
ipv6: IPv6
142142
wifi: Wifi | None
143143
vlan: Vlan | None
144-
mdns: MulticastDnsMode
145-
llmnr: MulticastDnsMode
144+
mdns: MulticastDnsMode | None
145+
llmnr: MulticastDnsMode | None
146146

147147

148148
@dataclass(frozen=True, slots=True)

tests/fixtures/network_info.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,36 @@
3131
"vlan": null,
3232
"mdns": "default",
3333
"llmnr": "default"
34+
},
35+
{
36+
"interface": "end0.10",
37+
"type": "vlan",
38+
"enabled": false,
39+
"connected": false,
40+
"primary": false,
41+
"mac": "00:11:22:33:44:55",
42+
"ipv4": {
43+
"method": "disabled",
44+
"address": [],
45+
"nameservers": [],
46+
"gateway": null,
47+
"ready": false,
48+
"route_metric": null
49+
},
50+
"ipv6": {
51+
"method": "disabled",
52+
"address": [],
53+
"nameservers": [],
54+
"gateway": null,
55+
"ready": false,
56+
"route_metric": null,
57+
"addr_gen_mode": "default",
58+
"ip6_privacy": "default"
59+
},
60+
"wifi": null,
61+
"vlan": null,
62+
"mdns": null,
63+
"llmnr": null
3464
}
3565
],
3666
"docker": {

tests/test_network.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ async def test_network_info(
5656
assert result.interfaces[0].mdns is MulticastDnsMode.DEFAULT
5757
assert result.interfaces[0].llmnr is MulticastDnsMode.DEFAULT
5858

59+
assert result.interfaces[1].interface == "end0.10"
60+
assert result.interfaces[1].type == "vlan"
61+
assert result.interfaces[1].enabled is False
62+
assert result.interfaces[1].mdns is None
63+
assert result.interfaces[1].llmnr is None
64+
5965
assert result.docker.interface == "hassio"
6066
assert result.docker.address.compressed == "172.30.32.0/23"
6167
assert result.docker.gateway.compressed == "172.30.32.1"

0 commit comments

Comments
 (0)