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

Allow to commission with code on network only #470

Merged
merged 6 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ def get_node(self, node_id: int) -> MatterNode:
return node
raise NodeNotExists(f"Node {node_id} does not exist or is not yet interviewed")

async def commission_with_code(self, code: str) -> MatterNodeData:
async def commission_with_code(
self, code: str, network_only: bool
agners marked this conversation as resolved.
Show resolved Hide resolved
) -> MatterNodeData:
"""
Commission a device using QRCode or ManualPairingCode.

Returns basic MatterNodeData once complete.
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
"""
data = await self.send_command(APICommand.COMMISSION_WITH_CODE, code=code)
data = await self.send_command(
APICommand.COMMISSION_WITH_CODE, code=code, network_only=network_only
)
return dataclass_from_dict(MatterNodeData, data)

async def commission_on_network(
Expand Down
5 changes: 4 additions & 1 deletion matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def get_node(self, node_id: int) -> MatterNodeData:
raise NodeNotExists(f"Node {node_id} does not exist or is not yet interviewed")

@api_command(APICommand.COMMISSION_WITH_CODE)
async def commission_with_code(self, code: str) -> MatterNodeData:
async def commission_with_code(
self, code: str, network_only: bool = False
) -> MatterNodeData:
"""
Commission a device using QRCode or ManualPairingCode.
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -166,6 +168,7 @@ async def commission_with_code(self, code: str) -> MatterNodeData:
self.chip_controller.CommissionWithCode,
setupPayload=code,
nodeid=node_id,
networkOnly=network_only,
)
if not success:
raise NodeCommissionFailed(
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ dependencies = [
"coloredlogs",
"dacite",
"orjson",
"home-assistant-chip-clusters==2023.10.2"
"home-assistant-chip-clusters==2023.12.0"
]

[project.optional-dependencies]
server = [
"home-assistant-chip-core==2023.10.2",
"home-assistant-chip-core==2023.12.0",
"cryptography==41.0.7"
]
test = [
Expand Down
2 changes: 1 addition & 1 deletion tests/server/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async def test_server_start(
{"code": "test_code"},
strict=True,
)
) == {"code": "test_code"}
) == {"code": "test_code", "network_only": False}
assert (
parse_arguments(
server.command_handlers[APICommand.COMMISSION_ON_NETWORK].signature,
Expand Down
Loading