Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update label on interview #909

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ async def commission_with_code(
retries = 3
while retries:
try:
await self.interview_node(node_id)
await self._interview_node(node_id)
except (NodeNotResolving, NodeInterviewFailed) as err:
if retries <= 0:
raise err
Expand Down Expand Up @@ -425,7 +425,7 @@ async def commission_on_network(
retries = 3
while retries:
try:
await self.interview_node(node_id)
await self._interview_node(node_id)
except NodeInterviewFailed as err:
if retries <= 0:
raise err
Expand Down Expand Up @@ -567,17 +567,7 @@ async def discover_commissionable_nodes(
for x in sdk_result
]

@api_command(APICommand.INTERVIEW_NODE)
async def interview_node(self, node_id: int) -> None:
"""Interview a node."""
if node_id >= TEST_NODE_START:
LOGGER.debug(
"interview_node called for test node %s",
node_id,
)
self.server.signal_event(EventType.NODE_UPDATED, self._nodes[node_id])
return

async def _interview_node(self, node_id: int) -> None:
try:
LOGGER.info("Interviewing node: %s", node_id)
read_response: Attribute.AsyncReadTransaction.ReadResponse = (
Expand Down Expand Up @@ -622,6 +612,28 @@ async def interview_node(self, node_id: int) -> None:

LOGGER.debug("Interview of node %s completed", node_id)

@api_command(APICommand.INTERVIEW_NODE)
async def interview_node(self, node_id: int) -> None:
"""Interview a node."""
if node_id >= TEST_NODE_START:
LOGGER.debug(
"interview_node called for test node %s",
node_id,
)
self.server.signal_event(EventType.NODE_UPDATED, self._nodes[node_id])
return

await self._interview_node(node_id)

if self._default_fabric_label:
await self._chip_device_controller.send_command(
node_id,
0,
Clusters.OperationalCredentials.Commands.UpdateFabricLabel(
self._default_fabric_label
),
)

@api_command(APICommand.DEVICE_COMMAND)
async def send_device_command(
self,
Expand Down Expand Up @@ -1114,7 +1126,7 @@ def attribute_updated_callback(
and new_value != old_value
):
# schedule a full interview of the node if the software version changed
self._loop.create_task(self.interview_node(node_id))
self._loop.create_task(self._interview_node(node_id))

# store updated value in node attributes
node.attributes[str(path)] = new_value
Expand Down Expand Up @@ -1346,7 +1358,7 @@ async def _setup_node_try_once(
or node_data.interview_version != DATA_MODEL_SCHEMA_VERSION
):
try:
await self.interview_node(node_id)
await self._interview_node(node_id)
except NodeInterviewFailed as err:
node_logger.warning(
"Setup for node failed: %s",
Expand Down Expand Up @@ -1436,7 +1448,7 @@ async def _handle_endpoints_added(
) -> None:
"""Handle callback for when bridge endpoint(s) get added."""
# we simply do a full interview of the node
await self.interview_node(node_id)
await self._interview_node(node_id)
# signal event to consumers
for endpoint_id in endpoints:
self.server.signal_event(
Expand Down