import json # Import the CHIP clusters from chip.clusters import Objects as clusters # Import the ability to turn objects into dictionaries, and vice-versa from matter_server.common.helpers.util import dataclass_from_dict,dataclass_to_dict command = clusters.OnOff.Commands.On() payload = dataclass_to_dict(command) message = { "message_id": "example", "command": "device_command", "args": { "endpoint_id": 1, "node_id": 1, "payload": payload, "cluster_id": command.cluster_id, "command_name": "On" } } print(json.dumps(message, indent=2))