Skip to content

create groups #1071

@goossensbas

Description

@goossensbas

Hello all,

I am using the python-matter-server docker container as a stand-alone application.
I wrote an interface in python to test the capabilities of Matter.

The documentation of the server is somewhat limited. Basic functions like onoff and commissioning work,
but other features like binding a switch to a light is not documented at all.
(i managed to do this by writing the values in the correct cluster attributes)

I want to create a group for 2 or more light devices, but i can't assemble the correct command.

my code:

async def add_node_to_group(client, group_id, node_id):
    res = await client.read_attribute(node_id,f"1/4/0")
    print(f"{res}")
    current_membership = res.get("1/4/0", 0)  # Extracting the attribute value
    print(f"Current Membership: {current_membership}")

    # Define the AddGroup command
    command = clusters.Groups.Commands.AddGroup(
        groupId=group_id,  # Replace with your desired group ID
        groupName=f"group{group_id}"  # Replace with your desired group name
    )
    payload = dataclass_to_dict(command)

    add_group_command = json.dumps({
        "message_id": "example",
        "command": "device_command",
        "args": {
            "endpoint_id": 1,
            "node_id": node_id,
            "payload": payload,
            "cluster_id": command.cluster_id,
            "command_name": "AddGroup"
        }
    })
    # Write the updated group membership attribute
    write_res = await client.send_device_command(node_id, 1, add_group_command)
    print(f"Write Attribute Response: {write_res}")

gives the error:

Error during Matter client operation: Groups.Commands.AddGroup.__init__() got an unexpected keyword argument 'GroupId'
Disconnected from Matter server.

I also tried GroupId and GroupName with capital letters, but it gives the same error.

command = clusters.Groups.Commands.AddGroup(
        GroupId=group_id,  # Replace with your desired group ID
        GroupName=f"group{group_id}"  # Replace with your desired group name
    )

How can i create a group and add nodes to it?
How do i send group commands?

Thanks in advance for the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendrevisit-with-matter.js-controllerRevisit/Revalidate/Recheck the issue or feature request with the matter,js based Matter Server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions