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
Expand Up @@ -35,7 +35,13 @@ local IKEA_XY_COLOR_BULB_FINGERPRINTS = {
}

local function can_handle_ikea_xy_color_bulb(opts, driver, device)
return (IKEA_XY_COLOR_BULB_FINGERPRINTS[device:get_manufacturer()] or {})[device:get_model()] or false
local can_handle = (IKEA_XY_COLOR_BULB_FINGERPRINTS[device:get_manufacturer()] or {})[device:get_model()]
if can_handle then
local subdriver = require("ikea-xy-color-bulb")
return true, subdriver
else
return false
end
end

local device_init = function(self, device)
Expand Down
4 changes: 2 additions & 2 deletions drivers/SmartThings/zigbee-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ end

local function lazy_load_if_possible(sub_driver_name)
-- gets the current lua libs api 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 Down Expand Up @@ -105,7 +104,8 @@ 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 nil,
lazy_load_if_possible("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 @@ -27,7 +27,9 @@ end

return function(driver, device, event)
local clusters = require "st.zigbee.zcl.clusters"
local ZLL_PROFILE_ID = 0xC05E
local device_lib = require "st.device"
local version = require "version"

local main_endpoint = device:get_endpoint(clusters.OnOff.ID)
if is_mcd_device(device) == false and device.network_type == device_lib.NETWORK_TYPE_ZIGBEE then
Expand All @@ -53,4 +55,7 @@ return function(driver, device, event)
end
end
end
if version.api > 15 and device:get_profile_id() == ZLL_PROFILE_ID then
device:refresh()
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

local capabilities = require "st.capabilities"
return function(self, device)
device:refresh()
local ZLL_PROFILE_ID = 0xC05E
local version = require "version"
if version.api < 16 or (version.api > 15 and device:get_profile_id() ~= ZLL_PROFILE_ID) then
device:refresh()
end
device:configure()

-- Additional one time configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ 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
local Level = clusters.Level
local IASZone = clusters.IASZone
local IasEnrollResponseCode = IASZone.types.EnrollResponseCode

local mock_device = test.mock_device.build_test_zigbee_device(
{ profile = t_utils.get_profile_definition("on-off-level-motion-sensor.yml"),
Expand All @@ -31,7 +31,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 @@ -76,14 +77,6 @@ test.register_coroutine_test(
mock_device.id,
IASZone.attributes.ZoneStatus:configure_reporting(mock_device, 30, 300, 1)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASZone.attributes.IASCIEAddress:write(mock_device, zigbee_test_utils.mock_hub_eui)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASZone.server.commands.ZoneEnrollResponse(mock_device, IasEnrollResponseCode.SUCCESS, 0x00)
})
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)
Expand Down Expand Up @@ -116,6 +109,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 +128,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 +147,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
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ local function can_handle_zigbee_dimming_light(opts, driver, device)
return false
end

local function do_configure(driver, device)
device:refresh()
device:configure()
end

local function device_init(driver, device)
for _,attribute in ipairs(DIMMING_LIGHT_CONFIGURATION) do
device:add_configured_attribute(attribute)
Expand All @@ -99,7 +104,8 @@ local zigbee_dimming_light = {
NAME = "Zigbee Dimming Light",
lifecycle_handlers = {
init = configurations.power_reconfig_wrapper(device_init),
added = device_added
added = device_added,
doConfigure = do_configure
},
sub_drivers = {
require("zigbee-dimming-light/osram-iqbr30"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ local zll_dimmer_bulb = {
[capabilities.colorTemperature.commands.setColorTemperature.NAME] = handle_set_color_temperature
}
},
sub_drivers = {
require("zll-dimmer-bulb/ikea-xy-color-bulb")
},
can_handle = can_handle_zll_dimmer_bulb
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
-- limitations under the License.

local device_lib = require "st.device"
local constants = require "st.zigbee.constants"
local clusters = require "st.zigbee.zcl.clusters"
local ZLL_PROFILE_ID = 0xC05E

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 == ZLL_PROFILE_ID) then
local subdriver = require("zll-polling")
return true, subdriver
else
Expand Down
Loading