Skip to content

Commit b89ff06

Browse files
zszhangshen001
authored andcommitted
Add step functionality to Zigbee curtains using Common Handler.
1 parent 52ae995 commit b89ff06

14 files changed

Lines changed: 736 additions & 4 deletions

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-aqara-roller-shade-rotate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ components:
66
version: 1
77
- id: windowShadeLevel
88
version: 1
9+
- id: statelessWindowShadeLevelStep
10+
version: 1
911
- id: stse.initializedStateWithGuide
1012
version: 1
1113
- id: stse.shadeRotateState

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-aqara.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ components:
66
version: 1
77
- id: windowShadeLevel
88
version: 1
9+
- id: statelessWindowShadeLevelStep
10+
version: 1
911
- id: stse.deviceInitialization
1012
version: 1
1113
- id: firmwareUpdate

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-battery.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ components:
88
version: 1
99
- id: windowShadeLevel
1010
version: 1
11+
- id: statelessWindowShadeLevelStep
12+
version: 1
1113
- id: battery
1214
version: 1
1315
- id: firmwareUpdate

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-no-preset.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ components:
88
version: 1
99
- id: windowShadeLevel
1010
version: 1
11+
- id: statelessWindowShadeLevelStep
12+
version: 1
1113
- id: firmwareUpdate
1214
version: 1
1315
- id: refresh

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-powerSource.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ components:
66
version: 1
77
- id: windowShadeLevel
88
version: 1
9+
- id: statelessWindowShadeLevelStep
10+
version: 1
911
- id: windowShadePreset
1012
version: 1
1113
- id: powerSource

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-profile-no-firmware-update.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ components:
88
version: 1
99
- id: windowShadeLevel
1010
version: 1
11+
- id: statelessWindowShadeLevelStep
12+
version: 1
1113
- id: refresh
1214
version: 1
1315
categories:

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-profile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ components:
88
version: 1
99
- id: windowShadeLevel
1010
version: 1
11+
- id: statelessWindowShadeLevelStep
12+
version: 1
1113
- id: firmwareUpdate
1214
version: 1
1315
- id: refresh

drivers/SmartThings/zigbee-window-treatment/profiles/window-treatment-reverse.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ components:
66
version: 1
77
- id: windowShadeLevel
88
version: 1
9+
- id: statelessWindowShadeLevelStep
10+
version: 1
911
- id: windowShadePreset
1012
version: 1
1113
- id: firmwareUpdate

drivers/SmartThings/zigbee-window-treatment/src/hanssem/init.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ local TUYA_CLUSTER = 0xEF00
2525
local DP_TYPE_VALUE = "\x02"
2626
local DP_TYPE_ENUM = "\x04"
2727

28-
local SeqNum = 0
29-
3028
-------- Send Command Function for Tuya Zigbee device -------------
3129
-- ZigbeeMessageTx:
3230
-- Uint16: 0x0000
@@ -45,6 +43,14 @@ local SeqNum = 0
4543
-- ReadAttribute:
4644
-- AttributeId: 0x0000
4745

46+
-- Get next sequence number for Tuya commands (per-device storage to avoid counter conflicts)
47+
local function get_next_tuya_seq_num(device)
48+
local seq = device:get_field("tuya_seq_num") or 0
49+
seq = (seq + 1) % 65536
50+
device:set_field("tuya_seq_num", seq)
51+
return seq
52+
end
53+
4854
local function SendCommand(device, DpId, Type, Value)
4955
local addrh = Messages.AddressHeader(
5056
ZigbeeConstants.HUB.ADDR, -- Source Address
@@ -57,8 +63,7 @@ local function SendCommand(device, DpId, Type, Value)
5763
local zclh = ZigbeeZcl.ZclHeader({cmd = data_types.ZCLCommandId(0x00)})
5864
zclh.frame_ctrl:set_cluster_specific() -- sets this frame control field to be cluster specific
5965
-- Make a payload body
60-
SeqNum = (SeqNum + 1) % 65536
61-
local strSeqNum = string.pack(">I2", SeqNum) -- Pack the Sequence number to 2 bytes unsigned integer type with big endian.
66+
local strSeqNum = string.pack(">I2", get_next_tuya_seq_num(device)) -- Pack the Sequence number to 2 bytes unsigned integer type with big endian.
6267
local LenOfValue = string.pack(">I2",string.len(Value)) -- Pack length of Value to 2 bytes unsigned integer type wiht big endian.
6368
local PayloadBody = generic_body.GenericBody(strSeqNum .. DpId .. Type .. LenOfValue .. Value)
6469
local MsgBody = ZigbeeZcl.ZclMessageBody({zcl_header = zclh, zcl_body = PayloadBody})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Copyright 2026 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local capabilities = require "st.capabilities"
5+
6+
return function(opts, driver, device)
7+
local can_handle = device:supports_capability(capabilities.statelessWindowShadeLevelStep)
8+
if can_handle then
9+
local subdriver = require("stateless_handler")
10+
return true, subdriver
11+
end
12+
return false
13+
end

0 commit comments

Comments
 (0)