-
Notifications
You must be signed in to change notification settings - Fork 156
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
How to parse/access an incoming ZCL frame? #1301
Comments
Even just a link to a how-to would be appreciated. |
To access incoming ZCL frames, you would have to attach a listener to the cluster object on the device you're interested in receiving frames: Line 427 in e54dab0
Something like this: class MyListener:
def __init__(self, endpoint):
self.endpoint = endpoint
self.device = endpoint.device
def cluster_command(self, tsn, command_id, cmd):
print(f"Device {self.device} received command {cmd} on endpoint {self.endpoint}")
ep = dev.endpoints[1]
ep.on_off.add_listener(MyListener(ep)) Alternatively, you can create a listener for the device: def my_callback(cmd_hdr, cmd):
print("Received command {cmd_hdr} {cmd}")
with app._callback_for_response(src=dev, filters=[], callback=my_callback):
await main()
# Callback listener detaches once you exit the context |
Thanks for the help @puddly Using your first example, would I add the listener when the Eg.
This would allow me to add different/bespoke listeners to specific devices, I'm hoping. |
Hey @puddly I think I've done what you said, but it isn't behaving the way I expected so either I don't understand the workflow or something is wrong.
I added a listener on the My listener looks like this;
Any thoughts on where I'm going wrong? |
Hopefully this is the right place, if not please direct me.
I'm trying to implement a super lightweight Zigbee implementation to send and receive messages from an MQTT broker and have chosen Zigpy and Zigpy-Znp.
I've reached the stage where I need to parse the message and publish it to my MQTT broker, I can see the following in the logs;
Essentially I want access to the "Decoded ZCL frame" so I can pass it on to where it needs to go as it seem to have what I want. I have implemented my own
handle_message
method, which is receiving data.I just want to know how to access the "decoded" ZCL frame or how to, as is implied in the log above, implement my own
explicit handler for the cluster command
.Any help super appreciated and many thanks in advance.
The text was updated successfully, but these errors were encountered: