From 512906026133fa8e8f14082b1312f01612da86a3 Mon Sep 17 00:00:00 2001 From: seojune Date: Mon, 18 Sep 2023 09:19:07 +0900 Subject: [PATCH 1/3] fix routine condition error on child button of light switch --- .../zigbee-switch/src/aqara/multi-switch/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua b/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua index b3193d2b7e..8db1c3b305 100644 --- a/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua @@ -81,6 +81,12 @@ local function device_added(driver, device) device:send(cluster_base.write_manufacturer_specific_attribute(device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, data_types.Uint8, 0x01)) -- private + elseif device.network_type == "DEVICE_EDGE_CHILD" then + device:emit_event(capabilities.button.supportedButtonValues({ "pushed" }, + { visibility = { displayed = false } })) + device:emit_event(capabilities.button.numberOfButtons({ value = 1 }, + { visibility = { displayed = false } })) + device:emit_event(capabilities.button.button.pushed({ state_change = false })) end end From 696537811981c1616e4c21f070b3568e6d59ded0 Mon Sep 17 00:00:00 2001 From: seojune Date: Tue, 19 Sep 2023 09:54:36 +0900 Subject: [PATCH 2/3] fixed the codes(if block) --- .../src/aqara/multi-switch/init.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua b/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua index 8db1c3b305..40de476c0e 100644 --- a/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/init.lua @@ -8,9 +8,9 @@ local PRIVATE_ATTRIBUTE_ID = 0x0009 local MFG_CODE = 0x115F local FINGERPRINTS = { - { mfr = "LUMI", model = "lumi.switch.n1acn1", children = 1, child_profile = "" }, - { mfr = "LUMI", model = "lumi.switch.n2acn1", children = 2, child_profile = "aqara-switch-child" }, - { mfr = "LUMI", model = "lumi.switch.n3acn1", children = 3, child_profile = "aqara-switch-child" }, + { mfr = "LUMI", model = "lumi.switch.n1acn1", children = 1, child_profile = "" }, + { mfr = "LUMI", model = "lumi.switch.n2acn1", children = 2, child_profile = "aqara-switch-child" }, + { mfr = "LUMI", model = "lumi.switch.n3acn1", children = 3, child_profile = "aqara-switch-child" }, { mfr = "LUMI", model = "lumi.switch.b2laus01", children = 2, child_profile = "aqara-switch-child" } } @@ -70,24 +70,20 @@ local function device_added(driver, device) end -- for wireless button - device:emit_event(capabilities.button.supportedButtonValues({ "pushed" }, - { visibility = { displayed = false } })) device:emit_event(capabilities.button.numberOfButtons({ value = children_amount }, { visibility = { displayed = false } })) - device:emit_event(capabilities.button.button.pushed({ state_change = false })) - device:emit_event(capabilities.powerMeter.power({ value = 0.0, unit = "W" })) device:emit_event(capabilities.energyMeter.energy({ value = 0.0, unit = "Wh" })) device:send(cluster_base.write_manufacturer_specific_attribute(device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, data_types.Uint8, 0x01)) -- private elseif device.network_type == "DEVICE_EDGE_CHILD" then - device:emit_event(capabilities.button.supportedButtonValues({ "pushed" }, - { visibility = { displayed = false } })) device:emit_event(capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = false } })) - device:emit_event(capabilities.button.button.pushed({ state_change = false })) end + device:emit_event(capabilities.button.supportedButtonValues({ "pushed" }, + { visibility = { displayed = false } })) + device:emit_event(capabilities.button.button.pushed({ state_change = false })) end local function device_init(self, device) From 3a268b38c504360614c0c4585e9718f08ecfc01f Mon Sep 17 00:00:00 2001 From: seojune Date: Wed, 1 Nov 2023 15:46:32 +0900 Subject: [PATCH 3/3] Add TC for H1 switch --- .../src/test/test_aqara_switch_power.lua | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_aqara_switch_power.lua b/drivers/SmartThings/zigbee-switch/src/test/test_aqara_switch_power.lua index 8b01b3cefc..d206ac8c29 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_aqara_switch_power.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_aqara_switch_power.lua @@ -25,6 +25,7 @@ local OnOff = clusters.OnOff local AnalogInput = clusters.AnalogInput local PRIVATE_CLUSTER_ID = 0xFCC0 +local PRIVATE_ATTRIBUTE_ID = 0x0009 local MFG_CODE = 0x115F local RESTORE_POWER_STATE_ATTRIBUTE_ID = 0x0201 local CHANGE_TO_WIRELESS_SWITCH_ATTRIBUTE_ID = 0x0200 @@ -61,15 +62,55 @@ local mock_child = test.mock_device.build_test_child_device({ parent_assigned_child_key = string.format("%02X", 2) }) +local mock_child2 = test.mock_device.build_test_child_device({ + profile = t_utils.get_profile_definition("aqara-switch-child.yml"), + device_network_id = string.format("%04X:%02X", mock_device:get_short_address(), 3), + parent_device_id = mock_device.id, + parent_assigned_child_key = string.format("%02X", 3) +}) + zigbee_test_utils.prepare_zigbee_env_info() local function test_init() test.mock_device.add_test_device(mock_device) test.mock_device.add_test_device(mock_child) + test.mock_device.add_test_device(mock_child2) end test.set_test_init_function(test_init) +test.register_coroutine_test( + "Lifecycle - added test", + function() + test.socket.zigbee:__set_channel_ordering("relaxed") + test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" }) + test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.button.numberOfButtons({ value = 3 }, + { visibility = { displayed = false } }))) + test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.powerMeter.power({ value = 0.0, unit = "W" }))) + test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.energyMeter.energy({ value = 0.0, unit = "Wh" }))) + test.socket.zigbee:__expect_send({ mock_device.id, + cluster_base.write_manufacturer_specific_attribute(mock_device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, + data_types.Uint8, 1) }) + test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.button.supportedButtonValues({ "pushed" }, + { visibility = { displayed = false } }))) + test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.button.button.pushed({ state_change = false }))) + + end +) + +test.register_coroutine_test( + "Lifecycle - added test", + function() + test.socket.zigbee:__set_channel_ordering("relaxed") + test.socket.device_lifecycle:__queue_receive({ mock_child.id, "added" }) + test.socket.capability:__expect_send(mock_child:generate_test_message("main", capabilities.button.numberOfButtons({ value = 1 }, + { visibility = { displayed = false } }))) + test.socket.capability:__expect_send(mock_child:generate_test_message("main", capabilities.button.supportedButtonValues({ "pushed" }, + { visibility = { displayed = false } }))) + test.socket.capability:__expect_send(mock_child:generate_test_message("main", capabilities.button.button.pushed({ state_change = false }))) + end +) + test.register_coroutine_test( "Refresh device should read all necessary attributes", function()