Skip to content

Commit 01e5205

Browse files
authored
Ignore MDNS removal messages (#541)
1 parent 56f6e3a commit 01e5205

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

matter_server/server/device_controller.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,14 @@ def _on_mdns_service_state_change(
11711171
if not name.startswith(self.fabric_id_hex):
11721172
# filter out messages that are not for our fabric
11731173
return
1174+
LOGGER.debug("Received %s MDNS event for %s", state_change, name)
1175+
if state_change not in (
1176+
ServiceStateChange.Added,
1177+
ServiceStateChange.Updated,
1178+
):
1179+
# we're not interested in removals as this is already
1180+
# handled in the subscription logic
1181+
return
11741182
if existing := self._mdns_queues.get(name):
11751183
queue = existing[0]
11761184
else:
@@ -1193,20 +1201,18 @@ async def _process_mdns_queue(
11931201
if node_id not in self._nodes:
11941202
continue # this should not happen, but just in case
11951203
node = self._nodes[node_id]
1196-
if state_change in (
1204+
if state_change not in (
11971205
ServiceStateChange.Added,
11981206
ServiceStateChange.Updated,
11991207
):
1200-
if node.available:
1201-
continue # node is already set-up, no action needed
1202-
LOGGER.info("Node %s discovered on MDNS", node_id)
1203-
# setup the node
1204-
await self._setup_node(node_id)
1205-
elif state_change == ServiceStateChange.Removed:
1206-
if not node.available:
1207-
continue # node is already offline, nothing to do
1208-
LOGGER.info("Node %s vanished according to MDNS", node_id)
1209-
await self._node_offline(node_id)
1208+
# this should be already filtered out, but just in case
1209+
continue
1210+
if node.available:
1211+
# if the node is already set-up, no action is needed
1212+
continue
1213+
LOGGER.info("Node %s discovered on MDNS", node_id)
1214+
# setup the node
1215+
await self._setup_node(node_id)
12101216

12111217
async def _on_mdns_commissionable_node_state(
12121218
self, name: str, state_change: ServiceStateChange

0 commit comments

Comments
 (0)