Skip to content

Commit 0ac1f3a

Browse files
authored
Merge pull request #2799 from SmartThingsCommunity/CHAD-17092-zwave-sensor-llv2
CHAD-17092: zwave-sensor lazy-loading v2
2 parents af61d35 + 709cda3 commit 0ac1f3a

94 files changed

Lines changed: 766 additions & 1162 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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+
local function can_handle_aeotec_multisensor(opts, self, device, ...)
5+
local FINGERPRINTS = require("aeotec-multisensor.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
8+
local subdriver = require("aeotec-multisensor")
9+
return true, subdriver
10+
end
11+
end
12+
return false
13+
end
14+
15+
return can_handle_aeotec_multisensor
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+
local AEOTEC_MULTISENSOR_FINGERPRINTS = {
5+
{ manufacturerId = 0x0086, productId = 0x0064 }, -- MultiSensor 6
6+
{ manufacturerId = 0x0371, productId = 0x0018 }, -- MultiSensor 7
7+
}
8+
9+
return AEOTEC_MULTISENSOR_FINGERPRINTS
Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,12 @@
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
local capabilities = require "st.capabilities"
165
--- @type st.zwave.CommandClass
176
local cc = require "st.zwave.CommandClass"
187
--- @type st.zwave.CommandClass.Notification
198
local Notification = (require "st.zwave.CommandClass.Notification")({ version = 3 })
209

21-
local AEOTEC_MULTISENSOR_FINGERPRINTS = {
22-
{ manufacturerId = 0x0086, productId = 0x0064 }, -- MultiSensor 6
23-
{ manufacturerId = 0x0371, productId = 0x0018 }, -- MultiSensor 7
24-
}
25-
26-
local function can_handle_aeotec_multisensor(opts, self, device, ...)
27-
for _, fingerprint in ipairs(AEOTEC_MULTISENSOR_FINGERPRINTS) do
28-
if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
29-
local subdriver = require("aeotec-multisensor")
30-
return true, subdriver
31-
end
32-
end
33-
return false
34-
end
35-
3610
local function notification_report_handler(self, device, cmd)
3711
local event
3812
if cmd.args.notification_type == Notification.notification_type.POWER_MANAGEMENT then
@@ -61,12 +35,10 @@ local aeotec_multisensor = {
6135
[Notification.REPORT] = notification_report_handler
6236
}
6337
},
64-
sub_drivers = {
65-
require("aeotec-multisensor/multisensor-6"),
66-
require("aeotec-multisensor/multisensor-7")
67-
},
38+
sub_drivers = require("aeotec-multisensor.sub_drivers"),
6839
NAME = "aeotec multisensor",
69-
can_handle = can_handle_aeotec_multisensor
40+
can_handle = require("aeotec-multisensor.can_handle"),
41+
shared_device_thread_enabled = true,
7042
}
7143

7244
return aeotec_multisensor
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 can_handle_multisensor_6(opts, self, device, ...)
5+
local MULTISENSOR_6_PRODUCT_ID = 0x0064
6+
if device.zwave_product_id == MULTISENSOR_6_PRODUCT_ID then
7+
return true, require("aeotec-multisensor.multisensor-6")
8+
end
9+
return false
10+
end
11+
return can_handle_multisensor_6

drivers/SmartThings/zwave-sensor/src/aeotec-multisensor/multisensor-6/init.lua

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
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+
4+
145

156
local capabilities = require "st.capabilities"
167
--- @type st.zwave.CommandClass
@@ -19,12 +10,8 @@ local cc = require "st.zwave.CommandClass"
1910
local Configuration = (require "st.zwave.CommandClass.Configuration")({ version = 2 })
2011
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({version = 2})
2112

22-
local MULTISENSOR_6_PRODUCT_ID = 0x0064
2313
local PREFERENCE_NUM = 9
2414

25-
local function can_handle_multisensor_6(opts, self, device, ...)
26-
return device.zwave_product_id == MULTISENSOR_6_PRODUCT_ID
27-
end
2815

