Skip to content

Commit

Permalink
use attribute_path
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Jun 28, 2023
1 parent dee53c7 commit 0243ad8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 4 additions & 6 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ async def send_device_command(
async def write_attribute(
self,
node_id: int,
endpoint_id: int,
attribute: ClusterAttributeDescriptor,
attribute_path: str,
value: Any,
response_type: Any | None = None,
timed_request_timeout_ms: int | None = None,
interaction_timeout_ms: int | None = None,
Expand All @@ -246,10 +246,8 @@ async def write_attribute(
return await self.send_command(
APICommand.WRITE_ATTRIBUTE,
node_id=node_id,
endpoint_id=endpoint_id,
cluster_id=attribute.cluster_id,
attribute_id=attribute.attribute_id,
value=attribute.value,
attribute_path=attribute_path,
value=value,
response_type=response_type,
timed_request_timeout_ms=timed_request_timeout_ms,
interaction_timeout_ms=interaction_timeout_ms,
Expand Down
5 changes: 2 additions & 3 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,15 @@ async def send_device_command(
async def write_attribute(
self,
node_id: int,
endpoint_id: int,
cluster_id: int,
attribute_id: int,
attribute_path: str | list[str],
value: Any,
timed_request_timeout_ms: int | None = None,
interaction_timeout_ms: int | None = None,
) -> Any:
"""Write an attribute(value) on a target node."""
if self.chip_controller is None:
raise RuntimeError("Device Controller not initialized.")
endpoint_id, cluster_id, attribute_id = parse_attribute_path(attribute_path)
attribute = ALL_ATTRIBUTES[cluster_id][attribute_id]()
attribute.value = value
return await self.chip_controller.WriteAttribute(
Expand Down

0 comments on commit 0243ad8

Please sign in to comment.