Skip to content

Commit

Permalink
Fix model for CommissioningParameters in client (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt authored Jan 30, 2024
1 parent 8a03034 commit d933fe8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ..common.models import (
APICommand,
CommandMessage,
CommissioningParameters,
ErrorResultMessage,
EventMessage,
EventType,
Expand Down Expand Up @@ -179,14 +180,14 @@ async def open_commissioning_window(
iteration: int = 1000,
option: int = 1,
discriminator: Optional[int] = None,
) -> tuple[int, str]:
) -> CommissioningParameters:
"""
Open a commissioning window to commission a device present on this controller to another.
Returns code to use as discriminator.
"""
return cast(
tuple[int, str],
return dataclass_from_dict(
CommissioningParameters,
await self.send_command(
APICommand.OPEN_COMMISSIONING_WINDOW,
node_id=node_id,
Expand Down
13 changes: 13 additions & 0 deletions matter_server/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,16 @@ class ServerInfoMessage:
| ErrorResultMessage
| ServerInfoMessage
)


@dataclass
class CommissioningParameters:
"""
Object that is returned on the 'open_commisisoning_window' command.
NOTE: This is just a copy of the dataclass specified in chip.ChipDeviceCtrl
"""

setupPinCode: int # pylint: disable=invalid-name
setupManualCode: str # pylint: disable=invalid-name
setupQRCode: str # pylint: disable=invalid-name
7 changes: 2 additions & 5 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
import random
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable, TypeVar, cast

from chip.ChipDeviceCtrl import (
CommissionableNode,
CommissioningParameters,
DeviceProxyWrapper,
)
from chip.ChipDeviceCtrl import CommissionableNode, DeviceProxyWrapper
from chip.clusters import Attribute, Objects as Clusters
from chip.clusters.Attribute import ValueDecodeFailure
from chip.clusters.ClusterObjects import ALL_ATTRIBUTES, ALL_CLUSTERS, Cluster
from chip.discovery import CommissionableNode as CommissionableNodeData
from chip.exceptions import ChipStackError

from matter_server.common.helpers.util import convert_ip_address
from matter_server.common.models import CommissioningParameters
from matter_server.server.helpers.attributes import parse_attributes_from_read_result
from matter_server.server.helpers.utils import ping_ip

Expand Down

0 comments on commit d933fe8

Please sign in to comment.