Skip to content

Commit

Permalink
Merge pull request #1567 from SmartThingsCommunity/feature/enable-nat…
Browse files Browse the repository at this point in the history
…ive-handlers

Enable native handlers for drivers that can use them
  • Loading branch information
cjswedes authored Aug 12, 2024
2 parents 0b92605 + 8cb2981 commit 4774ab8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions drivers/SmartThings/matter-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,28 @@ local function device_removed(driver, device)
end

local function handle_switch_on(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 endpoint_id = device:component_to_endpoint(cmd.component)
--TODO use OnWithRecallGlobalScene for devices with the LT feature
local req = clusters.OnOff.server.commands.On(device, endpoint_id)
device:send(req)
end

local function handle_switch_off(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 endpoint_id = device:component_to_endpoint(cmd.component)
local req = clusters.OnOff.server.commands.Off(device, endpoint_id)
device:send(req)
end

local function handle_set_level(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 endpoint_id = device:component_to_endpoint(cmd.component)
local level = math.floor(cmd.args.level/100.0 * 254)
local req = clusters.LevelControl.server.commands.MoveToLevelWithOnOff(device, endpoint_id, level, cmd.args.rate or 0, 0 ,0)
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/zigbee-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ local zigbee_switch_driver_template = {
}

defaults.register_for_default_handlers(zigbee_switch_driver_template,
zigbee_switch_driver_template.supported_capabilities)
zigbee_switch_driver_template.supported_capabilities, {native_capability_cmds_enabled = true})
local zigbee_switch = ZigbeeDriver("zigbee_switch", zigbee_switch_driver_template)
zigbee_switch:run()
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-bulb/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local driver_template = {
},
}

defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities)
defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities, {native_capability_cmds_enabled = true})
--- @type st.zwave.Driver
local bulb = ZwaveDriver("zwave_bulb", driver_template)
bulb:run()
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ local driver_template = {
}
}

defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities)
defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities, {native_capability_cmds_enabled = true})
--- @type st.zwave.Driver
local switch = ZwaveDriver("zwave_switch", driver_template)
switch:run()

0 comments on commit 4774ab8

Please sign in to comment.