Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Update CONTRIBUTING.md #470

wants to merge 1 commit into from

Conversation

pipiche38
Copy link
Contributor

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.

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
@coveralls
Copy link

Coverage Status

Coverage decreased (-100.0%) to 0.0% when pulling d5030e6 on pipiche38:patch-1 into 64e4f73 on zigpy:dev.

@coveralls
Copy link

coveralls commented Sep 2, 2020

Coverage Status

Coverage remained the same at 99.96% when pulling d5030e6 on pipiche38:patch-1 into 64e4f73 on zigpy:dev.

Comment on lines +179 to +187
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
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Comment on lines +179 to +181
def cluster_command(self, cluster, command_id, *args):
# ???? not sure on the parameters
pass
Copy link
Collaborator

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

zigpy/zigpy/util.py

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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):
Copy link
Collaborator

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.

@pipiche38
Copy link
Contributor Author

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 .

@Gamester17
Copy link
Contributor

@puddly & @dmulcahey Do you maybe have some suggestions or feedback on a guide for how-to get started with the zigpy library?

@Gamester17
Copy link
Contributor

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

@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants