Skip to content

Commit

Permalink
aeotec-pico-generic: unnecessary log entry removed, unused ep variabl…
Browse files Browse the repository at this point in the history
…e corrected, fixed broken test

aeotec-pico-switch: fixed broken test
  • Loading branch information
ronie-z-wave committed Nov 9, 2023
1 parent ca0f218 commit 38e3919
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 1 addition & 3 deletions drivers/SmartThings/zigbee-switch/src/aeotec-pico/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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({
Expand All @@ -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 },
Expand All @@ -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",
Expand All @@ -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 }))
}
}
Expand Down

0 comments on commit 38e3919

Please sign in to comment.