diff --git a/drivers/SmartThings/zigbee-switch/src/init.lua b/drivers/SmartThings/zigbee-switch/src/init.lua index 15241cd004..2723204b9d 100644 --- a/drivers/SmartThings/zigbee-switch/src/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/init.lua @@ -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)) @@ -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 @@ -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 @@ -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"), diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_sengled_dimmer_bulb_with_motion_sensor.lua b/drivers/SmartThings/zigbee-switch/src/test/test_sengled_dimmer_bulb_with_motion_sensor.lua index 6051a9decd..b4e16e1963 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_sengled_dimmer_bulb_with_motion_sensor.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_sengled_dimmer_bulb_with_motion_sensor.lua @@ -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 @@ -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 } } } @@ -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) }) @@ -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) }) @@ -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) }) diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_zll_color_temp_bulb.lua b/drivers/SmartThings/zigbee-switch/src/test/test_zll_color_temp_bulb.lua index 6d7986700e..fc68ec7786 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_zll_color_temp_bulb.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_zll_color_temp_bulb.lua @@ -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 @@ -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) @@ -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) @@ -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) @@ -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() diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_zll_dimmer_bulb.lua b/drivers/SmartThings/zigbee-switch/src/test/test_zll_dimmer_bulb.lua index 922a0ce364..a82dac084a 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_zll_dimmer_bulb.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_zll_dimmer_bulb.lua @@ -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 @@ -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) }) @@ -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) }) @@ -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) }) diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgb_bulb.lua b/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgb_bulb.lua index b58acb6dc2..7bf6b175cd 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgb_bulb.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgb_bulb.lua @@ -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 @@ -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) }) @@ -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) }) @@ -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) }) diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgbw_bulb.lua b/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgbw_bulb.lua index 51edc21777..7945b8d030 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgbw_bulb.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_zll_rgbw_bulb.lua @@ -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 @@ -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) }) @@ -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) }) @@ -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) }) @@ -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)}) diff --git a/drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua b/drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua index d3ce34c2fd..560c97b13e 100644 --- a/drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua @@ -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