Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local function can_handle(opts, driver, device, cmd, ...)
local cc = require "st.zwave.CommandClass"
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({ version = 1 })
local version = require "version"
if version.api == 6 and
cmd.cmd_class == cc.WAKE_UP and
cmd.cmd_id == WakeUp.NOTIFICATION then
return true, require("apiv6_bugfix")
end
return false
end

return can_handle
13 changes: 4 additions & 9 deletions drivers/SmartThings/zwave-smoke-alarm/src/apiv6_bugfix/init.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local cc = require "st.zwave.CommandClass"
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({ version = 1 })


local function can_handle(opts, driver, device, cmd, ...)
local version = require "version"
return version.api == 6 and
cmd.cmd_class == cc.WAKE_UP and
cmd.cmd_id == WakeUp.NOTIFICATION
end

local function wakeup_notification(driver, device, cmd)
device:refresh()
end
Expand All @@ -20,7 +15,7 @@ local apiv6_bugfix = {
}
},
NAME = "apiv6_bugfix",
can_handle = can_handle
can_handle = require("apiv6_bugfix.can_handle"),
}

return apiv6_bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local function can_handle_fibaro_smoke_sensor(opts, driver, device, cmd, ...)
local FINGERPRINTS = require("fibaro-smoke-sensor.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:id_match( fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
return true, require("fibaro-smoke-sensor")
end
end
return false
end

return can_handle_fibaro_smoke_sensor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local FIBARO_SMOKE_SENSOR_FINGERPRINTS = {
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x1002 }, -- Fibaro Smoke Sensor
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x1003 }, -- Fibaro Smoke Sensor
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x3002 }, -- Fibaro Smoke Sensor
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x4002 } -- Fibaro Smoke Sensor
}

return FIBARO_SMOKE_SENSOR_FINGERPRINTS
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local capabilities = require "st.capabilities"
--- @type st.zwave.CommandClass
Expand All @@ -24,26 +14,12 @@ local WakeUp = (require "st.zwave.CommandClass.WakeUp")({version=1})

local FIBARO_SMOKE_SENSOR_WAKEUP_INTERVAL = 21600 --seconds

local FIBARO_SMOKE_SENSOR_FINGERPRINTS = {
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x1002 }, -- Fibaro Smoke Sensor
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x1003 }, -- Fibaro Smoke Sensor
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x3002 }, -- Fibaro Smoke Sensor
{ manufacturerId = 0x010F, productType = 0x0C02, productId = 0x4002 } -- Fibaro Smoke Sensor
}

--- Determine whether the passed device is fibaro smoke sensro
---
--- @param driver st.zwave.Driver
--- @param device st.zwave.Device
--- @return boolean true if the device is fibaro smoke sensor
local function can_handle_fibaro_smoke_sensor(opts, driver, device, cmd, ...)
for _, fingerprint in ipairs(FIBARO_SMOKE_SENSOR_FINGERPRINTS) do
if device:id_match( fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
return true
end
end
return false
end

local function device_added(self, device)
device:send(WakeUp:IntervalSet({node_id = self.environment_info.hub_zwave_id, seconds = FIBARO_SMOKE_SENSOR_WAKEUP_INTERVAL}))
Expand Down Expand Up @@ -76,7 +52,7 @@ local fibaro_smoke_sensor = {
added = device_added
},
NAME = "fibaro smoke sensor",
can_handle = can_handle_fibaro_smoke_sensor,
can_handle = require("fibaro-smoke-sensor.can_handle"),
health_check = false,
}

