Skip to content

Commit eb5724a

Browse files
committed
CHAD-17040: zwave-thermostat: Subdriver modifications for lazy loading
1 parent 246a4c3 commit eb5724a

File tree

25 files changed

+248
-217
lines changed

25 files changed

+248
-217
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_aeotec_radiator_thermostat(opts, driver, device, ...)
5+
local AEOTEC_THERMOSTAT_FINGERPRINT = {mfr = 0x0371, prod = 0x0002, model = 0x0015}
6+
7+
if device:id_match(AEOTEC_THERMOSTAT_FINGERPRINT.mfr, AEOTEC_THERMOSTAT_FINGERPRINT.prod, AEOTEC_THERMOSTAT_FINGERPRINT.model) then
8+
return true, require "aeotec-radiator-thermostat"
9+
else
10+
return false
11+
end
12+
end
13+
14+
return can_handle_aeotec_radiator_thermostat

drivers/SmartThings/zwave-thermostat/src/aeotec-radiator-thermostat/init.lua

Lines changed: 4 additions & 20 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 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
144

155
local capabilities = require "st.capabilities"
166
--- @type st.zwave.CommandClass
@@ -24,12 +14,6 @@ local SensorMultilevel = (require "st.zwave.CommandClass.SensorMultilevel")({ver
2414
--- @type st.zwave.CommandClass.ThermostatSetpoint
2515
local ThermostatSetpoint = (require "st.zwave.CommandClass.ThermostatSetpoint")({version=1})
2616

27-
local AEOTEC_THERMOSTAT_FINGERPRINT = {mfr = 0x0371, prod = 0x0002, model = 0x0015}
28-
29-
local function can_handle_aeotec_radiator_thermostat(opts, driver, device, ...)
30-
return device:id_match(AEOTEC_THERMOSTAT_FINGERPRINT.mfr, AEOTEC_THERMOSTAT_FINGERPRINT.prod, AEOTEC_THERMOSTAT_FINGERPRINT.model)
31-
end
32-
3317
local function thermostat_mode_report_handler(self, device, cmd)
3418
local event = nil
3519
if (cmd.args.mode == ThermostatMode.mode.OFF) then
@@ -114,7 +98,7 @@ local aeotec_radiator_thermostat = {
11498
}
11599
},
116100
lifecycle_handlers = {added = device_added},
117-
can_handle = can_handle_aeotec_radiator_thermostat
101+
can_handle = require("aeotec-radiator-thermostat.can_handle"),
118102
}
119103

120104
return aeotec_radiator_thermostat
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
local cc = require "st.zwave.CommandClass"
7+
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({ version = 1 })
8+
local DANFOSS_LC13_THERMOSTAT_FPS = require "apiv6_bugfix.fingerprints"
9+
10+
if version.api == 6 and
11+
cmd.cmd_class == cc.WAKE_UP and
12+
cmd.cmd_id == WakeUp.NOTIFICATION and not
13+
(device:id_match(DANFOSS_LC13_THERMOSTAT_FPS[1].manufacturerId,
14+
DANFOSS_LC13_THERMOSTAT_FPS[1].productType,
15+
DANFOSS_LC13_THERMOSTAT_FPS[1].productId) or
16+
device:id_match(DANFOSS_LC13_THERMOSTAT_FPS[2].manufacturerId,
17+
DANFOSS_LC13_THERMOSTAT_FPS[2].productType,
18+
DANFOSS_LC13_THERMOSTAT_FPS[2].productId)) then
19+
return true, require "apiv6_bugfix"
20+
else
21+
return false
22+
end
23+
end
24+
25+
return can_handle
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 DANFOSS_LC13_THERMOSTAT_FPS = {
5+
{ manufacturerId = 0x0002, productType = 0x0005, productId = 0x0003 }, -- Danfoss LC13 Thermostat
6+
{ manufacturerId = 0x0002, productType = 0x0005, productId = 0x0004 } -- Danfoss LC13 Thermostat
7+
}
8+
9+
return DANFOSS_LC13_THERMOSTAT_FPS
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
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

