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
14 changes: 9 additions & 5 deletions drivers/SmartThings/zigbee-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ local SimpleMetering = clusters.SimpleMetering
local ElectricalMeasurement = clusters.ElectricalMeasurement
local preferences = require "preferences"
local device_lib = require "st.device"
local version = require "version"
local constants = require "st.zigbee.constants"

local function lazy_load_if_possible(sub_driver_name)
-- gets the current lua libs api version
local version = require "version"

-- version 9 will include the lazy loading functions
if version.api >= 9 then
return ZigbeeDriver.lazy_load_sub_driver(require(sub_driver_name))
Expand All @@ -41,7 +40,9 @@ local function info_changed(self, device, event, args)
end

local do_configure = function(self, device)
device:refresh()
if version.api > 15 and device:get_profile_id() ~= constants.ZLL_PROFILE_ID then
device:refresh()
end
device:configure()

-- Additional one time configuration
Expand Down Expand Up @@ -126,6 +127,9 @@ local function device_added(driver, device, event)
end
end
end
if version.api > 15 and device:get_profile_id() == constants.ZLL_PROFILE_ID then
device:refresh()
end
end


Expand Down Expand Up @@ -157,7 +161,7 @@ local zigbee_switch_driver_template = {
lazy_load_if_possible("zigbee-dimming-light"),
lazy_load_if_possible("white-color-temp-bulb"),
lazy_load_if_possible("rgbw-bulb"),
lazy_load_if_possible("zll-dimmer-bulb"),
(version.api < 16) and lazy_load_if_possible("zll-dimmer-bulb") or require("zll-dimmer-bulb/ikea-xy-color-bulb"),
lazy_load_if_possible("zll-polling"),
lazy_load_if_possible("zigbee-switch-power"),
lazy_load_if_possible("ge-link-bulb"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local test = require "integration_test"
local capabilities = require "st.capabilities"
local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local version = require "version"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"

local OnOff = clusters.OnOff
Expand All @@ -31,7 +32,8 @@ local mock_device = test.mock_device.build_test_zigbee_device(
id = 1,
manufacturer = "sengled",
model = "E13-N11",
server_clusters = { 0x0006, 0x0008, 0x0500 }
server_clusters = { 0x0006, 0x0008, 0x0500 },
profile_id = 0xC05E
}
}
}
Expand Down Expand Up @@ -116,6 +118,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "on", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "on") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

Expand All @@ -134,6 +137,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "off", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "off") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.Off(mock_device) })

Expand All @@ -152,6 +156,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switchLevel", component = "main", command = "setLevel", args = { 57 } } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switchLevel", "setLevel") end

test.socket.zigbee:__expect_send({ mock_device.id, Level.server.commands.MoveToLevelWithOnOff(mock_device, 144, 0xFFFF) })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
local test = require "integration_test"
local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local version = require "version"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"

local OnOff = clusters.OnOff
Expand Down Expand Up @@ -83,6 +84,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "on", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "on") end
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device)})
test.wait_for_events()
test.mock_time.advance_time(2)
Expand All @@ -98,6 +100,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "off", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "off") end
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.Off(mock_device)})
test.wait_for_events()
test.mock_time.advance_time(2)
Expand All @@ -113,6 +116,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switchLevel", component = "main", command = "setLevel", args = {50} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switchLevel", "setLevel") end
test.socket.zigbee:__expect_send({ mock_device.id, Level.commands.MoveToLevelWithOnOff(mock_device, math.floor(50 / 100.0 * 254), 0xFFFF)})
test.wait_for_events()
test.mock_time.advance_time(2)
Expand All @@ -128,6 +132,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "colorTemperature", component = "main", command = "setColorTemperature", args = {200} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("colorTemperature", "setColorTemperature") end
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device)})
test.socket.zigbee:__expect_send({ mock_device.id, ColorControl.commands.MoveToColorTemperature(mock_device, 5000, 0x0000)})
test.wait_for_events()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
local test = require "integration_test"
local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local version = require "version"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"

local OnOff = clusters.OnOff
Expand Down Expand Up @@ -121,6 +122,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "on", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "on") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

Expand All @@ -138,6 +140,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "off", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "off") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.Off(mock_device) })

Expand All @@ -155,6 +158,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switchLevel", component = "main", command = "setLevel", args = { 57 } } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switchLevel", "setLevel") end

test.socket.zigbee:__expect_send({ mock_device.id, Level.server.commands.MoveToLevelWithOnOff(mock_device, 144, 0xFFFF) })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local test = require "integration_test"
local capabilities = require "st.capabilities"
local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local version = require "version"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"

local OnOff = clusters.OnOff
Expand Down Expand Up @@ -149,6 +150,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "on", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "on") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

Expand All @@ -168,6 +170,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "off", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "off") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.Off(mock_device) })

Expand All @@ -187,6 +190,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switchLevel", component = "main", command = "setLevel", args = { 57 } } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switchLevel", "setLevel") end

test.socket.zigbee:__expect_send({ mock_device.id, Level.server.commands.MoveToLevelWithOnOff(mock_device, 144, 0xFFFF) })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
local test = require "integration_test"
local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local version = require "version"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"

local OnOff = clusters.OnOff
Expand Down Expand Up @@ -140,6 +141,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "on", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "on") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

Expand All @@ -160,6 +162,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switch", component = "main", command = "off", args = {} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switch", "off") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.Off(mock_device) })

Expand All @@ -180,6 +183,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "switchLevel", component = "main", command = "setLevel", args = { 57 } } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("switchLevel", "setLevel") end

test.socket.zigbee:__expect_send({ mock_device.id, Level.server.commands.MoveToLevelWithOnOff(mock_device, 144, 0xFFFF) })

Expand All @@ -200,6 +204,7 @@ test.register_coroutine_test(
test.socket.zigbee:__set_channel_ordering("relaxed")
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = "colorTemperature", component = "main", command = "setColorTemperature", args = {200} } })
if version.api > 15 then mock_device:expect_native_cmd_handler_registration("colorTemperature", "setColorTemperature") end

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device)})
test.socket.zigbee:__expect_send({ mock_device.id, ColorControl.commands.MoveToColorTemperature(mock_device, 5000, 0x0000)})
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local clusters = require "st.zigbee.zcl.clusters"

local function zll_profile(opts, driver, device, zb_rx, ...)
local endpoint = device.zigbee_endpoints[device.fingerprinted_endpoint_id] or device.zigbee_endpoints[tostring(device.fingerprinted_endpoint_id)]
if (endpoint ~= nil and endpoint.profile_id == constants.ZLL_PROFILE_ID) then
if (endpoint ~= nil and endpoint.profile_id == constants.ZLL_PROFILE_ID) and (device:get_model() ~= "E13-N11") then
local subdriver = require("zll-polling")
return true, subdriver
else
Expand Down
Loading