Skip to content

Commit 80b0947

Browse files
committed
CHAD-17093: zwave-siren lazy loading of sub-drivers
1 parent 5a96c15 commit 80b0947

Some content is hidden

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

44 files changed

+317
-434
lines changed
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 function can_handle_aeon_siren(opts, driver, device, ...)
5+
local AEON_MFR = 0x0086
6+
local AEON_SIREN_PRODUCT_ID = 0x0050
7+
8+
if device.zwave_manufacturer_id == AEON_MFR and device.zwave_product_id == AEON_SIREN_PRODUCT_ID then
9+
return true, require("aeon-siren")
10+
end
11+
return false
12+
end
13+
14+
return can_handle_aeon_siren

drivers/SmartThings/zwave-siren/src/aeon-siren/init.lua

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
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 Basic = (require "st.zwave.CommandClass.Basic")({ version=1 })
166
local Configuration = (require "st.zwave.CommandClass.Configuration")({ version=1 })
177

18-
local AEON_MFR = 0x0086
19-
local AEON_SIREN_PRODUCT_ID = 0x0050
20-
218
local SOUND_TYPE_AND_VOLUME_PARAMETER_NUMBER = 37
229
local CONFIGURE_SOUND_TYPE = "type"
2310
local SOUND_TYPE_DEFAULT = 1
2411
local CONFIGURE_VOLUME = "volume"
2512
local VOLUME_DEFAULT = 3
2613

27-
local function can_handle_aeon_siren(opts, driver, device, ...)
28-
return device.zwave_manufacturer_id == AEON_MFR and device.zwave_product_id == AEON_SIREN_PRODUCT_ID
29-
end
3014

3115
local function configure_sound(device, sound_type, volume)
3216
if sound_type == nil then sound_type = SOUND_TYPE_DEFAULT end
@@ -64,7 +48,7 @@ end
6448

