diff --git a/drivers/SmartThings/zigbee-switch/src/aeotec-pico/init.lua b/drivers/SmartThings/zigbee-switch/src/aeotec-pico/init.lua index 21c54c564c..781a5afab4 100644 --- a/drivers/SmartThings/zigbee-switch/src/aeotec-pico/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/aeotec-pico/init.lua @@ -17,7 +17,6 @@ local clusters = require "st.zigbee.zcl.clusters" local capabilities = require "st.capabilities" local st_device = require "st.device" local utils = require "st.utils" -local log = require "log" -- Clusters local SimpleMetering = clusters.SimpleMetering @@ -182,7 +181,7 @@ local scenes_cluster_handler = function(driver, device, zb_rx) if device:get_model() == "ZGA002" then ep = zb_rx.address_header.src_endpoint.value == 0x03 and 0x08 or 0x07 else - ep = zb_rx.address_header.src_endpoint.value == 0x04 and 0x02 or 0x01 + ep = zb_rx.address_header.src_endpoint.value == 0x04 and 0x02 or ep end local button_event = SCENE_ID_BUTTON_EVENT_MAP[zb_rx.body.zcl_body.scene_id.value] @@ -222,7 +221,6 @@ local device_added = function(driver, device, event) end device.thread:call_with_delay(3, function() - log.debug(utils.stringify_table(device.profile.components.main.capabilities, 'capabilities', true)) if device.profile.components.main.capabilities["button"] ~= nil then device:emit_event( capabilities.button.supportedButtonValues({ "pushed", "double", "pushed_3x", "held", "up" }, diff --git a/drivers/SmartThings/zigbee-switch/src/test/test_aeotec-pico-switch.lua b/drivers/SmartThings/zigbee-switch/src/test/test_aeotec-pico-switch.lua index 0892ff6fdf..4c0ab7ae84 100644 --- a/drivers/SmartThings/zigbee-switch/src/test/test_aeotec-pico-switch.lua +++ b/drivers/SmartThings/zigbee-switch/src/test/test_aeotec-pico-switch.lua @@ -86,7 +86,7 @@ local PREFERENCE_TABLES = { local mock_device = test.mock_device.build_test_zigbee_device( { label = "Aeotec Pico Switch", - profile = t_utils.get_profile_definition("aeotec-pico-switch.yml"), + profile = t_utils.get_profile_definition("aeotec-pico-switch-two-button-control.yml"), zigbee_endpoints = { [1] = { id = 1, @@ -113,19 +113,7 @@ test.register_coroutine_test( 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.supportedButtonValues({ "pushed", "double", "pushed_3x", "held", "up" }, - { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "main", - capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = false } }) - ) - ) + mock_device:expect_metadata_update({ profile = "aeotec-pico-switch-two-button-control" }) -- do refresh test.socket.zigbee:__expect_send({ @@ -148,6 +136,7 @@ test.register_coroutine_test( end ) + local SCENE_ID_BUTTON_EVENT_MAP = { { state_name = "pushed", button_state = capabilities.button.button.pushed }, { state_name = "double", button_state = capabilities.button.button.double }, @@ -161,6 +150,19 @@ for i, button_event in ipairs(SCENE_ID_BUTTON_EVENT_MAP) do test.register_message_test( "Test Scene Control: Parent device - " .. button_event.state_name, { + { + channel = "zigbee", + direction = "receive", + message = { mock_device.id, + zigbee_test_utils.build_custom_command_id(mock_device, Scenes.ID, Scenes.server.commands.RecallScene.ID, 0x0000, + "\x00\x01" .. string.char(i) .. "\xFF\xFF", 0x02) } + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("button1", + button_event.button_state({ state_change = true })) + }, { channel = "zigbee", direction = "receive", @@ -171,7 +173,7 @@ for i, button_event in ipairs(SCENE_ID_BUTTON_EVENT_MAP) do { channel = "capability", direction = "send", - message = mock_device:generate_test_message("main", + message = mock_device:generate_test_message("button2", button_event.button_state({ state_change = true })) } }