Skip to content

Commit 88fa1fc

Browse files
committed
zwave-thermostat: Subdriver modifications for lazy loading
1 parent d1996f0 commit 88fa1fc

File tree

13 files changed

+93
-49
lines changed

13 files changed

+93
-49
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: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ local SensorMultilevel = (require "st.zwave.CommandClass.SensorMultilevel")({ver
1414
--- @type st.zwave.CommandClass.ThermostatSetpoint
1515
local ThermostatSetpoint = (require "st.zwave.CommandClass.ThermostatSetpoint")({version=1})
1616

17-
local AEOTEC_THERMOSTAT_FINGERPRINT = {mfr = 0x0371, prod = 0x0002, model = 0x0015}
18-
19-
local function can_handle_aeotec_radiator_thermostat(opts, driver, device, ...)
20-
return device:id_match(AEOTEC_THERMOSTAT_FINGERPRINT.mfr, AEOTEC_THERMOSTAT_FINGERPRINT.prod, AEOTEC_THERMOSTAT_FINGERPRINT.model)
21-
end
22-
2317
local function thermostat_mode_report_handler(self, device, cmd)
2418
local event = nil
2519
if (cmd.args.mode == ThermostatMode.mode.OFF) then

drivers/SmartThings/zwave-thermostat/src/apiv6_bugfix/can_handle.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33

44
local function can_handle(opts, driver, device, cmd, ...)
55
local version = require "version"
6-
return version.api == 6 and
6+
local DANFOSS_LC13_THERMOSTAT_FPS = require "apiv6_bugfix.fingerprints"
7+
8+
if version.api == 6 and
79
cmd.cmd_class == cc.WAKE_UP and
810
cmd.cmd_id == WakeUp.NOTIFICATION and not
911
(device:id_match(DANFOSS_LC13_THERMOSTAT_FPS[1].manufacturerId,
1012
DANFOSS_LC13_THERMOSTAT_FPS[1].productType,
1113
DANFOSS_LC13_THERMOSTAT_FPS[1].productId) or
1214
device:id_match(DANFOSS_LC13_THERMOSTAT_FPS[2].manufacturerId,
1315
DANFOSS_LC13_THERMOSTAT_FPS[2].productType,
14-
DANFOSS_LC13_THERMOSTAT_FPS[2].productId))
16+
DANFOSS_LC13_THERMOSTAT_FPS[2].productId)) then
17+
return true, require "apiv6_bugfix"
18+
else
19+
return false
20+
end
1521
end
1622

1723
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

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
local cc = require "st.zwave.CommandClass"
55
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({ version = 1 })
66

7-
local DANFOSS_LC13_THERMOSTAT_FPS = {
8-
{ manufacturerId = 0x0002, productType = 0x0005, productId = 0x0003 }, -- Danfoss LC13 Thermostat
9-
{ manufacturerId = 0x0002, productType = 0x0005, productId = 0x0004 } -- Danfoss LC13 Thermostat
10-
}
11-
127

138
local function wakeup_notification(driver, device, cmd)
149
device:refresh()
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: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ local cooling_setpoint_defaults = require "st.zwave.defaults.thermostatCoolingSe
2323
local constants = require "st.zwave.constants"
2424
local utils = require "st.utils"
2525

26-
local CT100_THERMOSTAT_FINGERPRINTS = {
27-
{ manufacturerId = 0x0098, productType = 0x6401, productId = 0x0107 }, -- 2Gig CT100 Programmable Thermostat
28-
{ manufacturerId = 0x0098, productType = 0x6501, productId = 0x000C }, -- Iris Thermostat
29-
}
30-
3126
-- This old device uses separate endpoints to get values of temp and humidity
3227
-- DTH actually uses the old mutliInstance encap, but multichannel should be back-compat
3328
local TEMPERATURE_ENDPOINT = 1
@@ -65,16 +60,6 @@ local function set_setpoint_factory(setpoint_type)
6560
end
6661
end
6762

68-
local function can_handle_ct100_thermostat(opts, driver, device)
69-
for _, fingerprint in ipairs(CT100_THERMOSTAT_FINGERPRINTS) do
70-
if device:id_match( fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
71-
return true
72-
end
73-
end
74-
75-
return false
76-
end
77-
7863
local function thermostat_mode_report_handler(self, device, cmd)
7964
local event = nil
8065

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_popp_radiator_thermostat(opts, driver, device, ...)
5+
local POPP_THERMOSTAT_FINGERPRINT = {mfr = 0x0002, prod = 0x0115, model = 0xA010}
6+
7+
if device:id_match(POPP_THERMOSTAT_FINGERPRINT.mfr, POPP_THERMOSTAT_FINGERPRINT.prod, POPP_THERMOSTAT_FINGERPRINT.model) then
8+
return true, require "popp-radiator-thermostat"
9+
else
10+
return false
11+
end
12+
end
13+
14+
return can_handle_popp_radiator_thermostat

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ local LATEST_WAKEUP = "latest_wakeup"
1919
local CACHED_SETPOINT = "cached_setpoint"
2020
local POPP_WAKEUP_INTERVAL = 600 --seconds
2121

22-
local POPP_THERMOSTAT_FINGERPRINT = {mfr = 0x0002, prod = 0x0115, model = 0xA010}
23-
2422
local function get_latest_wakeup_timestamp(device)
2523
return device:get_field(LATEST_WAKEUP)
2624
end
@@ -38,10 +36,6 @@ local function seconds_since_latest_wakeup(device)
3836
end
3937
end
4038

41-
local function can_handle_popp_radiator_thermostat(opts, driver, device, ...)
42-
return device:id_match(POPP_THERMOSTAT_FINGERPRINT.mfr, POPP_THERMOSTAT_FINGERPRINT.prod, POPP_THERMOSTAT_FINGERPRINT.model)
43-
end
44-
4539
-- POPP is a sleepy device, therefore it won't accept setpoint commands rightaway.
4640
-- That's why driver waits for a device to wake up and then sends cached setpoint command.
4741
-- Driver assumes that wakeUps come in reguraly every 10 minutes.

0 commit comments

Comments
 (0)