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
1 change: 1 addition & 0 deletions drivers/SmartThings/zigbee-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ local zigbee_switch_driver_template = {
capabilities.motionSensor
},
sub_drivers = {
lazy_load_if_possible("non_zigbee_devices"),
lazy_load_if_possible("hanssem"),
lazy_load_if_possible("aqara"),
lazy_load_if_possible("aqara-light"),
Expand Down
57 changes: 57 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/non_zigbee_devices/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
-- Copyright 2025 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.

-- This is a patch for the zigbee-switch driver to fix https://smartthings.atlassian.net/browse/CHAD-16558
-- Several hubs were found that had zigbee switch drivers hosting zwave devices.
-- This patch works around it until hubcore 0.59 is released with
-- https://smartthings.atlassian.net/browse/CHAD-16552

local st_device = require "st.device"
local log = require "log"

local function can_handle(opts, driver, device)
if device.network_type ~= st_device.NETWORK_TYPE_ZIGBEE and device.network_type ~= st_device.NETWORK_TYPE_CHILD then
return true, require("non_zigbee_devices")
end
return false
end

local function device_added(driver, device, event)
log.info(string.format("Non zigbee device added: %s", device))
end

local function device_init(driver, device, event)
log.info(string.format("Non zigbee device init: %s", device))
end

local function do_configure(driver, device)
log.info(string.format("Non zigbee do configure: %s", device))
end

local function info_changed(driver, device, event, args)
log.info(string.format("Non zigbee infoChanged: %s", device))
end

local non_zigbee_devices = {
NAME = "non zigbee devices filter",
lifecycle_handlers = {
init = device_init,
added = device_added,
doConfigure = do_configure,
infoChanged = info_changed
},
can_handle = can_handle
}

return non_zigbee_devices
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
-- Copyright 2025 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.

local test = require "integration_test"
local t_utils = require "integration_test.utils"
local dkjson = require 'dkjson'

-- This test attempts to add a zwave device to this zigbee switch driver
-- Once the monkey-patch is removed with hubcore 59 is released with:
-- https://smartthings.atlassian.net/browse/CHAD-16552
local mock_device = test.mock_device.build_test_zwave_device({
profile = t_utils.get_profile_definition("on-off-level.yml"),
})

local function test_init()
test.mock_device.add_test_device(mock_device)
end

test.set_test_init_function(test_init)

-- Just validating that the driver doesn't crash is enough to validate
-- that the work-around is effective in ignoring the incorrect device kind
test.register_coroutine_test("zwave_device_handled", function()
test.mock_device.add_test_device(mock_device)
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })
test.wait_for_events()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "init" })
test.wait_for_events()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
mock_device:expect_metadata_update({provisioning_state = "PROVISIONED"})
test.wait_for_events()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "infoChanged", dkjson.encode(mock_device.raw_st_data) })
test.wait_for_events()
end,
nil
)

test.register_message_test(
"Capability command for incorrect protocol",
{
channel = "capability",
direction = "receive",
message = { mock_device.id, { capability = "switch", component = "main", command = "on", args = { } } }
}
)

test.run_registered_tests()
Loading