Skip to content
Merged
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,13 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local is_aqara_products = function(opts, driver, device, ...)
local FINGERPRINTS = { mfr = "aqara", model = "lumi.motion.ac01" }

if device:get_manufacturer() == FINGERPRINTS.mfr and device:get_model() == FINGERPRINTS.model then
return true, require("aqara")
end
return false
end

return is_aqara_products
11 changes: 4 additions & 7 deletions drivers/SmartThings/zigbee-presence-sensor/src/aqara/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
local cluster_base = require "st.zigbee.cluster_base"
local data_types = require "st.zigbee.data_types"
Expand All @@ -19,12 +22,6 @@ local SENSITIVITY = "stse.sensitivity"
local RESET_PRESENCE = "stse.resetPresence"
local APP_DISTANCE = "stse.approachDistance"

local FINGERPRINTS = { mfr = "aqara", model = "lumi.motion.ac01" }

local is_aqara_products = function(opts, driver, device, ...)
return device:get_manufacturer() == FINGERPRINTS.mfr and device:get_model() == FINGERPRINTS.model
end

local function device_init(driver, device)
-- no action
end
Expand Down Expand Up @@ -104,7 +101,7 @@ local aqara_fp1_handler = {
doConfigure = do_configure,
infoChanged = device_info_changed
},
can_handle = is_aqara_products
can_handle = require("aqara.can_handle"),
}

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

local function arrival_sensor_v1_can_handle(opts, driver, device, ...)
-- excluding Aqara device and tagv4
if device:get_manufacturer() ~= "aqara" and device:get_model() ~= "tagv4" then
return true, require("arrival-sensor-v1")
end
return false
end

return arrival_sensor_v1_can_handle
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


-- Zigbee Spec Utils
local zcl_messages = require "st.zigbee.zcl"
Expand Down Expand Up @@ -41,10 +31,6 @@ local presence_utils = require "presence_utils"

local CHECKIN_INTERVAL = 20 -- seconds

local function arrival_sensor_v1_can_handle(opts, driver, device, ...)
-- excluding Aqara device and tagv4
return device:get_manufacturer() ~= "aqara" and device:get_model() ~= "tagv4"
end

local function legacy_battery_handler(self, device, zb_rx)
local battery_value = string.byte(zb_rx.body.zcl_body.body_bytes)
Expand Down Expand Up @@ -144,7 +130,7 @@ local arrival_sensor_v1 = {
added = added_handler,
init = init_handler
},
can_handle = arrival_sensor_v1_can_handle
can_handle = require("arrival-sensor-v1.can_handle"),
}

return arrival_sensor_v1
21 changes: 4 additions & 17 deletions drivers/SmartThings/zigbee-presence-sensor/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 ZigbeeDriver = require "st.zigbee"
local defaults = require "st.zigbee.defaults"
Expand Down Expand Up @@ -204,10 +194,7 @@ local zigbee_presence_driver = {
},
-- Custom handler for every Zigbee message
zigbee_message_handler = all_zigbee_message_handler,
sub_drivers = {
require("aqara"),
require("arrival-sensor-v1")
},
sub_drivers = require("sub_drivers"),
health_check = false,
}

Expand Down
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
15 changes: 2 additions & 13 deletions drivers/SmartThings/zigbee-presence-sensor/src/presence_utils.lua
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 presence_utils = {}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- 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("aqara"),
lazy_load_if_possible("arrival-sensor-v1"),
}
return sub_drivers
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

-- Mock out globals
local test = require "integration_test"
Expand Down
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

-- Mock out globals
local test = require "integration_test"
Expand Down
Loading