Skip to content

Commit c178696

Browse files
authored
WWSTCERT-8722/8725 [Aqara] add Aqara Wireless Remote Switch H1(Single/Double) (#2511)
* add Aqara Wireless Remote Switch H1(Single/Double) * remove the commented‑out code
1 parent 5d997ba commit c178696

File tree

5 files changed

+202
-49
lines changed

5 files changed

+202
-49
lines changed

drivers/SmartThings/zigbee-button/fingerprints.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ zigbeeManufacturer:
2424
manufacturer: LUMI
2525
model: lumi.remote.b286acn03
2626
deviceProfileName: aqara-double-buttons
27+
- id: "LUMI/lumi.remote.b18ac1"
28+
deviceLabel: Aqara Wireless Remote Switch H1 (Single Rocker)
29+
manufacturer: LUMI
30+
model: lumi.remote.b18ac1
31+
deviceProfileName: aqara-single-button-mode
32+
- id: "LUMI/lumi.remote.b28ac1"
33+
deviceLabel: Aqara Wireless Remote Switch H1 (Double Rocker)
34+
manufacturer: LUMI
35+
model: lumi.remote.b28ac1
36+
deviceProfileName: aqara-double-buttons-mode
2737
- id: "HEIMAN/SOS-EM"
2838
deviceLabel: HEIMAN Button
2939
manufacturer: HEIMAN
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: aqara-double-buttons-mode
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: button
6+
version: 1
7+
- id: batteryLevel
8+
version: 1
9+
- id: firmwareUpdate
10+
version: 1
11+
- id: refresh
12+
version: 1
13+
categories:
14+
- name: RemoteController
15+
- id: button1
16+
capabilities:
17+
- id: button
18+
version: 1
19+
categories:
20+
- name: RemoteController
21+
- id: button2
22+
capabilities:
23+
- id: button
24+
version: 1
25+
categories:
26+
- name: RemoteController
27+
- id: all
28+
capabilities:
29+
- id: button
30+
version: 1
31+
categories:
32+
- name: RemoteController
33+
preferences:
34+
- preferenceId: stse.allowOperationModeChange
35+
explicit: true
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: aqara-single-button-mode
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: button
6+
version: 1
7+
- id: batteryLevel
8+
version: 1
9+
- id: firmwareUpdate
10+
version: 1
11+
- id: refresh
12+
version: 1
13+
categories:
14+
- name: Button
15+
preferences:
16+
- preferenceId: stse.allowOperationModeChange
17+
explicit: true

drivers/SmartThings/zigbee-button/src/aqara/init.lua

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ local data_types = require "st.zigbee.data_types"
1919
local capabilities = require "st.capabilities"
2020
local button_utils = require "button_utils"
2121

22+
local MODE = "devicemode"
23+
local MODE_CHANGE = "stse.allowOperationModeChange"
24+
local SUPPORTED_BUTTON = { { "pushed" }, { "pushed", "held", "double" } }
2225

2326
local PowerConfiguration = clusters.PowerConfiguration
2427
local PRIVATE_CLUSTER_ID = 0xFCC0
2528
local PRIVATE_ATTRIBUTE_ID_T1 = 0x0009
2629
local PRIVATE_ATTRIBUTE_ID_E1 = 0x0125
30+
local PRIVATE_ATTRIBUTE_ID_ALIVE = 0x00F7
2731
local MFG_CODE = 0x115F
2832

2933
local MULTISTATE_INPUT_CLUSTER_ID = 0x0012
@@ -34,7 +38,9 @@ local FINGERPRINTS = {
3438
["lumi.remote.b1acn02"] = { mfr = "LUMI", btn_cnt = 1 },
3539
["lumi.remote.acn003"] = { mfr = "LUMI", btn_cnt = 1 },
3640
["lumi.remote.b186acn03"] = { mfr = "LUMI", btn_cnt = 1 },
37-
["lumi.remote.b286acn03"] = { mfr = "LUMI", btn_cnt = 3 }
41+
["lumi.remote.b286acn03"] = { mfr = "LUMI", btn_cnt = 3 },
42+
["lumi.remote.b18ac1"] = { mfr = "LUMI", btn_cnt = 1 },
43+
["lumi.remote.b28ac1"] = { mfr = "LUMI", btn_cnt = 3 }
3844
}
3945

4046
local configuration = {
@@ -103,6 +109,36 @@ local function battery_level_handler(driver, device, value, zb_rx)
103109
end
104110
end
105111

112+
local function mode_switching_handler(driver, device, value, zb_rx)
113+
local btn_evt_cnt = FINGERPRINTS[device:get_model()].btn_cnt or 1
114+
local allow = device.preferences[MODE_CHANGE] or false
115+
if allow then
116+
local mode = device:get_field(MODE) or 1
117+
mode = 3 - mode
118+
device:set_field(MODE, mode, { persist = true })
119+
device:send(cluster_base.write_manufacturer_specific_attribute(device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID_E1,
120+
MFG_CODE, data_types.Uint8, mode))
121+
device:emit_event(capabilities.button.supportedButtonValues(SUPPORTED_BUTTON[mode],
122+
{ visibility = { displayed = false } }))
123+
device:emit_event(capabilities.button.numberOfButtons({ value = 1 }))
124+
button_utils.emit_event_if_latest_state_missing(device, "main", capabilities.button, capabilities.button.button.NAME,
125+
capabilities.button.button.pushed({ state_change = false }))
126+
if btn_evt_cnt > 1 then
127+
for i = 1, btn_evt_cnt do
128+
device:emit_component_event(device.profile.components[COMP_LIST[i]],
129+
capabilities.button.supportedButtonValues(SUPPORTED_BUTTON[mode],
130+
{ visibility = { displayed = false } }))
131+
device:emit_component_event(device.profile.components[COMP_LIST[i]],
132+
capabilities.button.numberOfButtons({ value = 1 }))
133+
device:emit_component_event(device.profile.components[COMP_LIST[i]],
134+
capabilities.button.button.pushed({ state_change = false }))
135+
button_utils.emit_event_if_latest_state_missing(device, COMP_LIST[i], capabilities.button,
136+
capabilities.button.button.NAME, capabilities.button.button.pushed({ state_change = false }))
137+
end
138+
end
139+
end
140+
end
141+
106142
local is_aqara_products = function(opts, driver, device)
107143
local isAqaraProducts = false
108144
if FINGERPRINTS[device:get_model()] and FINGERPRINTS[device:get_model()].mfr == device:get_manufacturer() then
@@ -122,8 +158,18 @@ end
122158

123159
local function added_handler(self, device)
124160
local btn_evt_cnt = FINGERPRINTS[device:get_model()].btn_cnt or 1
125-
126-
device:emit_event(capabilities.button.supportedButtonValues({ "pushed", "held", "double" },
161+
local mode = device:get_field(MODE) or 0
162+
local model = device:get_model()
163+
164+
if mode == 0 then
165+
if model == "lumi.remote.b18ac1" or model == "lumi.remote.b28ac1" then
166+
mode = 1
167+
else
168+
mode = 2
169+
end
170+
end
171+
device:set_field(MODE, mode, { persist = true })
172+
device:emit_event(capabilities.button.supportedButtonValues(SUPPORTED_BUTTON[mode],
127173
{ visibility = { displayed = false } }))
128174
device:emit_event(capabilities.button.numberOfButtons({ value = 1 }))
129175
button_utils.emit_event_if_latest_state_missing(device, "main", capabilities.button, capabilities.button.button.NAME,
@@ -135,7 +181,7 @@ local function added_handler(self, device)
135181
if btn_evt_cnt > 1 then
136182
for i = 1, btn_evt_cnt do
137183
device:emit_component_event(device.profile.components[COMP_LIST[i]],
138-
capabilities.button.supportedButtonValues({ "pushed", "held", "double" },
184+
capabilities.button.supportedButtonValues(SUPPORTED_BUTTON[mode],
139185
{ visibility = { displayed = false } }))
140186
device:emit_component_event(device.profile.components[COMP_LIST[i]],
141187
capabilities.button.numberOfButtons({ value = 1 }))
@@ -179,6 +225,9 @@ local aqara_wireless_switch_handler = {
179225
},
180226
[PowerConfiguration.ID] = {
181227
[PowerConfiguration.attributes.BatteryVoltage.ID] = battery_level_handler
228+
},
229+
[PRIVATE_CLUSTER_ID] = {
230+
[PRIVATE_ATTRIBUTE_ID_ALIVE] = mode_switching_handler
182231
}
183232
}
184233
},

0 commit comments

Comments
 (0)