Skip to content
Open
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
6 changes: 6 additions & 0 deletions drivers/SmartThings/zwave-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,12 @@ zwaveManufacturer:
manufacturerId: 0x010F
productType: 0x0102
deviceProfileName: fibaro-dimmer-2
- id: Philio/PAD19
deviceLabel: PAD19
manufacturerId: 0x013C
productType: 0x0005
productId: 0x008A
deviceProfileName: philio-dimmer-switch
Comment on lines +919 to +924
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, I think this fingerprint is the only change you actually need to include.

#Shelly/Qubino
- id: 1120/2/137
deviceLabel: Wave Plug UK
Expand Down
16 changes: 16 additions & 0 deletions drivers/SmartThings/zwave-switch/profiles/philio-dimmer-switch.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a duplicate of the existing switch-level

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: philio-dimmer-switch
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
config:
values:
- key: "level.value"
range: [0, 99]
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This distinction is not worthwhile and would be confusing to users with other devices installed on the system.

Your integration would be easier and you would be better served if you simply turned this PR into a fingerprint addition.

None of your code does anything beyond what our defaults already do in a materially different way other than this needless distinction of 0-99 instead of 1-100.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Steven :

I’m hoping to implement the following behavior for this device:

When the switch is toggled:

Turning ON should restore the light to its previous level (or a default level if none is stored).

Turning OFF should result in the switchLevel being treated as 0 from the user perspective.

When adjusting the switchLevel slider:

Setting the level to any value greater than 0 should automatically set the switch to ON.

Setting the level to 0 should turn the switch OFF.

The goal is to keep the switch and switchLevel capabilities logically and visually synchronized, which is a more intuitive behavior for users of dimmer devices.

I understand the concern regarding modifying the capability range, and I plan to implement this behavior within the driver logic rather than altering the profile.

Thank you for your guidance and feedback.

Best regards,
Jerry Yang

- id: refresh
version: 1
categories:
- name: Switch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

-- can_handle.lua
-- 判斷是否為 Philio PAD19 裝置


local function can_handle_pad19(opts, driver, device, ...)
local fingerprint_list = {
{mfr = 0x013C, prod_type = 0x0005, prod_id = 0x008A}, -- Philio PAD19
}

for _, fingerprint in ipairs(fingerprint_list) do
if device:id_match(fingerprint.mfr, fingerprint.prod_type, fingerprint.prod_id) then
local subdriver = require("philio-dimmer-switch")
return true, subdriver
end
end

return false
end

return can_handle_pad19
120 changes: 120 additions & 0 deletions drivers/SmartThings/zwave-switch/src/philio-dimmer-switch/init.lua
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Steven's feedback regarding the driver structure. Also be sure to remove the print() statements from this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all .lua files need to include our copyright and license statement

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
local cc = require "st.zwave.CommandClass"
local utils = require "st.utils"
local constants = require "st.zwave.constants"
local Basic = (require "st.zwave.CommandClass.Basic")({ version = 1 })
local SwitchMultilevel = (require "st.zwave.CommandClass.SwitchMultilevel")({ version = 4 })

local function dimmer_event(driver, device, cmd)
local raw = cmd.args.value or cmd.args.target_value or 0

if raw == "OFF_DISABLE" then
raw = 0
end

if type(raw) ~= "number" then
raw = 0
end

local level = utils.clamp_value(raw, 0, 99)
device:emit_event(level > 0 and capabilities.switch.switch.on() or capabilities.switch.switch.off())
device:emit_event(capabilities.switchLevel.level(level))
end

local function basic_report_handler(driver, device, cmd)
local basic_level = cmd.args.value or 0
local level = utils.clamp_value(basic_level, 0, 99)

device:emit_event(level > 0 and capabilities.switch.switch.on() or capabilities.switch.switch.off())
device:emit_event(capabilities.switchLevel.level(level))
end

local function switch_on_handler(driver, device)
device:send(Basic:Set({value = 0xff}))
device.thread:call_with_delay(4, function(d)
device:send(SwitchMultilevel:Get({}))
end)
end

local function switch_off_handler(driver, device)
device:send(Basic:Set({value = 0x00}))
device.thread:call_with_delay(4, function(d)
device:send(SwitchMultilevel:Get({}))
end)
end

local function switch_level_set(driver, device, cmd)
local level = utils.round(cmd.args.level)
level = utils.clamp_value(level, 0, 99)

device:emit_event(level > 0 and capabilities.switch.switch.on() or capabilities.switch.switch.off())
device:emit_event(capabilities.switchLevel.level(level))

------------------------------------------------------------------
-- 修正:SmartThings 可能送出 rate="default",不是數字 → 會造成崩潰
------------------------------------------------------------------
local raw_rate = cmd.args.rate
local dimmingDuration = tonumber(raw_rate) -- dimming duration in seconds
if dimmingDuration == nil then
dimmingDuration = 0 -- Z-Wave duration=0 = 快速/立即
end

device:send(SwitchMultilevel:Set({ value=level, duration=dimmingDuration }))
local function query_level()
device:send(SwitchMultilevel:Get({}))
end
-- delay shall be at least 5 sec.
local delay = math.max(dimmingDuration + constants.DEFAULT_POST_DIMMING_DELAY , constants.MIN_DIMMING_GET_STATUS_DELAY) --delay in seconds
device.thread:call_with_delay(delay, query_level)
end
Comment on lines +49 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same as the defaults except for reporting that the level has changed before it actually has


---- Refresh 指令函式(SmartThings Test Suite 必要)
local function refresh_cmd(driver, device, command)
-- print("DEBUG: PAD19 refresh_cmd called")

-- 取得目前開關狀態
local switch_get = Basic:Get({})
device:send(switch_get)

-- 取得目前dimmer的level
local switchlevel_get = SwitchMultilevel:Get({})
device:send(switchlevel_get)
end
Comment on lines +74 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equivalent to the defaults


-------------------------------------------------------------------
-- Lifecycle
-------------------------------------------------------------------
local pad19_driver_template = {
NAME = "Philio PAD19 Dimmer Switch",
zwave_handlers = {
[cc.BASIC] = {
[Basic.SET] = dimmer_event,
[Basic.REPORT] = basic_report_handler
},
[cc.SWITCH_MULTILEVEL] = {
[SwitchMultilevel.SET] = dimmer_event,
[SwitchMultilevel.REPORT] = dimmer_event
}
},
capability_handlers = {
[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] = switch_level_set
},
[capabilities.refresh.ID] = {
[capabilities.refresh.commands.refresh.NAME] = refresh_cmd
}
},

lifecycle_handlers = {
}
}

-- 回傳驅動範本
return pad19_driver_template
3 changes: 2 additions & 1 deletion drivers/SmartThings/zwave-switch/src/sub_drivers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ return {
lazy_load_if_possible("zooz-zen-30-dimmer-relay"),
lazy_load_if_possible("multichannel-device"),
lazy_load_if_possible("aeotec-smart-switch"),
lazy_load_if_possible("aeotec-heavy-duty")
lazy_load_if_possible("aeotec-heavy-duty"),
lazy_load_if_possible("philio-dimmer-switch")
}
Loading