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

Implement ZCL CLuster 0003 commands #1237

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Zigbee/zclCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
zcl_raw_send_group_member_ship_identify,
zcl_raw_window_covering,
zcl_raw_write_attributeNoResponse,
zcl_raw_default_response)
zcl_raw_default_response,
zcl_raw_identify)

DEFAULT_ACK_MODE = False

Expand Down Expand Up @@ -159,7 +160,7 @@ def zcl_get_list_attribute_extended_infos(self, nwkid, EpIn, EpOut, cluster, sta
def zcl_identify_send(self, nwkid, EPout, duration, ackIsDisabled=DEFAULT_ACK_MODE):
self.log.logging("zclCommand", "Debug", "zcl_identify_send %s %s %s" % (nwkid, EPout, duration))
if "ControllerInRawMode" in self.pluginconf.pluginConf and self.pluginconf.pluginConf["ControllerInRawMode"]:
self.log.logging("zclCommand", "Error", "zcl_identify_send not implemented for RAW mode")
zcl_raw_identify(self, nwkid, ZIGATE_EP, EPout, 'Identify', identify_time=duration, ackIsDisabled=ackIsDisabled)
return

if ackIsDisabled:
Expand All @@ -170,18 +171,18 @@ def zcl_identify_send(self, nwkid, EPout, duration, ackIsDisabled=DEFAULT_ACK_MO
def zcl_identify_trigger_effect(self, nwkid, EPout, effectId, effectGradient, ackIsDisabled=DEFAULT_ACK_MODE):
self.log.logging("zclCommand", "Debug", "zcl_identify_trigger_effect %s %s %s %s" % (nwkid, EPout, effectId, effectGradient))
if "ControllerInRawMode" in self.pluginconf.pluginConf and self.pluginconf.pluginConf["ControllerInRawMode"]:
self.log.logging("zclCommand", "Error", "zcl_identify_trigger_effect not implemented for RAW mode")
zcl_raw_identify(self, nwkid, ZIGATE_EP, EPout, 'TriggerEffect', identify_effect=effectId, identify_variant=effectGradient, ackIsDisabled=ackIsDisabled)
return

if ackIsDisabled:
return send_zigatecmd_zcl_ack(self, nwkid, "00E0", nwkid + ZIGATE_EP + EPout + effectId + effectGradient)
return send_zigatecmd_zcl_noack(self, nwkid, "00E0", nwkid + ZIGATE_EP + EPout + effectId + effectGradient)


def zcl_group_identify_trigger_effect(self, nwkid, epin, epout, effectId, effectGradient):
def zcl_group_identify_trigger_effect(self, nwkid, epin, epout, effectId, effectGradient, ackIsDisabled=DEFAULT_ACK_MODE):
self.log.logging("zclCommand", "Debug", "zcl_group_identify_trigger_effect %s %s %s %s" % (nwkid, epout, effectId, effectGradient))
if "ControllerInRawMode" in self.pluginconf.pluginConf and self.pluginconf.pluginConf["ControllerInRawMode"]:
self.log.logging("zclCommand", "Error", "zcl_group_identify_trigger_effect not implemented for RAW mode")
zcl_raw_identify(self, nwkid, epin, epout, 'TriggerEffect', identify_effect=effectId, identify_variant=effectGradient, groupaddrmode=True, ackIsDisabled=ackIsDisabled)
return

data = "%02d" % ADDRESS_MODE["group"] + nwkid + epin + epout + effectId + effectGradient
Expand Down
41 changes: 41 additions & 0 deletions Zigbee/zclRawCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,47 @@ def zcl_raw_configure_reporting_requestv2(self, nwkid, epin, epout, cluster, dir

# Discover Attributes

# Cluster 0004: Identify

def zcl_raw_identify(self, nwkid, epin, epout, command, identify_time=None, identify_effect=None, identify_variant=None, groupaddrmode=False, ackIsDisabled=DEFAULT_ACK_MODE):

self.log.logging("zclCommand", "Debug", "zcl_raw_identify %s %s %s %s %s %s %s %s %s" % (nwkid, epin, epout, command, identify_time, identify_effect, identify_variant, groupaddrmode, ackIsDisabled))
IDENTIFY_COMMAND = {
"Identify": 0x00,
"IdentifyQuery": 0x01,
"TriggerEffect": 0x40
}

Cluster = "0003"

if command not in IDENTIFY_COMMAND:
return
if command == 'Identify' and identify_time is None:
return
if command == 'TriggerEffect' and identify_effect is None and identify_variant is None:
return

# Cluster Frame:
# 0b xxxx xxxx
# |- Frame Type: Cluster Specific (0x01)
# |-- Manufacturer Specific False
# |--- Command Direction: Client to Server (0)
# | ---- Disable default response: True
# |||- ---- Reserved : 0x000
#
cluster_frame = 0b00010001
sqn = get_and_inc_ZCL_SQN(self, nwkid)
payload = "%02x" % cluster_frame + sqn + "%02x" % IDENTIFY_COMMAND[command]

if command == 'Identify' and identify_time:
payload += identify_time
elif command == 'TriggerEffect' and identify_effect and identify_variant:
payload += identify_effect + identify_variant

raw_APS_request(self, nwkid, epout, Cluster, "0104", payload, zigpyzqn=sqn, zigate_ep=epin, groupaddrmode=groupaddrmode, ackIsDisabled=ackIsDisabled)
return sqn


# Cluster 0004: Groups

def zcl_raw_add_group_membership(self, nwkid, epin, epout, GrpId, ackIsDisabled=DEFAULT_ACK_MODE):
Expand Down