2916
local function wakeup_notification(driver, device, cmd)
3017
--Note sending WakeUpIntervalGet the first time a device wakes up will happen by default in Lua libs 0.49.x and higher
@@ -62,7 +49,8 @@ local multisensor_6 = {
6249
}
6350
},
6451
NAME = "aeotec multisensor 6",
65-
can_handle = can_handle_multisensor_6
52+
can_handle = require("aeotec-multisensor.multisensor-6.can_handle"),
53+
shared_device_thread_enabled = true,
6654
}
6755

6856
return multisensor_6
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local function can_handle_multisensor_7(opts, self, device, ...)
5+
local MULTISENSOR_7_PRODUCT_ID = 0x0018
6+
if device.zwave_product_id == MULTISENSOR_7_PRODUCT_ID then
7+
return true, require("aeotec-multisensor.multisensor-7")
8+
end
9+
return false
10+
end
11+
12+
return can_handle_multisensor_7

drivers/SmartThings/zwave-sensor/src/aeotec-multisensor/multisensor-7/init.lua

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
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+
4+
145

156
local capabilities = require "st.capabilities"
167
--- @type st.zwave.CommandClass
@@ -19,13 +10,8 @@ local cc = require "st.zwave.CommandClass"
1910
local Configuration = (require "st.zwave.CommandClass.Configuration")({ version = 2 })
2011
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({ version = 2 })
2112

22-
local MULTISENSOR_7_PRODUCT_ID = 0x0018
2313
local PREFERENCE_NUM = 10
2414

25-
local function can_handle_multisensor_7(opts, self, device, ...)
26-
return device.zwave_product_id == MULTISENSOR_7_PRODUCT_ID
27-
end
28-
2915
local function wakeup_notification(driver, device, cmd)
3016
--Note sending WakeUpIntervalGet the first time a device wakes up will happen by default in Lua libs 0.49.x and higher
3117
--This is done to help the hub correctly set the checkInterval for migrated devices.
@@ -62,7 +48,8 @@ local multisensor_7 = {
6248
}
6349
},
6450
NAME = "aeotec multisensor 7",
65-
can_handle = can_handle_multisensor_7
51+
can_handle = require("aeotec-multisensor.multisensor-7.can_handle"),
52+
shared_device_thread_enabled = true,
6653
}
6754

6855
return multisensor_7
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+
local lazy_load_if_possible = require "lazy_load_subdriver"
5+
local sub_drivers = {
6+
lazy_load_if_possible("aeotec-multisensor/multisensor-6"),
7+
lazy_load_if_possible("aeotec-multisensor/multisensor-7"),
8+
}
9+
return sub_drivers
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+
local function can_handle_zwave_water_temp_humidity_sensor(opts, driver, device, ...)
5+
local FINGERPRINTS = require("aeotec-water-sensor.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
8+
local subdriver = require("aeotec-water-sensor")
9+
return true, subdriver
10+
end
11+
end
12+
return false
13+
end
14+
15+
return can_handle_zwave_water_temp_humidity_sensor
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 ZWAVE_WATER_TEMP_HUMIDITY_FINGERPRINTS = {
5+
{ manufacturerId = 0x0371, productType = 0x0002, productId = 0x0013 }, -- Aeotec Water Sensor 7 Pro EU
6+
{ manufacturerId = 0x0371, productType = 0x0102, productId = 0x0013 }, -- Aeotec Water Sensor 7 Pro US
7+
{ manufacturerId = 0x0371, productType = 0x0202, productId = 0x0013 }, -- Aeotec Water Sensor 7 Pro AU
8+
{ manufacturerId = 0x0371, productId = 0x0012 } -- Aeotec Water Sensor 7
9+
}
10+
11+
return ZWAVE_WATER_TEMP_HUMIDITY_FINGERPRINTS

0 commit comments

Comments
 (0)