Skip to content

Commit cfc0b30

Browse files
committed
CHAD-17042:Lazy loading v2 of sub drivers and copyright updates
1 parent f1557c4 commit cfc0b30

File tree

72 files changed

+524
-695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+524
-695
lines changed

drivers/SmartThings/zigbee-motion-sensor/src/aqara/aqara_utils.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
14
local capabilities = require "st.capabilities"
25

36
local aqara_utils = {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local is_aqara_products = function(opts, driver, device)
5+
local FINGERPRINTS = require("aqara.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
8+
return true, require("aqara")
9+
end
10+
end
11+
return false
12+
end
13+
14+
return is_aqara_products
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local FINGERPRINTS = {
5+
{ mfr = "LUMI", model = "lumi.motion.ac02" },
6+
{ mfr = "LUMI", model = "lumi.motion.agl02" },
7+
{ mfr = "LUMI", model = "lumi.motion.agl04" }
8+
}
9+
10+
return FINGERPRINTS
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
return function(opts, driver, device, ...)
5+
if device:get_model() == "lumi.motion.agl04" then
6+
return true, require("aqara.high-precision-motion")
7+
end
8+
return false
9+
end

drivers/SmartThings/zigbee-motion-sensor/src/aqara/high-precision-motion/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
14
local capabilities = require "st.capabilities"
25
local clusters = require "st.zigbee.zcl.clusters"
36
local cluster_base = require "st.zigbee.cluster_base"
@@ -118,9 +121,7 @@ local aqara_high_precision_motion_handler = {
118121
}
119122
}
120123
},
121-
can_handle = function(opts, driver, device, ...)
122-
return device:get_model() == "lumi.motion.agl04"
123-
end
124+
can_handle = require("aqara.high-precision-motion.can_handle")
124125
}
125126

126127
return aqara_high_precision_motion_handler

drivers/SmartThings/zigbee-motion-sensor/src/aqara/init.lua

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
14
local capabilities = require "st.capabilities"
25
local zcl_commands = require "st.zigbee.zcl.global_commands"
36
local clusters = require "st.zigbee.zcl.clusters"
@@ -16,11 +19,6 @@ local FREQUENCY_ATTRIBUTE_ID = 0x0102
1619

1720
local MOTION_DETECTED_UINT32 = 65536
1821

19-
local FINGERPRINTS = {
20-
{ mfr = "LUMI", model = "lumi.motion.ac02" },
21-
{ mfr = "LUMI", model = "lumi.motion.agl02" },
22-
{ mfr = "LUMI", model = "lumi.motion.agl04" }
23-
}
2422

2523
local CONFIGURATIONS = {
2624
{
@@ -33,14 +31,6 @@ local CONFIGURATIONS = {
3331
}
3432
}
3533

36-
local is_aqara_products = function(opts, driver, device)
37-
for _, fingerprint in ipairs(FINGERPRINTS) do
38-
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
39-
return true
40-
end
41-
end
42-
return false
43-
end
4434

4535
local function motion_illuminance_attr_handler(driver, device, value, zb_rx)
4636
-- The low 16 bits for Illuminance
@@ -123,10 +113,8 @@ local aqara_motion_handler = {
123113
}
124114
}
125115
},
126-
sub_drivers = {
127-
require("aqara.high-precision-motion")
128-
},
129-
can_handle = is_aqara_products
116+
sub_drivers = require("aqara.sub_drivers"),
117+
can_handle = require("aqara.can_handle"),
130118
}
131119

132120
return aqara_motion_handler
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local lazy_load = require "lazy_load_subdriver"
5+
6+
return {
7+
lazy_load("aqara.high-precision-motion")
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local function aurora_can_handle(opts, driver, device, ...)
5+
if device:get_manufacturer() == "Aurora" and device:get_model() == "MotionSensor51AU" then
6+
return true, require("aurora")
7+
end
8+
return false
9+
end
10+
11+
return aurora_can_handle
Lines changed: 4 additions & 16 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
local capabilities = require "st.capabilities"
155

166
local function added_handler(self, device)
@@ -24,9 +14,7 @@ local aurora_motion_driver = {
2414
lifecycle_handlers = {
2515
added = added_handler,
2616
},
27-
can_handle = function(opts, driver, device, ...)
28-
return device:get_manufacturer() == "Aurora" and device:get_model() == "MotionSensor51AU"
29-
end
17+
can_handle = require("aurora.can_handle"),
3018
}
3119

3220
return aurora_motion_driver
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local can_handle_battery_voltage = function(opts, driver, device, ...)
5+
local FINGERPRINTS = require("battery-voltage.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
8+
return true, require("battery-voltage")
9+
end
10+
end
11+
return false
12+
end
13+
14+
return can_handle_battery_voltage

0 commit comments

Comments
 (0)