4-
local DANFOSS_LC13_THERMOSTAT_FPS = {
5-
{ manufacturerId = 0x0002, productType = 0x0005, productId = 0x0003 }, -- Danfoss LC13 Thermostat
6-
{ manufacturerId = 0x0002, productType = 0x0005, productId = 0x0004 } -- Danfoss LC13 Thermostat
7-
}
8-
9-
local function can_handle(opts, driver, device, cmd, ...)
10-
local version = require "version"
11-
return version.api == 6 and
12-
cmd.cmd_class == cc.WAKE_UP and
13-
cmd.cmd_id == WakeUp.NOTIFICATION and not
14-
(device:id_match(DANFOSS_LC13_THERMOSTAT_FPS[1].manufacturerId,
15-
DANFOSS_LC13_THERMOSTAT_FPS[1].productType,
16-
DANFOSS_LC13_THERMOSTAT_FPS[1].productId) or
17-
device:id_match(DANFOSS_LC13_THERMOSTAT_FPS[2].manufacturerId,
18-
DANFOSS_LC13_THERMOSTAT_FPS[2].productType,
19-
DANFOSS_LC13_THERMOSTAT_FPS[2].productId))
20-
end
217

228
local function wakeup_notification(driver, device, cmd)
239
device:refresh()
@@ -30,7 +16,7 @@ local apiv6_bugfix = {
3016
}
3117
},
3218
NAME = "apiv6_bugfix",
33-
can_handle = can_handle
19+
can_handle = require("apiv6_bugfix.can_handle"),
3420
}
3521

3622
return apiv6_bugfix
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_ct100_thermostat(opts, driver, device)
5+
local CT100_THERMOSTAT_FINGERPRINTS = require "ct100-thermostat.fingerprints"
6+
for _, fingerprint in ipairs(CT100_THERMOSTAT_FINGERPRINTS) do
7+
if device:id_match( fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
8+
return true, require "ct100-thermostat"
9+
end
10+
end
11+
12+
return false
13+
end
14+
15+
return can_handle_ct100_thermostat
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 CT100_THERMOSTAT_FINGERPRINTS = {
5+
{ manufacturerId = 0x0098, productType = 0x6401, productId = 0x0107 }, -- 2Gig CT100 Programmable Thermostat
6+
{ manufacturerId = 0x0098, productType = 0x6501, productId = 0x000C }, -- Iris Thermostat
7+
}
8+
9+
return CT100_THERMOSTAT_FINGERPRINTS

drivers/SmartThings/zwave-thermostat/src/ct100-thermostat/init.lua

Lines changed: 4 additions & 29 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 2025 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"
@@ -33,11 +23,6 @@ local cooling_setpoint_defaults = require "st.zwave.defaults.thermostatCoolingSe
3323
local constants = require "st.zwave.constants"
3424
local utils = require "st.utils"
3525

36-
local CT100_THERMOSTAT_FINGERPRINTS = {
37-
{ manufacturerId = 0x0098, productType = 0x6401, productId = 0x0107 }, -- 2Gig CT100 Programmable Thermostat
38-
{ manufacturerId = 0x0098, productType = 0x6501, productId = 0x000C }, -- Iris Thermostat
39-
}
40-
4126
-- This old device uses separate endpoints to get values of temp and humidity
4227
-- DTH actually uses the old mutliInstance encap, but multichannel should be back-compat
4328
local TEMPERATURE_ENDPOINT = 1
@@ -75,16 +60,6 @@ local function set_setpoint_factory(setpoint_type)
7560
end
7661
end
7762

78-
local function can_handle_ct100_thermostat(opts, driver, device)
79-
for _, fingerprint in ipairs(CT100_THERMOSTAT_FINGERPRINTS) do
80-
if device:id_match( fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
81-
return true
82-
end
83-
end
84-
85-
return false
86-
end
87-
8863
local function thermostat_mode_report_handler(self, device, cmd)
8964
local event = nil
9065

@@ -210,7 +185,7 @@ local ct100_thermostat = {
210185
[capabilities.refresh.commands.refresh.NAME] = do_refresh
211186
}
212187
},
213-
can_handle = can_handle_ct100_thermostat,
188+
can_handle = require("ct100-thermostat.can_handle"),
214189
}
215190

216191
return ct100_thermostat
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_fibaro_heat_controller(opts, driver, device, ...)
5+
local FINGERPRINTS = require("fibaro-heat-controller.fingerprints")
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:id_match(fingerprint.mfr, fingerprint.prod, fingerprint.model) then
8+
return true, require("fibaro-heat-controller")
9+
end
10+
end
11+
12+
return false
13+
end
14+
15+
return can_handle_fibaro_heat_controller
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 FIBARO_HEAT_FINGERPRINTS = {
5+
{mfr = 0x010F, prod = 0x1301, model = 0x1000}, -- Fibaro Heat Controller
6+
{mfr = 0x010F, prod = 0x1301, model = 0x1001} -- Fibaro Heat Controller
7+
}
8+
9+
return FIBARO_HEAT_FINGERPRINTS

0 commit comments

Comments
 (0)