Skip to content

Commit e555cbc

Browse files
agnersmarcelveldt
andauthoredJan 11, 2024
Print result of device removal (#500)
Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
1 parent 8c3186d commit e555cbc

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed
 

‎matter_server/server/device_controller.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ async def remove_node(self, node_id: int) -> None:
578578
self.server.storage.save(immediate=True)
579579
LOGGER.info("Node ID %s successfully removed from Matter server.", node_id)
580580

581+
self.server.signal_event(EventType.NODE_REMOVED, node_id)
582+
581583
assert node is not None
582584

583585
attribute_path = create_attribute_path_from_attribute(
@@ -586,15 +588,25 @@ async def remove_node(self, node_id: int) -> None:
586588
)
587589
fabric_index = node.attributes[attribute_path]
588590

589-
self.server.signal_event(EventType.NODE_REMOVED, node_id)
590-
591-
await self.chip_controller.SendCommand(
592-
nodeid=node_id,
593-
endpoint=0,
594-
payload=Clusters.OperationalCredentials.Commands.RemoveFabric(
595-
fabricIndex=fabric_index,
596-
),
591+
result: Clusters.OperationalCredentials.Commands.NOCResponse = (
592+
await self.chip_controller.SendCommand(
593+
nodeid=node_id,
594+
endpoint=0,
595+
payload=Clusters.OperationalCredentials.Commands.RemoveFabric(
596+
fabricIndex=fabric_index,
597+
),
598+
)
597599
)
600+
if (
601+
result.statusCode
602+
== Clusters.OperationalCredentials.Enums.NodeOperationalCertStatusEnum.kOk
603+
):
604+
LOGGER.info("Successfully removed Home Assistant fabric from device.")
605+
else:
606+
LOGGER.warning(
607+
"Removing current fabric from device failed with status code %d.",
608+
result.statusCode,
609+
)
598610

599611
@api_command(APICommand.SUBSCRIBE_ATTRIBUTE)
600612
async def subscribe_attribute(

0 commit comments

Comments
 (0)