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
15 changes: 2 additions & 13 deletions drivers/SmartThings/zigbee-fan/src/configurations.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
-- Copyright 2024 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 2024 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local clusters = require "st.zigbee.zcl.clusters"

Expand Down
14 changes: 14 additions & 0 deletions drivers/SmartThings/zigbee-fan/src/fan-light/can_handle.lua
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_itm_fanlight(opts, driver, device)
local FINGERPRINTS = require("fan-light.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
return true, require("fan-light")
end
end
return false
end

return can_handle_itm_fanlight
8 changes: 8 additions & 0 deletions drivers/SmartThings/zigbee-fan/src/fan-light/fingerprints.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local FINGERPRINTS = {
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-003" },
}

return FINGERPRINTS
31 changes: 4 additions & 27 deletions drivers/SmartThings/zigbee-fan/src/fan-light/init.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
-- Copyright 2024 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 2024 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local clusters = require "st.zigbee.zcl.clusters"
local capabilities = require "st.capabilities"
local FanControl = clusters.FanControl
local Level = clusters.Level
local OnOff = clusters.OnOff

local FINGERPRINTS = {
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-003" },
}

local function can_handle_itm_fanlight(opts, driver, device)
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
return true
end
end
return false
end

-- CAPABILITY HANDLERS

Expand Down Expand Up @@ -111,9 +90,7 @@ local itm_fan_light = {
[capabilities.fanSpeed.commands.setFanSpeed.NAME] = fan_speed_handler
}
},
can_handle = can_handle_itm_fanlight
can_handle = require("fan-light.can_handle"),
}

return itm_fan_light


21 changes: 4 additions & 17 deletions drivers/SmartThings/zigbee-fan/src/init.lua
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move the configurations into the function where it is used, since it is only used at startup. That way it gets gc'd

Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2024 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 2024 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local capabilities = require "st.capabilities"
local ZigbeeDriver = require "st.zigbee"
Expand All @@ -32,9 +22,7 @@ local zigbee_fan_driver = {
capabilities.switchLevel,
capabilities.fanspeed
},
sub_drivers = {
require("fan-light")
},
sub_drivers = require("sub_drivers"),
lifecycle_handlers = {
init = device_init
},
Expand All @@ -44,4 +32,3 @@ local zigbee_fan_driver = {
defaults.register_for_default_handlers(zigbee_fan_driver,zigbee_fan_driver.supported_capabilities)
local fan = ZigbeeDriver("zigbee-fan", zigbee_fan_driver)
fan:run()

15 changes: 15 additions & 0 deletions drivers/SmartThings/zigbee-fan/src/lazy_load_subdriver.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- 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 version = require "version"
local ZigbeeDriver = require "st.zigbee"
if version.api >= 16 then
return ZigbeeDriver.lazy_load_sub_driver_v2(sub_driver_name)
elseif version.api >= 9 then
return ZigbeeDriver.lazy_load_sub_driver(require(sub_driver_name))
else
return require(sub_driver_name)
end
end
8 changes: 8 additions & 0 deletions drivers/SmartThings/zigbee-fan/src/sub_drivers.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- 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("fan-light"),
}
return sub_drivers
16 changes: 3 additions & 13 deletions drivers/SmartThings/zigbee-fan/src/test/test_fan_light.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- Copyright 2024 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 2024 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local test = require "integration_test"
local t_utils = require "integration_test.utils"
local clusters = require "st.zigbee.zcl.clusters"
Expand Down
Loading