Skip to content

Commit 7508866

Browse files
Fix issues caused by moving code
Also update other subdrivers so that they are preferred over the static profile subdriver.
1 parent a19a26d commit 7508866

File tree

10 files changed

+234
-350
lines changed

10 files changed

+234
-350
lines changed

drivers/SmartThings/matter-switch/profiles/plug-modular.yml

Lines changed: 0 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -48,174 +48,6 @@ components:
4848
version: 1
4949
categories:
5050
- name: SmartPlug
51-
- id: plug2
52-
optional: true
53-
capabilities:
54-
- id: switch
55-
version: 1
56-
optional: true
57-
- id: switchLevel
58-
version: 1
59-
optional: true
60-
config:
61-
values:
62-
- key: "level.value"
63-
range: [1, 100]
64-
- id: powerMeter
65-
version: 1
66-
optional: true
67-
- id: energyMeter
68-
version: 1
69-
optional: true
70-
- id: powerConsumptionReport
71-
version: 1
72-
optional: true
73-
categories:
74-
- name: SmartPlug
75-
- id: plug3
76-
optional: true
77-
capabilities:
78-
- id: switch
79-
version: 1
80-
optional: true
81-
- id: switchLevel
82-
version: 1
83-
optional: true
84-
config:
85-
values:
86-
- key: "level.value"
87-
range: [1, 100]
88-
- id: powerMeter
89-
version: 1
90-
optional: true
91-
- id: energyMeter
92-
version: 1
93-
optional: true
94-
- id: powerConsumptionReport
95-
version: 1
96-
optional: true
97-
categories:
98-
- name: SmartPlug
99-
- id: plug4
100-
optional: true
101-
capabilities:
102-
- id: switch
103-
version: 1
104-
optional: true
105-
- id: switchLevel
106-
version: 1
107-
optional: true
108-
config:
109-
values:
110-
- key: "level.value"
111-
range: [1, 100]
112-
- id: powerMeter
113-
version: 1
114-
optional: true
115-
- id: energyMeter
116-
version: 1
117-
optional: true
118-
- id: powerConsumptionReport
119-
version: 1
120-
optional: true
121-
categories:
122-
- name: SmartPlug
123-
- id: plug5
124-
optional: true
125-
capabilities:
126-
- id: switch
127-
version: 1
128-
optional: true
129-
- id: switchLevel
130-
version: 1
131-
optional: true
132-
config:
133-
values:
134-
- key: "level.value"
135-
range: [1, 100]
136-
- id: powerMeter
137-
version: 1
138-
optional: true
139-
- id: energyMeter
140-
version: 1
141-
optional: true
142-
- id: powerConsumptionReport
143-
version: 1
144-
optional: true
145-
categories:
146-
- name: SmartPlug
147-
- id: plug6
148-
optional: true
149-
capabilities:
150-
- id: switch
151-
version: 1
152-
optional: true
153-
- id: switchLevel
154-
version: 1
155-
optional: true
156-
config:
157-
values:
158-
- key: "level.value"
159-
range: [1, 100]
160-
- id: powerMeter
161-
version: 1
162-
optional: true
163-
- id: energyMeter
164-
version: 1
165-
optional: true
166-
- id: powerConsumptionReport
167-
version: 1
168-
optional: true
169-
categories:
170-
- name: SmartPlug
171-
- id: plug7
172-
optional: true
173-
capabilities:
174-
- id: switch
175-
version: 1
176-
optional: true
177-
- id: switchLevel
178-
version: 1
179-
optional: true
180-
config:
181-
values:
182-
- key: "level.value"
183-
range: [1, 100]
184-
- id: powerMeter
185-
version: 1
186-
optional: true
187-
- id: energyMeter
188-
version: 1
189-
optional: true
190-
- id: powerConsumptionReport
191-
version: 1
192-
optional: true
193-
categories:
194-
- name: SmartPlug
195-
- id: plug8
196-
optional: true
197-
capabilities:
198-
- id: switch
199-
version: 1
200-
optional: true
201-
- id: switchLevel
202-
version: 1
203-
optional: true
204-
config:
205-
values:
206-
- key: "level.value"
207-
range: [1, 100]
208-
- id: powerMeter
209-
version: 1
210-
optional: true
211-
- id: energyMeter
212-
version: 1
213-
optional: true
214-
- id: powerConsumptionReport
215-
version: 1
216-
optional: true
217-
categories:
218-
- name: SmartPlug
21951
- id: button
22052
optional: true
22153
capabilities:

