Skip to content

Commit

Permalink
fix Aqara LED Light Bult T1 reonboarding issue (#1308)
Browse files Browse the repository at this point in the history
reference:
  STSE-2616

Signed-off-by: zhoujie <[email protected]>
  • Loading branch information
zhoujie2022 authored Apr 26, 2024
1 parent eb147da commit a55e393
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
9 changes: 3 additions & 6 deletions drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ local function do_refresh(self, device)
end

local function do_configure(self, device)
device:send(ColorControl.commands.MoveToColorTemperature(device, 200, 0x0000))
device:configure()
do_refresh(self, device)
end

local function device_added(driver, device, event)
device:send(cluster_base.write_manufacturer_specific_attribute(device,
PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, data_types.Uint8, 1)) -- private

device:send(Level.attributes.OnTransitionTime:write(device, 0))
device:send(Level.attributes.OffTransitionTime:write(device, 0))
device:send(ColorControl.commands.MoveToColorTemperature(device, 200, 0x0000))

do_refresh(self, device)
end

local function set_level_handler(driver, device, cmd)
Expand All @@ -56,7 +54,6 @@ end
local aqara_light_handler = {
NAME = "Aqara Light Handler",
lifecycle_handlers = {
added = device_added,
doConfigure = do_configure
},
capability_handlers = {
Expand Down
14 changes: 3 additions & 11 deletions drivers/SmartThings/zigbee-switch/src/test/test_aqara_led_bulb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ end
test.set_test_init_function(test_init)

test.register_coroutine_test(
"Handle added lifecycle",
"Configure should configure all necessary attributes and refresh device",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__set_channel_ordering("relaxed")

test.socket.zigbee:__expect_send(
{
Expand All @@ -66,15 +67,6 @@ test.register_coroutine_test(
)
test.socket.zigbee:__expect_send({ mock_device.id, Level.attributes.OnTransitionTime:write(mock_device, 0) })
test.socket.zigbee:__expect_send({ mock_device.id, Level.attributes.OffTransitionTime:write(mock_device, 0) })
end
)

test.register_coroutine_test(
"Configure should configure all necessary attributes and refresh device",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__set_channel_ordering("relaxed")

test.socket.zigbee:__expect_send(
{
mock_device.id,
Expand Down
14 changes: 3 additions & 11 deletions drivers/SmartThings/zigbee-switch/src/test/test_aqara_light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ end
test.set_test_init_function(test_init)

test.register_coroutine_test(
"Handle added lifecycle",
"Configure should configure all necessary attributes and refresh device",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__set_channel_ordering("relaxed")

test.socket.zigbee:__expect_send(
{
Expand All @@ -67,15 +68,6 @@ test.register_coroutine_test(
)
test.socket.zigbee:__expect_send({ mock_device.id, Level.attributes.OnTransitionTime:write(mock_device, 0) })
test.socket.zigbee:__expect_send({ mock_device.id, Level.attributes.OffTransitionTime:write(mock_device, 0) })
end
)

test.register_coroutine_test(
"Configure should configure all necessary attributes and refresh device",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__set_channel_ordering("relaxed")

test.socket.zigbee:__expect_send(
{
mock_device.id,
Expand Down

0 comments on commit a55e393

Please sign in to comment.