Skip to content

Commit 95436cd

Browse files
committed
CHAD-17076: zigbee-sound-sensor lazy load subdrivers
1 parent b82b7e1 commit 95436cd

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

drivers/SmartThings/zigbee-sound-sensor/src/init.lua

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
-- Copyright 2022 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.
1+
-- Copyright 2022 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
144

155
local device_management = require "st.zigbee.device_management"
166
local ZigbeeDriver = require "st.zigbee"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
return function(sub_driver_name)
5+
-- gets the current lua libs api version
6+
local version = require "version"
7+
local ZigbeeDriver = require "st.zigbee"
8+
if version.api >= 16 then
9+
return ZigbeeDriver.lazy_load_sub_driver_v2(sub_driver_name)
10+
elseif version.api >= 9 then
11+
return ZigbeeDriver.lazy_load_sub_driver(require(sub_driver_name))
12+
else
13+
return require(sub_driver_name)
14+
end
15+
end

drivers/SmartThings/zigbee-sound-sensor/src/test/test_zigbee_sound_sensor.lua

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
-- Copyright 2022 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.
1+
-- Copyright 2022 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
143

154
-- Mock out globals
165
local test = require "integration_test"

0 commit comments

Comments
 (0)