Skip to content

Commit

Permalink
Print result of device removal (#500)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcel van der Veldt <[email protected]>
  • Loading branch information
agners and marcelveldt committed Jan 11, 2024
1 parent 8c3186d commit e555cbc
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ async def remove_node(self, node_id: int) -> None:
self.server.storage.save(immediate=True)
LOGGER.info("Node ID %s successfully removed from Matter server.", node_id)

self.server.signal_event(EventType.NODE_REMOVED, node_id)

assert node is not None

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

self.server.signal_event(EventType.NODE_REMOVED, node_id)

await self.chip_controller.SendCommand(
nodeid=node_id,
endpoint=0,
payload=Clusters.OperationalCredentials.Commands.RemoveFabric(
fabricIndex=fabric_index,
),
result: Clusters.OperationalCredentials.Commands.NOCResponse = (
await self.chip_controller.SendCommand(
nodeid=node_id,
endpoint=0,
payload=Clusters.OperationalCredentials.Commands.RemoveFabric(
fabricIndex=fabric_index,
),
)
)
if (
result.statusCode
== Clusters.OperationalCredentials.Enums.NodeOperationalCertStatusEnum.kOk
):
LOGGER.info("Successfully removed Home Assistant fabric from device.")
else:
LOGGER.warning(
"Removing current fabric from device failed with status code %d.",
result.statusCode,
)

@api_command(APICommand.SUBSCRIBE_ATTRIBUTE)
async def subscribe_attribute(
Expand Down

0 comments on commit e555cbc

Please sign in to comment.