Skip to content
Draft
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 @@ -13,6 +13,9 @@ local OPTIONS_MASK = 0x01 -- default: The `ExecuteIfOff` option is overriden
local IGNORE_COMMAND_IF_OFF = 0x00 -- default: the command will not be executed if the device is off

local function step_color_temperature_by_percent_handler(driver, device, cmd)
if type(device.register_native_capability_cmd_handler) == "function" then
device:register_native_capability_cmd_handler(cmd.capability, cmd.command)
end
local step_percent_change = cmd.args and cmd.args.stepSize or 0
if step_percent_change == 0 then return end
local step_mode = step_percent_change > 0 and clusters.ColorControl.types.CcStepMode.DOWN or clusters.ColorControl.types.CcStepMode.UP
Expand Down Expand Up @@ -42,6 +45,9 @@ local function step_color_temperature_by_percent_handler(driver, device, cmd)
end

local function step_level_handler(driver, device, cmd)
if type(device.register_native_capability_cmd_handler) == "function" then
device:register_native_capability_cmd_handler(cmd.capability, cmd.command)
end
local step_size = st_utils.round((cmd.args and cmd.args.stepSize or 0)/100.0 * 254)
if step_size == 0 then return end
local step_mode = step_size > 0 and clusters.Level.types.MoveStepMode.UP or clusters.Level.types.MoveStepMode.DOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ test.register_message_test(
{ capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { 20 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessColorTemperatureStep", capability_cmd_id = "stepColorTemperatureByPercent" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -324,6 +332,14 @@ test.register_message_test(
{ capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { 90 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessColorTemperatureStep", capability_cmd_id = "stepColorTemperatureByPercent" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -340,6 +356,14 @@ test.register_message_test(
{ capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { -50 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessColorTemperatureStep", capability_cmd_id = "stepColorTemperatureByPercent" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -362,6 +386,14 @@ test.register_message_test(
{ capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { 25 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessSwitchLevelStep", capability_cmd_id = "stepLevel" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -378,6 +410,14 @@ test.register_message_test(
{ capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { -50 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessSwitchLevelStep", capability_cmd_id = "stepLevel" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -394,6 +434,14 @@ test.register_message_test(
{ capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { 100 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessSwitchLevelStep", capability_cmd_id = "stepLevel" }
}
},
{
channel = "zigbee",
direction = "send",
Expand Down
48 changes: 48 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/test/test_rgbw_bulb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ test.register_message_test(
{ capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { 25 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessSwitchLevelStep", capability_cmd_id = "stepLevel" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -177,6 +185,14 @@ test.register_message_test(
{ capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { -50 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessSwitchLevelStep", capability_cmd_id = "stepLevel" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -193,6 +209,14 @@ test.register_message_test(
{ capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { 100 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessSwitchLevelStep", capability_cmd_id = "stepLevel" }
}
},
{
channel = "zigbee",
direction = "send",
Expand Down Expand Up @@ -324,6 +348,14 @@ test.register_message_test(
{ capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { 20 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessColorTemperatureStep", capability_cmd_id = "stepColorTemperatureByPercent" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -340,6 +372,14 @@ test.register_message_test(
{ capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { 90 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessColorTemperatureStep", capability_cmd_id = "stepColorTemperatureByPercent" }
}
},
{
channel = "zigbee",
direction = "send",
Expand All @@ -356,6 +396,14 @@ test.register_message_test(
{ capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { -50 } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "statelessColorTemperatureStep", capability_cmd_id = "stepColorTemperatureByPercent" }
}
},
{
channel = "zigbee",
direction = "send",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ test.register_coroutine_test(
function()
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "statelessColorTemperatureStep", component = "main", command = "stepColorTemperatureByPercent", args = { 20 } } })
mock_device:expect_native_cmd_handler_registration("statelessColorTemperatureStep", "stepColorTemperatureByPercent")

test.socket.zigbee:__expect_send(
{
Expand All @@ -173,6 +174,7 @@ test.register_coroutine_test(
function()
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "statelessSwitchLevelStep", component = "main", command = "stepLevel", args = { 25 } } })
mock_device:expect_native_cmd_handler_registration("statelessSwitchLevelStep", "stepLevel")

test.socket.zigbee:__expect_send(
{
Expand Down
Loading