Expand Down
23 changes: 4 additions & 19 deletions drivers/SmartThings/zwave-smoke-alarm/src/init.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local capabilities = require "st.capabilities"
--- @type st.zwave.CommandClass
Expand Down Expand Up @@ -83,12 +73,7 @@ local driver_template = {
capabilities.temperatureAlarm,
capabilities.temperatureMeasurement
},
sub_drivers = {
require("zwave-smoke-co-alarm-v1"),
require("zwave-smoke-co-alarm-v2"),
require("fibaro-smoke-sensor"),
require("apiv6_bugfix"),
},
sub_drivers = require("sub_drivers"),
lifecycle_handlers = {
init = device_init,
infoChanged = info_changed,
Expand Down
18 changes: 18 additions & 0 deletions drivers/SmartThings/zwave-smoke-alarm/src/lazy_load_subdriver.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


return function(sub_driver_name)
-- gets the current lua libs api version
local ZwaveDriver = require "st.zwave.driver"
local version = require "version"

if version.api >= 16 then
return ZwaveDriver.lazy_load_sub_driver_v2(sub_driver_name)
elseif version.api >= 9 then
return ZwaveDriver.lazy_load_sub_driver(require(sub_driver_name))
else
return require(sub_driver_name)
end

end
16 changes: 3 additions & 13 deletions drivers/SmartThings/zwave-smoke-alarm/src/preferences.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local devices = {
FIBARO = {
Expand Down
11 changes: 11 additions & 0 deletions drivers/SmartThings/zwave-smoke-alarm/src/sub_drivers.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local lazy_load_if_possible = require "lazy_load_subdriver"
local sub_drivers = {
lazy_load_if_possible("zwave-smoke-co-alarm-v1"),
lazy_load_if_possible("zwave-smoke-co-alarm-v2"),
lazy_load_if_possible("fibaro-smoke-sensor"),
lazy_load_if_possible("apiv6_bugfix"),
}
return sub_drivers
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local test = require "integration_test"
local capabilities = require "st.capabilities"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local test = require "integration_test"
local capabilities = require "st.capabilities"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local test = require "integration_test"
local capabilities = require "st.capabilities"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local test = require "integration_test"
local capabilities = require "st.capabilities"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local test = require "integration_test"
local capabilities = require "st.capabilities"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local function can_handle_v1_alarm(opts, driver, device, cmd, ...)
-- The default handlers for the Alarm/Notification command class(es) for the
-- Smoke Detector and Carbon Monoxide Detector only handles V3 and up.
if opts.dispatcher_class == "ZwaveDispatcher" and cmd ~= nil and cmd.version ~= nil and cmd.version < 3 then
return true, require("zwave-smoke-co-alarm-v1")
end
return false
end

return can_handle_v1_alarm
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2022 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
--- @type st.zwave.CommandClass
Expand All @@ -23,17 +12,6 @@ local Alarm = (require "st.zwave.CommandClass.Alarm")({ version = 1 })
-- manufacturerId = 0x0138, productType = 0x0001, productId = 0x0002 -- First Alert Smoke & CO Detector
-- manufacturerId = 0x0138, productType = 0x0001, productId = 0x0003 -- First Alert Smoke & CO Detector

--- Determine whether the passed device only supports V1 or V2 of the Alarm command class
---
--- @param driver st.zwave.Driver
--- @param device st.zwave.Device
--- @return boolean true if the device is smoke co alarm
local function can_handle_v1_alarm(opts, driver, device, cmd, ...)
-- The default handlers for the Alarm/Notification command class(es) for the
-- Smoke Detector and Carbon Monoxide Detector only handles V3 and up.
return opts.dispatcher_class == "ZwaveDispatcher" and cmd ~= nil and cmd.version ~= nil and cmd.version < 3
end

--- Default handler for alarm command class reports
---
--- This converts alarm V1 reports to correct smoke events
Expand Down Expand Up @@ -75,7 +53,7 @@ local zwave_alarm = {
}
},
NAME = "Z-Wave smoke and CO alarm V1",
can_handle = can_handle_v1_alarm,
can_handle = require("zwave-smoke-co-alarm-v1.can_handle"),
}

return zwave_alarm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local function can_handle_v2_alarm(opts, driver, device, cmd, ...)
local FINGERPRINTS = require("zwave-smoke-co-alarm-v2.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:id_match( fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then
return true, require("zwave-smoke-co-alarm-v2")
end
end
return false
end

return can_handle_v2_alarm
Loading
Loading