Skip to content

Commit d122771

Browse files
Override doConfigure and driverSwitched in other subdrivers
The Aqara Cube and Eve Energy subdrivers need doConfigure and driverSwitched lifecycle event handler overrides to prevent the handlers from running in the main driver, which would result in match_profile running. Also fix nil value error in is_aqara_cube function.
1 parent 1d46a97 commit d122771

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

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

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
-- Copyright 2025 SmartThings
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
115
local capabilities = require "st.capabilities"
216
local clusters = require "st.matter.clusters"
317
local device_lib = require "st.device"
@@ -19,10 +33,11 @@ local CUBEACTION_TIMER = "__cubeAction_timer"
1933
local CUBEACTION_TIME = 3
2034

2135
local function is_aqara_cube(opts, driver, device)
22-
local name = string.format("%s", device.manufacturer_info.product_name)
23-
if device.network_type == device_lib.NETWORK_TYPE_MATTER and
24-
string.find(name, "Aqara Cube T1 Pro") then
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
2539
return true
40+
end
2641
end
2742
return false
2843
end
@@ -186,6 +201,12 @@ local function info_changed(driver, device, event, args)
186201
end
187202
end
188203

204+
-- override do_configure to prevent it running in the main driver
205+
local function do_configure(driver, device) end
206+
207+
-- override driver_switched to prevent it running in the main driver
208+
local function driver_switched(driver, device) end
209+
189210
local function initial_press_event_handler(driver, device, ib, response)
190211
if get_field_for_endpoint(device, INITIAL_PRESS_ONLY, ib.endpoint_id) then
191212
local map = device:get_field(COMPONENT_TO_ENDPOINT_MAP_BUTTON) or {}
@@ -214,7 +235,9 @@ local aqara_cube_handler = {
214235
lifecycle_handlers = {
215236
init = device_init,
216237
added = device_added,
217-
infoChanged = info_changed
238+
infoChanged = info_changed,
239+
doConfigure = do_configure,
240+
driverSwitched = driver_switched
218241
},
219242
matter_handlers = {
220243
attr = {

drivers/SmartThings/matter-switch/src/eve-energy/init.lua

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Copyright 2023 SmartThings
1+
-- Copyright 2025 SmartThings
22
--
33
-- Licensed under the Apache License, Version 2.0 (the "License");
44
-- you may not use this file except in compliance with the License.
@@ -277,6 +277,12 @@ local function device_removed(driver, device)
277277
delete_poll_schedule(device)
278278
end
279279

280+
-- override do_configure to prevent it running in the main driver
281+
local function do_configure(driver, device) end
282+
283+
-- override driver_switched to prevent it running in the main driver
284+
local function driver_switched(driver, device) end
285+
280286
local function handle_refresh(self, device)
281287
requestData(device)
282288
end
@@ -368,6 +374,8 @@ local eve_energy_handler = {
368374
init = device_init,
369375
added = device_added,
370376
removed = device_removed,
377+
doConfigure = do_configure,
378+
driverSwitched = driver_switched
371379
},
372380
matter_handlers = {
373381
attr = {

0 commit comments

Comments
 (0)