-
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
Update CONTRIBUTING.md #470
Conversation
Hereby I'm trying to document what could be the MainListener template. I think that each call back needs to be introduced here with their correct API
def cluster_command(self, cluster, command_id, *args): | ||
# ???? not sure on the parameters | ||
pass | ||
|
||
def attribute_updated(self, cluster, attribute_id, value): | ||
# Call everytime and event is received. | ||
# Each object is linked to its parent (i.e. app > device > endpoint > cluster) | ||
device = cluster.endpoint.device | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two are for "Cluster Event Listneres" --> events from the actual device/cluster. Everything above it is "ApplicationController" Listeners --> events happening on the network, like device leaving, joining etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you expect from me. I'm trying to understand how to use the all zigpy library, so feel free to update the PR accordingly. I'm sure that I'm wrong in a lot of places.
def cluster_command(self, cluster, command_id, *args): | ||
# ???? not sure on the parameters | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the signature is def cluster_command(self, command_id, *args)
when added via add_listener()
method. Signature def cluster_command(self, cluster, command_id, *args)
is applicable when added via add_context_listenere()
method. see
Lines 28 to 49 in 64e4f73
def add_listener(self, listener): | |
return self._add_listener(listener, include_context=False) | |
def add_context_listener(self, listener): | |
return self._add_listener(listener, include_context=True) | |
def listener_event(self, method_name, *args): | |
result = [] | |
for listener, include_context in self._listeners.values(): | |
method = getattr(listener, method_name, None) | |
if not method: | |
continue | |
try: | |
if include_context: | |
result.append(method(self, *args)) | |
else: | |
result.append(method(*args)) | |
except Exception as e: | |
LOGGER.warning("Error calling listener.%s: %s", method_name, e) | |
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
command_id
is an int
representing a "cluster specific command", for example command_id == 0x0000
is the "Off" command if received from the OnOff cluster. The type of cluster: in_cluster (server cluster) or out_cluster (client cluster) may have different commands, so application needs to be aware if the command is coming from an input or output clusters.
*args
are going to be command specific. Look into https://github.com/zigpy/zigpy/blob/dev/zigpy/zcl/clusters definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you expect from me. I'm trying to understand how to use the all zigpy library, so feel free to update the PR accordingly. I'm sure that I'm wrong in a lot of places.
# ???? not sure on the parameters | ||
pass | ||
|
||
def attribute_updated(self, cluster, attribute_id, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for cluster_command
this signature is correct when added through add_context_listener()
method. When added through add_listener()
the cluster
instance parameter is omitted.
My purpose here is to create some User Guide on how to develop an app. So from my end, I imagine a kind of guide where we describe the few steps on how to create an apps. I think that we should have a kind of workflow which describe from a UI command to the Zigbee radio what is the flow and vice-versa from a Zigbee radio event to the UI app what is the data flow. For you @Adminiuga it is obvious, but for new comers this is not. and pointing out some codes, others apps and ZHA as such , I'm sorry this is quiet hard . |
@puddly & @dmulcahey Do you maybe have some suggestions or feedback on a guide for how-to get started with the zigpy library? |
I like to suggest also looking at the README.md from zsmartsystems/com.zsmartsystems.zigbee for inspiration: https://github.com/zsmartsystems/com.zsmartsystems.zigbee/blob/master/README.md |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions. |
Hereby I'm trying to document what could be the MainListener template.
I think that each call back needs to be introduced here with their correct API
In such it will ease the new comers to develop a first app.