diff --git a/drivers/SmartThings/zwave-switch/src/multi-metering-switch/init.lua b/drivers/SmartThings/zwave-switch/src/multi-metering-switch/init.lua index b3ce54b5da..efe7d35893 100644 --- a/drivers/SmartThings/zwave-switch/src/multi-metering-switch/init.lua +++ b/drivers/SmartThings/zwave-switch/src/multi-metering-switch/init.lua @@ -122,6 +122,20 @@ local function do_refresh(driver, device, command) -- should be deleted when v46 end end +-- Do not use native handlers due to unique component to endpoint mapping +local function switch_on_handler(driver, device, cmd) + switchDefaults.capability_handlers[capabilities.switch.commands.on](driver, device, cmd, false) +end + +local function switch_off_handler(driver, device, cmd) + switchDefaults.capability_handlers[capabilities.switch.commands.off](driver, device, cmd, false) +end + +local function set_level_handler(driver, device, cmd) + local defaults = require "st.zwave.defaults.switchLevel" + defaults.capability_handlers[capabilities.switchLevel.commands.setLevel](driver, device, cmd, false) +end + local function meter_report_handler(driver, device, cmd) -- We got a meter report from the root node, so refresh all children -- endpoint 0 should have its reports dropped @@ -161,7 +175,14 @@ local multi_metering_switch = { }, [capabilities.energyMeter.ID] = { [capabilities.energyMeter.commands.resetEnergyMeter.NAME] = reset - } + }, + [capabilities.switch.ID] = { + [capabilities.switch.commands.on.NAME] = switch_on_handler, + [capabilities.switch.commands.off.NAME] = switch_off_handler, + }, + [capabilities.switchLevel.ID] = { + [capabilities.switchLevel.commands.setLevel.NAME] = set_level_handler, + }, }, zwave_handlers = { [cc.METER] = { diff --git a/drivers/SmartThings/zwave-switch/src/test/test_multi_metering_switch.lua b/drivers/SmartThings/zwave-switch/src/test/test_multi_metering_switch.lua index 6b01e40baa..9373383093 100644 --- a/drivers/SmartThings/zwave-switch/src/test/test_multi_metering_switch.lua +++ b/drivers/SmartThings/zwave-switch/src/test/test_multi_metering_switch.lua @@ -237,14 +237,6 @@ test.register_message_test( { capability = "switch", command = "on", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_parent_device.id, capability_id = "switch", capability_cmd_id = "on" } - } - }, { channel = "zwave", direction = "send", @@ -270,14 +262,6 @@ test.register_message_test( { capability = "switch", command = "on", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_child_device.id, capability_id = "switch", capability_cmd_id = "on" } - } - }, { channel = "zwave", direction = "send", @@ -303,14 +287,6 @@ test.register_message_test( { capability = "switch", command = "off", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_parent_device.id, capability_id = "switch", capability_cmd_id = "off" } - } - }, { channel = "zwave", direction = "send", @@ -336,14 +312,6 @@ test.register_message_test( { capability = "switch", command = "off", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_child_device.id, capability_id = "switch", capability_cmd_id = "off" } - } - }, { channel = "zwave", direction = "send", @@ -606,7 +574,6 @@ test.register_coroutine_test( mock_parent_device.id, { capability = "switch", command = "off", component = "main", args = {} } }) - mock_parent_device:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( mock_parent_device, @@ -637,7 +604,6 @@ test.register_coroutine_test( mock_child_device.id, { capability = "switch", command = "off", component = "main", args = {} } }) - mock_child_device:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( mock_parent_device, diff --git a/drivers/SmartThings/zwave-switch/src/test/test_shelly_multi_metering_switch.lua b/drivers/SmartThings/zwave-switch/src/test/test_shelly_multi_metering_switch.lua index f26f1e2d33..b5606f6ab9 100644 --- a/drivers/SmartThings/zwave-switch/src/test/test_shelly_multi_metering_switch.lua +++ b/drivers/SmartThings/zwave-switch/src/test/test_shelly_multi_metering_switch.lua @@ -236,14 +236,6 @@ test.register_message_test( { capability = "switch", command = "on", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_parent_device.id, capability_id = "switch", capability_cmd_id = "on" } - } - }, { channel = "zwave", direction = "send", @@ -269,14 +261,6 @@ test.register_message_test( { capability = "switch", command = "on", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_child_device.id, capability_id = "switch", capability_cmd_id = "on" } - } - }, { channel = "zwave", direction = "send", @@ -302,14 +286,6 @@ test.register_message_test( { capability = "switch", command = "off", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_parent_device.id, capability_id = "switch", capability_cmd_id = "off" } - } - }, { channel = "zwave", direction = "send", @@ -335,14 +311,6 @@ test.register_message_test( { capability = "switch", command = "off", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_child_device.id, capability_id = "switch", capability_cmd_id = "off" } - } - }, { channel = "zwave", direction = "send", @@ -559,7 +527,6 @@ test.register_coroutine_test( mock_parent_device.id, { capability = "switch", command = "off", component = "main", args = {} } }) - mock_parent_device:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( mock_parent_device, @@ -590,7 +557,6 @@ test.register_coroutine_test( mock_child_device.id, { capability = "switch", command = "off", component = "main", args = {} } }) - mock_child_device:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( mock_parent_device, diff --git a/drivers/SmartThings/zwave-switch/src/test/test_wyfy_touch.lua b/drivers/SmartThings/zwave-switch/src/test/test_wyfy_touch.lua index a9aa7900e1..cc34fe0737 100644 --- a/drivers/SmartThings/zwave-switch/src/test/test_wyfy_touch.lua +++ b/drivers/SmartThings/zwave-switch/src/test/test_wyfy_touch.lua @@ -94,14 +94,6 @@ test.register_message_test( { capability = "switch", command = "on", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_parent_device.id, capability_id = "switch", capability_cmd_id = "on" } - } - }, { channel = "zwave", direction = "send", @@ -127,14 +119,6 @@ test.register_message_test( { capability = "switch", command = "on", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_child_device.id, capability_id = "switch", capability_cmd_id = "on" } - } - }, { channel = "zwave", direction = "send", @@ -160,14 +144,6 @@ test.register_message_test( { capability = "switch", command = "off", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_parent_device.id, capability_id = "switch", capability_cmd_id = "off" } - } - }, { channel = "zwave", direction = "send", @@ -193,14 +169,6 @@ test.register_message_test( { capability = "switch", command = "off", component = "main", args = {} } } }, - { - channel = "devices", - direction = "send", - message = { - "register_native_capability_cmd_handler", - { device_uuid = mock_child_device.id, capability_id = "switch", capability_cmd_id = "off" } - } - }, { channel = "zwave", direction = "send", @@ -283,7 +251,6 @@ test.register_coroutine_test( mock_parent_device.id, { capability = "switch", command = "off", component = "main", args = {} } }) - mock_parent_device:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( @@ -315,7 +282,6 @@ test.register_coroutine_test( mock_child_device.id, { capability = "switch", command = "off", component = "main", args = {} } }) - mock_child_device:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( mock_parent_device, diff --git a/drivers/SmartThings/zwave-switch/src/test/test_zwave_dual_switch.lua b/drivers/SmartThings/zwave-switch/src/test/test_zwave_dual_switch.lua index 59c7c8ccb8..4b69b063a7 100644 --- a/drivers/SmartThings/zwave-switch/src/test/test_zwave_dual_switch.lua +++ b/drivers/SmartThings/zwave-switch/src/test/test_zwave_dual_switch.lua @@ -467,7 +467,6 @@ test.register_coroutine_test( mock_parent.id, { capability = "switch", component = "main", command = "on", args = {} } }) - mock_parent:expect_native_cmd_handler_registration("switch", "on") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( @@ -505,7 +504,6 @@ test.register_coroutine_test( mock_child.id, { capability = "switch", component = "main", command = "on", args = {} } }) - mock_child:expect_native_cmd_handler_registration("switch", "on") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( @@ -543,7 +541,6 @@ test.register_coroutine_test( mock_parent.id, { capability = "switch", component = "main", command = "off", args = {} } }) - mock_parent:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( @@ -581,7 +578,6 @@ test.register_coroutine_test( mock_child.id, { capability = "switch", component = "main", command = "off", args = {} } }) - mock_child:expect_native_cmd_handler_registration("switch", "off") test.socket.zwave:__expect_send( zw_test_utils.zwave_test_build_send_command( diff --git a/drivers/SmartThings/zwave-switch/src/zwave-dual-switch/init.lua b/drivers/SmartThings/zwave-switch/src/zwave-dual-switch/init.lua index 3ec8868bcd..60bf54e4e0 100644 --- a/drivers/SmartThings/zwave-switch/src/zwave-dual-switch/init.lua +++ b/drivers/SmartThings/zwave-switch/src/zwave-dual-switch/init.lua @@ -117,6 +117,20 @@ local function do_refresh(driver, device, command) end end +-- Do not use native handlers due to unique component to endpoint mapping +local function switch_on_handler(driver, device, cmd) + switch_defaults.capability_handlers[capabilities.switch.commands.on](driver, device, cmd, false) +end + +local function switch_off_handler(driver, device, cmd) + switch_defaults.capability_handlers[capabilities.switch.commands.off](driver, device, cmd, false) +end + +local function set_level_handler(driver, device, cmd) + local defaults = require "st.zwave.defaults.switchLevel" + defaults.capability_handlers[capabilities.switchLevel.commands.setLevel](driver, device, cmd, false) +end + local function switch_report(driver, device, cmd) switch_defaults.zwave_handlers[cc.SWITCH_BINARY][SwitchBinary.REPORT](driver, device, cmd) @@ -139,7 +153,14 @@ local zwave_dual_switch = { capability_handlers = { [capabilities.refresh.ID] = { [capabilities.refresh.commands.refresh.NAME] = do_refresh - } + }, + [capabilities.switch.ID] = { + [capabilities.switch.commands.on.NAME] = switch_on_handler, + [capabilities.switch.commands.off.NAME] = switch_off_handler, + }, + [capabilities.switchLevel.ID] = { + [capabilities.switchLevel.commands.setLevel.NAME] = set_level_handler, + }, }, lifecycle_handlers = { added = device_added,