6549
local aeon_siren = {
6650
NAME = "aeon-siren",
67-
can_handle = can_handle_aeon_siren,
51+
can_handle = require("aeon-siren.can_handle"),
6852
lifecycle_handlers = {
6953
doConfigure = do_configure,
7054
infoChanged = info_changed
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 function can_handle_aeotec_doorbell_siren(opts, driver, device, ...)
5+
local FINGERPRINTS = require("aeotec-doorbell-siren.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
8+
return true, require("aeotec-doorbell-siren")
9+
end
10+
end
11+
return false
12+
end
13+
14+
return can_handle_aeotec_doorbell_siren
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local AEOTEC_DOORBELL_SIREN_FINGERPRINTS = {
5+
{ manufacturerId = 0x0371, productType = 0x0003, productId = 0x00A2}, -- Aeotec Doorbell 6 (EU)
6+
{ manufacturerId = 0x0371, productType = 0x0103, productId = 0x00A2}, -- Aeotec Doorbell 6 (US)
7+
{ manufacturerId = 0x0371, productType = 0x0203, productId = 0x00A2}, -- Aeotec Doorbell 6 (AU)
8+
{ manufacturerId = 0x0371, productType = 0x0003, productId = 0x00A4}, -- Aeotec Siren 6 (EU)
9+
{ manufacturerId = 0x0371, productType = 0x0103, productId = 0x00A4}, -- Aeotec Siren 6 (US)
10+
{ manufacturerId = 0x0371, productType = 0x0203, productId = 0x00A4}, -- Aeotec Siren 6 (AU)
11+
}
12+
13+
return AEOTEC_DOORBELL_SIREN_FINGERPRINTS

drivers/SmartThings/zwave-siren/src/aeotec-doorbell-siren/init.lua

Lines changed: 4 additions & 30 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 capabilities = require "st.capabilities"
166
local cc = require "st.zwave.CommandClass"
@@ -20,14 +10,6 @@ local Notification = (require "st.zwave.CommandClass.Notification")({version=3})
2010
local SoundSwitch = (require "st.zwave.CommandClass.SoundSwitch")({version=1})
2111
local preferencesMap = require "preferences"
2212

23-
local AEOTEC_DOORBELL_SIREN_FINGERPRINTS = {
24-
{ manufacturerId = 0x0371, productType = 0x0003, productId = 0x00A2}, -- Aeotec Doorbell 6 (EU)
25-
{ manufacturerId = 0x0371, productType = 0x0103, productId = 0x00A2}, -- Aeotec Doorbell 6 (US)
26-
{ manufacturerId = 0x0371, productType = 0x0203, productId = 0x00A2}, -- Aeotec Doorbell 6 (AU)
27-
{ manufacturerId = 0x0371, productType = 0x0003, productId = 0x00A4}, -- Aeotec Siren 6 (EU)
28-
{ manufacturerId = 0x0371, productType = 0x0103, productId = 0x00A4}, -- Aeotec Siren 6 (US)
29-
{ manufacturerId = 0x0371, productType = 0x0203, productId = 0x00A4}, -- Aeotec Siren 6 (AU)
30-
}
3113

3214
local COMPONENT_NAME = "componentName"
3315
local TONE = "tone"
@@ -51,14 +33,6 @@ local BUTTON_BATTERY_NORMAL = 99
5133
local DEVICE_PROFILE_CHANGE_IN_PROGRESS = "device_profile_change_in_progress"
5234
local NEXT_BUTTON_BATTERY_EVENT_DETAILS = "next_button_battery_event_details"
5335

54-
local function can_handle_aeotec_doorbell_siren(opts, driver, device, ...)
55-
for _, fingerprint in ipairs(AEOTEC_DOORBELL_SIREN_FINGERPRINTS) do
56-
if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
57-
return true
58-
end
59-
end
60-
return false
61-
end
6236

6337
local function querySoundStatus(device)
6438
for endpoint = 2, NUMBER_OF_SOUND_COMPONENTS do
@@ -316,7 +290,7 @@ end
316290

317291
local aeotec_doorbell_siren = {
318292
NAME = "aeotec-doorbell-siren",
319-
can_handle = can_handle_aeotec_doorbell_siren,
293+
can_handle = require("aeotec-doorbell-siren.can_handle"),
320294

321295
lifecycle_handlers = {
322296
added = device_added,
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(opts, driver, device, cmd, ...)
5+
local version = require "version"
6+
return version.api == 6 and
7+
cmd.cmd_class == cc.WAKE_UP and
8+
cmd.cmd_id == WakeUp.NOTIFICATION
9+
end
10+
11+
return can_handle
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
14
local cc = require "st.zwave.CommandClass"
25
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({ version = 1 })
36

47

5-
local function can_handle(opts, driver, device, cmd, ...)
6-
local version = require "version"
7-
return version.api == 6 and
8-
cmd.cmd_class == cc.WAKE_UP and
9-
cmd.cmd_id == WakeUp.NOTIFICATION
10-
end
118

129
local function wakeup_notification(driver, device, cmd)
1310
device:refresh()
@@ -20,7 +17,7 @@ local apiv6_bugfix = {
2017
}
2118
},
2219
NAME = "apiv6_bugfix",
23-
can_handle = can_handle
20+
can_handle = require("apiv6_bugfix.can_handle"),
2421
}
2522

2623
return apiv6_bugfix

drivers/SmartThings/zwave-siren/src/configurations.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 devices = {
166
YALE_SIREN = {
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 function can_handle_ecolink_wireless_siren(opts, driver, device, ...)
5+
local FINGERPRINTS = require("ecolink-wireless-siren.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
8+
return true, require("ecolink-wireless-siren")
9+
end
10+
end
11+
return false
12+
end
13+
14+
return can_handle_ecolink_wireless_siren
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 ECOLINK_WIRELESS_SIREN_FINGERPRINTS = {
5+
{ manufacturerId = 0x014A, productType = 0x0005, productId = 0x000A }, -- Ecolink Siren
6+
}
7+
8+
return ECOLINK_WIRELESS_SIREN_FINGERPRINTS

0 commit comments

Comments
 (0)