drivers/SmartThings/matter-switch/src/aqara-cube/init.lua

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
local capabilities = require "st.capabilities"
1616
local clusters = require "st.matter.clusters"
17+
local common_utils = require "common-utils"
1718
local device_lib = require "st.device"
1819
local log = require "log"
1920

@@ -32,16 +33,6 @@ local INITIAL_PRESS_ONLY = "__initial_press_only" -- for devices that support MS
3233
local CUBEACTION_TIMER = "__cubeAction_timer"
3334
local CUBEACTION_TIME = 3
3435

35-
local function is_aqara_cube(opts, driver, device)
36-
if device.network_type == device_lib.NETWORK_TYPE_MATTER then
37-
local name = string.format("%s", device.manufacturer_info.product_name)
38-
if string.find(name, "Aqara Cube T1 Pro") then
39-
return true
40-
end
41-
end
42-
return false
43-
end
44-
4536
local callback_timer = function(device)
4637
return function()
4738
device:emit_event(cubeAction.cubeAction("noAction"))
@@ -251,7 +242,7 @@ local aqara_cube_handler = {
251242
}
252243
},
253244
},
254-
can_handle = is_aqara_cube
245+
can_handle = common_utils.is_aqara_cube
255246
}
256247

257248
return aqara_cube_handler

drivers/SmartThings/matter-switch/src/button-utils.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ local function create_multi_press_values_list(size, supportsHeld)
4040
local list = {"pushed", "double"}
4141
if supportsHeld then table.insert(list, "held") end
4242
-- add multi press values of 3 or greater to the list
43-
for i=3, size do
43+
for i = 3, size do
4444
table.insert(list, string.format("pushed_%dx", i))
4545
end
4646
return list
@@ -68,7 +68,6 @@ function button_utils.configure_buttons(device)
6868
local msr_eps = device:get_endpoints(clusters.Switch.ID, {feature_bitmap=clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH_RELEASE})
6969
local msl_eps = device:get_endpoints(clusters.Switch.ID, {feature_bitmap=clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH_LONG_PRESS})
7070
local msm_eps = device:get_endpoints(clusters.Switch.ID, {feature_bitmap=clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH_MULTI_PRESS})
71-
7271
for _, ep in ipairs(ms_eps) do
7372
if device.profile.components[common_utils.endpoint_to_component(device, ep)] then
7473
device.log.info_with({hub_logs=true}, string.format("Configuring Supported Values for generic switch endpoint %d", ep))
@@ -87,7 +86,6 @@ function button_utils.configure_buttons(device)
8786
supportedButtonValues_event = capabilities.button.supportedButtonValues({"pushed"}, {visibility = {displayed = false}})
8887
common_utils.set_field_for_endpoint(device, INITIAL_PRESS_ONLY, ep, true, {persist = true})
8988
end
90-
9189
if supportedButtonValues_event then
9290
device:emit_event_for_endpoint(ep, supportedButtonValues_event)
9391
end
@@ -173,7 +171,6 @@ function button_utils.multi_press_complete_event_handler(driver, device, ib, res
173171
elseif press_value > 2 then
174172
button_event = capabilities.button.button(string.format("pushed_%dx", press_value), {state_change = true})
175173
end
176-
177174
device:emit_event_for_endpoint(ib.endpoint_id, button_event)
178175
else
179176
log.info(string.format("Number of presses (%d) not supported by capability", press_value))

0 commit comments

Comments
 (0)