From 661e44951dbbf47078795b732958f70f38c40197 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 20 Feb 2023 02:23:48 +0000 Subject: [PATCH 01/18] RELEASE: 0.7.4 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5562e50..26e1ddd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Change Log +## [0.7.4](https://github.com/jshessen/SmartThingsEdgeDrivers/compare/v0.7.3...v0.7.4) (2023-02-20) + + +### :scissors: Code Refactoring + +* **color:** extended set_switch_color ([1033c8a](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/1033c8a6aef27accdd2d681f4be9ec1a2ede1b11)) +* **hsm200:** Change category type ([db9fe7b](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/db9fe7b2241013e7414ef9df26349aa7220dbd77)) +* **hsm200:** ensure parity w/ ezmultipli ([1080f94](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/1080f941f91d22dfe67b66c872f65ef5193193eb)) +* **hsm200:** remove debug/trace statements ([90c8feb](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/90c8febbcecf3d49a9278ac999fab297c093ac84)) + + +### :hammer_and_wrench: Bug Fixes + +* **helpers:** Fix helper path locations ([f19f475](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/f19f4757735643f4bdc1d743acc231c4a4b1ba30)) +* **hsm200:** Add SwitchMultiLevel.Report handler ([4c99410](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/4c99410b2835b53f9b27f01f0a59f2f8aa463de5)) +* **hsm200:** Convert dim duration to number ([b016488](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/b0164882cc61485e3d8e1e5503a9db000b423055)) +* **hsm200:** eliminate the micro-second math ([b174af3](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/b174af35ee3f5cf23da04676e86fdf9bd80ead7e)) +* **switch:** remote switch response ([5cd854d](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/5cd854da243bf9352a93cf6f10e98312f0043f02)) + + +### :broom: Miscellaneous Chores + +* **sensor:** add reference ezmultipli lua ([ac3d65a](https://github.com/jshessen/SmartThingsEdgeDrivers/commit/ac3d65a6531efb1cf489919516e29a2d8988bac0)) + ## [0.7.4-beta.1](https://github.com/jshessen/SmartThingsEdgeDrivers/compare/v0.7.3...v0.7.4-beta.1) (2023-02-20) From b917aecb34cea215ed4e6886f3a9a06b42892530 Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 20 Feb 2023 15:40:52 -0600 Subject: [PATCH 02/18] refactor(color): Remove debug logging --- .../zwave-switch/src/homeseer-switches/color_helper.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua index 086622a0..4d7099ba 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua @@ -111,7 +111,6 @@ function color.set_switch_color(device, command, r, g, b) end local hue, saturation, mylightness = utils.rgb_to_hsl(r, g, b) - log.trace(string.format("***** HSM200 Driver *****: myhue=%s,mysat=%s", device:pretty_print(),hue, saturation)) command.args.color = { hue = hue, saturation = saturation, From 86fcdad00f57a15c2533779d2d57b3b5f23834f8 Mon Sep 17 00:00:00 2001 From: jshessen Date: Tue, 21 Feb 2023 14:03:07 -0600 Subject: [PATCH 03/18] fix(hsm200): segmented the hue/sat emit --- .../src/homeseer-hsm200-sensor/init.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua index f28c1f83..e6471dff 100644 --- a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua +++ b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua @@ -86,18 +86,18 @@ function zwave_handlers.switch_multilevel_handler(driver, device, command) local level = command.args.value or command.args.target_value -- Simplify if-else statement local value = (level > 0 or level == SwitchBinary.value.ON_ENABLE) and SwitchBinary.value.ON_ENABLE or SwitchBinary.value.OFF_DISABLE - + local event = value == SwitchBinary.value.ON_ENABLE and capabilities.switch.switch.on() + or capabilities.switch.switch.off() if command.component == "main" then --local set = SwitchBinary:Set({ target_value=value, duration=0 }) local set = Basic:Set({ value=value }) device:send(set) if value == SwitchBinary.value.ON_ENABLE then - device:emit_event(capabilities.switch.switch.on()) + device:emit_component_event(event, command.component) else - device:emit_event(capabilities.switch.switch.off()) - local hue=capabilities.colorControl.hue(0) - local saturation=capabilities.colorControl.saturation(0) - device:emit_event_for_endpoint(command.src_channel,hue,saturation) + device:emit_component_event(event, command.component) + device:emit_component_event(capabilities.colorControl.hue(0), command.component) + device:emit_component_event(capabilities.colorControl.saturation(0), command.component) end if device:supports_capability(capabilities.switchLevel, nil) then local dimmingDuration = command.args.rate or constants.DEFAULT_DIMMING_DURATION @@ -194,9 +194,9 @@ local homeseer_multipurpose_sensor = { [cc.BASIC] = { [Basic.REPORT] = zwave_handlers.switch_multilevel_handler }, - --[cc.NOTIFICATIONS] = { - --[Notification.REPORT] = zwave_handlers.notification_report_handler - --} + --[[ [cc.NOTIFICATION] = { + [Notification.REPORT] = zwave_handlers.notification_report_handler + } ]] }, capability_handlers = { [capabilities.switch.ID] = { From 26808c01728b074ac5cea0b08b3fbf5cdfab9647 Mon Sep 17 00:00:00 2001 From: jshessen Date: Tue, 21 Feb 2023 16:20:02 -0600 Subject: [PATCH 04/18] add debugging --- .../src/homeseer-hsm200-sensor/init.lua | 55 +++++++++++++------ .../src/homeseer-switches/color_helper.lua | 3 + 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua index e6471dff..629f10b6 100644 --- a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua +++ b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua @@ -82,24 +82,36 @@ local capability_handlers = {} --- @param device (st.zwave.Device) The device instance. --- @param command (Command) The command table. function zwave_handlers.switch_multilevel_handler(driver, device, command) - -- Declare local variables 'level' and 'value' - local level = command.args.value or command.args.target_value -- Simplify if-else statement + -- Declare local variables + local event + local level = command.args.target_value or command.args.value local value = (level > 0 or level == SwitchBinary.value.ON_ENABLE) and SwitchBinary.value.ON_ENABLE or SwitchBinary.value.OFF_DISABLE - local event = value == SwitchBinary.value.ON_ENABLE and capabilities.switch.switch.on() - or capabilities.switch.switch.off() + local endpoint = command.src_channel + + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, In function")) if command.component == "main" then + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, In \"main\" conditional")) + if value == SwitchBinary.value.OFF_DISABLE then + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, In \"off\"")) + event = capabilities.switch.switch.off() + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, emit hue=0")) + device:emit_event_for_endpoint(endpoint, capabilities.colorControl.hue(0)) + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, emit saturation=0")) + device:emit_event_for_endpoint(endpoint, capabilities.colorControl.saturation(0)) + else + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, In \"on\"")) + event = capabilities.switch.switch.off() + end --local set = SwitchBinary:Set({ target_value=value, duration=0 }) + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, Basic:Set")) local set = Basic:Set({ value=value }) device:send(set) - if value == SwitchBinary.value.ON_ENABLE then - device:emit_component_event(event, command.component) - else - device:emit_component_event(event, command.component) - device:emit_component_event(capabilities.colorControl.hue(0), command.component) - device:emit_component_event(capabilities.colorControl.saturation(0), command.component) - end + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, emit on/off event")) + device:emit_event_for_endpoint(endpoint, event) + if device:supports_capability(capabilities.switchLevel, nil) then + log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, In switchLevel conditional")) local dimmingDuration = command.args.rate or constants.DEFAULT_DIMMING_DURATION level = math.floor(level + 0.5) -- Round off 'level' to the nearest integer level = utils.clamp_value(level, 0, 99) -- Clamp 'level' to the range [0, 99] @@ -123,20 +135,26 @@ function zwave_handlers.switch_color_handler(driver, device, command) local color = helpers.color.map[7] local hue local saturation + + log.debug(string.format("***** HSM200 *****: switch_color_handler, In function")) if command.args.color then hue = command.args.color.hue + log.debug(string.format("***** HSM200 *****: switch_color_handler, hue=%s",hue)) saturation = command.args.color.saturation + log.debug(string.format("***** HSM200 *****: switch_color_handler, saturation=%s",saturation)) --log.trace(string.format("%s: basic_report_handler -- Find the closest supported color", device:pretty_print())) --color = helpers.color.find_closest_color(hue, saturation, nil) end --local r, g, b = helpers.color.hex_to_rgb(color.hex) local r, g, b = utils.hsl_to_rgb(hue,saturation,nil) + log.debug(string.format("***** HSM200 *****: switch_color_handler, HSL to RGB, r=%s,g=%s,b=%s",r,g,b)) if not r then log.error(string.format("%s: Failed to convert color Hue/Saturation to RGB.", device:pretty_print())) return end + log.debug(string.format("***** HSM200 *****: switch_color_handler,call set_switch_color")) helpers.color.set_switch_color(device, command, r, g, b) end capability_handlers.switch_color_handler = zwave_handlers.switch_color_handler @@ -175,13 +193,18 @@ end --- @param value (st.zwave.CommandClass.SwitchBinary.value) --- @return (function) function capability_handlers.switch_binary_handler(value) - --- Hand off to zwave_handlers.switch_multilevel_handler - --- @param driver (Driver) The driver object - --- @param device (st.zwave.Device) The device object - --- @param command (Command) Input command value - --- @return (nil) + --- Hand off to zwave_handlers.switch_multilevel_handler + --- @param driver (Driver) The driver object + --- @param device (st.zwave.Device) The device object + --- @param command (Command) Input command value + --- @return (nil) + + log.debug(string.format("***** HSM200 *****: switch_binary_handler, In function")) + return function(driver, device, command) + log.debug(string.format("***** HSM200 *****: switch_bianry_handler, value=%s",value)) command.args.value = value + log.debug(string.format("***** HSM200 *****: switch_binary_handler, call switch_multilevel_handler")) zwave_handlers.switch_multilevel_handler(device,device,command) end end diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua index 4d7099ba..fc90db0e 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua @@ -110,7 +110,9 @@ function color.set_switch_color(device, command, r, g, b) return false end + log.debug(string.format("***** HSM200 *****: set_switch_color, In function")) local hue, saturation, mylightness = utils.rgb_to_hsl(r, g, b) + log.debug(string.format("***** HSM200 *****: set_switch_color, RGB to HSL, hue=%s, saturation=%s",hue,saturation)) command.args.color = { hue = hue, saturation = saturation, @@ -128,6 +130,7 @@ function color.set_switch_color(device, command, r, g, b) }, duration = dim_duration }) + log.debug(string.format("***** HSM200 *****: set_switch_color, set=%s",set)) device:send_to_component(set, command.component) local color_check = function() From b48ebbcae5cbc630c0b78c1c4564b9a56e9bc504 Mon Sep 17 00:00:00 2001 From: jshessen Date: Thu, 23 Feb 2023 14:54:40 -0600 Subject: [PATCH 05/18] debug logs --- .../zwave-sensor/src/homeseer-hsm200-sensor/init.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua index 629f10b6..c4f8440d 100644 --- a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua +++ b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua @@ -193,19 +193,17 @@ end --- @param value (st.zwave.CommandClass.SwitchBinary.value) --- @return (function) function capability_handlers.switch_binary_handler(value) + log.debug(string.format("***** HSM200 *****: switch_binary_handler, In function")) --- Hand off to zwave_handlers.switch_multilevel_handler --- @param driver (Driver) The driver object --- @param device (st.zwave.Device) The device object --- @param command (Command) Input command value --- @return (nil) - - log.debug(string.format("***** HSM200 *****: switch_binary_handler, In function")) - return function(driver, device, command) log.debug(string.format("***** HSM200 *****: switch_bianry_handler, value=%s",value)) command.args.value = value log.debug(string.format("***** HSM200 *****: switch_binary_handler, call switch_multilevel_handler")) - zwave_handlers.switch_multilevel_handler(device,device,command) + zwave_handlers.switch_multilevel_handler(driver,device,command) end end From d0094fab71ca1a72b747fc1e5e6ad97b4a5b785f Mon Sep 17 00:00:00 2001 From: jshessen Date: Thu, 23 Feb 2023 14:55:00 -0600 Subject: [PATCH 06/18] blinkControl profile --- .../zwave-fan/src/homeseer-fan/color_helper.lua | 0 .../SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua | 0 .../zwave-fan/src/homeseer-fan/multi_tap_helper.lua | 0 .../zwave-fan/src/homeseer-fan/profile_helper.lua | 0 .../src/homeseer-hsm200-sensor/color_helper.lua | 0 .../profiles/homeseer-wx300s-status-latest.yaml | 8 ++++++++ 6 files changed, 8 insertions(+) mode change 120000 => 100644 drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua mode change 120000 => 100644 drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua mode change 120000 => 100644 drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua mode change 120000 => 100644 drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua mode change 120000 => 100644 drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua deleted file mode 120000 index 402bbdb9..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua new file mode 100644 index 00000000..402bbdb9 --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua deleted file mode 120000 index c27f2e2b..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/led_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua new file mode 100644 index 00000000..c27f2e2b --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/led_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua deleted file mode 120000 index 07dbafae..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/multi_tap_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua new file mode 100644 index 00000000..07dbafae --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/multi_tap_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua deleted file mode 120000 index 6a21b972..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/profile_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua new file mode 100644 index 00000000..6a21b972 --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/profile_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua deleted file mode 120000 index 402bbdb9..00000000 --- a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua new file mode 100644 index 00000000..402bbdb9 --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml index 01db9960..fb542f2a 100644 --- a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml +++ b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml @@ -19,6 +19,14 @@ components: version: 1 - id: colorControl version: 1 + - id: blinkControl + version: 1 + config: + values: + - key: blinkControl.value + enabledValues: + - on + - off categories: - name: Switch - id: LED-2 From 892b3f4ee43546ad662d0823e031fd8a829f92d9 Mon Sep 17 00:00:00 2001 From: jshessen Date: Thu, 23 Feb 2023 15:30:00 -0600 Subject: [PATCH 07/18] blinkControl profile --- .../profiles/homeseer-wx300s-status-latest.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml index fb542f2a..5e4f5ab9 100644 --- a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml +++ b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml @@ -17,16 +17,14 @@ components: capabilities: - id: switch version: 1 - - id: colorControl - version: 1 - - id: blinkControl - version: 1 config: values: - - key: blinkControl.value + - key: switch.blinkControl.value enabledValues: - on - off + - id: colorControl + version: 1 categories: - name: Switch - id: LED-2 From 8d580c2726a1190cb574797fd4fde5d0e6c37df0 Mon Sep 17 00:00:00 2001 From: jshessen Date: Thu, 23 Feb 2023 16:01:41 -0600 Subject: [PATCH 08/18] blinkControl profile --- .../homeseer-wx300s-status-latest.yaml | 125 +++++++++++++++--- 1 file changed, 105 insertions(+), 20 deletions(-) diff --git a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml index 5e4f5ab9..d40a9d82 100644 --- a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml +++ b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml @@ -12,69 +12,154 @@ components: - id: refresh version: 1 categories: - - name: Switch + - name: Light - id: LED-1 capabilities: - id: switch version: 1 config: - values: - - key: switch.blinkControl.value - enabledValues: - - on - - off + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: 0 + enumValues: + - value: 1 + label: On + - value: 0 + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light - id: LED-2 capabilities: - id: switch version: 1 + config: + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: false + enumValues: + - value: false + label: On + - value: true + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light - id: LED-3 capabilities: - id: switch version: 1 + config: + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: false + enumValues: + - value: false + label: On + - value: true + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light - id: LED-4 capabilities: - id: switch version: 1 + config: + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: false + enumValues: + - value: false + label: On + - value: true + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light - id: LED-5 capabilities: - id: switch version: 1 + config: + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: false + enumValues: + - value: false + label: On + - value: true + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light - id: LED-6 capabilities: - id: switch version: 1 + config: + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: false + enumValues: + - value: false + label: On + - value: true + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light - id: LED-7 capabilities: - id: switch version: 1 + config: + - key: blinkControl + title: Blink Control + description: Blink control for the LED + type: enum + required: false + multiple: false + default: false + enumValues: + - value: false + label: On + - value: true + label: Off - id: colorControl version: 1 categories: - - name: Switch + - name: Light preferences: - name: "operatingMode" title: "Switch Operating Mode" @@ -134,7 +219,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink1" - title: "LED-1 Enable Status Blink" + title: "LED-1 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean @@ -157,7 +242,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink2" - title: "LED-2 Enable Status Blink" + title: "LED-2 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean @@ -180,7 +265,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink3" - title: "LED-3 Enable Status Blink" + title: "LED-3 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean @@ -203,7 +288,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink4" - title: "LED-4 Enable Status Blink" + title: "LED-4 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean @@ -226,7 +311,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink5" - title: "LED-5 Enable Status Blink" + title: "LED-5 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean @@ -249,7 +334,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink6" - title: "LED-6 Enable Status Blink" + title: "LED-6 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean @@ -272,7 +357,7 @@ preferences: 6: "Cyan" default: 0 - name: "ledStatusBlink7" - title: "LED-7 Enable Status Blink" + title: "LED-7 Enable Blink Functionality" description: "Default: Off" required: false preferenceType: boolean From 2b3607425159192f2ddcfba8dffbb44cf6cb1ed4 Mon Sep 17 00:00:00 2001 From: jshessen Date: Fri, 24 Feb 2023 15:16:15 -0600 Subject: [PATCH 09/18] debug --- .../zwave-switch/src/homeseer-switches/color_helper.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua index fc90db0e..253e4481 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/color_helper.lua @@ -39,9 +39,6 @@ local log = (require "log") --- Variables/Constants --- ---- @type string -local CAP_CACHE_KEY = "st.capabilities." .. capabilities.colorControl.ID - --- @local (table) local color = { map = { @@ -117,6 +114,7 @@ function color.set_switch_color(device, command, r, g, b) hue = hue, saturation = saturation, } + local CAP_CACHE_KEY = "st.capabilities." .. capabilities.colorControl.ID device:set_field(CAP_CACHE_KEY, command) local dim_duration = constants.DEFAULT_DIMMING_DURATION From e176d342904a09a422f5651ba1f38a4f976d2c0a Mon Sep 17 00:00:00 2001 From: jshessen Date: Fri, 24 Feb 2023 15:24:51 -0600 Subject: [PATCH 10/18] fix(color): Restore symlink --- .../zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 120000 drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua deleted file mode 100644 index 402bbdb9..00000000 --- a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua new file mode 120000 index 00000000..402bbdb9 --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/color_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file From be2ab3fbceb8d5c0f5c4b2a618194eccbf331ad2 Mon Sep 17 00:00:00 2001 From: jshessen Date: Fri, 24 Feb 2023 16:00:11 -0600 Subject: [PATCH 11/18] restore profile --- .../profiles/homeseer-hsm200.yaml | 2 +- .../homeseer-wx300s-status-latest.yaml | 91 ------------------- 2 files changed, 1 insertion(+), 92 deletions(-) diff --git a/drivers/SmartThings/zwave-sensor/profiles/homeseer-hsm200.yaml b/drivers/SmartThings/zwave-sensor/profiles/homeseer-hsm200.yaml index 297fcb90..88330c07 100644 --- a/drivers/SmartThings/zwave-sensor/profiles/homeseer-hsm200.yaml +++ b/drivers/SmartThings/zwave-sensor/profiles/homeseer-hsm200.yaml @@ -24,7 +24,7 @@ components: - id: refresh version: 1 categories: - - name: MultiFunctionalSensor + - name: MotionSensor preferences: - name: "motionDelayTime" title: "Motion Sensor Delay Time" diff --git a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml index d40a9d82..2c340777 100644 --- a/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml +++ b/drivers/SmartThings/zwave-switch/profiles/homeseer-wx300s-status-latest.yaml @@ -17,19 +17,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: 0 - enumValues: - - value: 1 - label: On - - value: 0 - label: Off - id: colorControl version: 1 categories: @@ -38,19 +25,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: false - enumValues: - - value: false - label: On - - value: true - label: Off - id: colorControl version: 1 categories: @@ -59,19 +33,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: false - enumValues: - - value: false - label: On - - value: true - label: Off - id: colorControl version: 1 categories: @@ -80,19 +41,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: false - enumValues: - - value: false - label: On - - value: true - label: Off - id: colorControl version: 1 categories: @@ -101,19 +49,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: false - enumValues: - - value: false - label: On - - value: true - label: Off - id: colorControl version: 1 categories: @@ -122,19 +57,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: false - enumValues: - - value: false - label: On - - value: true - label: Off - id: colorControl version: 1 categories: @@ -143,19 +65,6 @@ components: capabilities: - id: switch version: 1 - config: - - key: blinkControl - title: Blink Control - description: Blink control for the LED - type: enum - required: false - multiple: false - default: false - enumValues: - - value: false - label: On - - value: true - label: Off - id: colorControl version: 1 categories: From c45a5f5cf3ab1f3a7e2aab72e7d7cd4f2053d6a6 Mon Sep 17 00:00:00 2001 From: jshessen Date: Fri, 24 Feb 2023 16:09:27 -0600 Subject: [PATCH 12/18] add basic.report --- .../SmartThings/zwave-switch/src/homeseer-switches/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua index 94b5ef9a..63e1245b 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua @@ -371,6 +371,9 @@ local homeseer_switches = { [cc.CENTRAL_SCENE] = { [CentralScene.NOTIFICATION] = zwave_handlers.emit_central_scene_events }, + [cc.BASIC] = { + [Basic.Report] = zwave_handlers.switch_multilevel_handler + }, -- Return firmware version [cc.VERSION] = { [Version.REPORT] = zwave_handlers.version_report_handler From 617a6ea23220a3b85d56308b3006f02dfdf99658 Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 27 Feb 2023 12:21:52 -0600 Subject: [PATCH 13/18] Added emit for components --- .../src/homeseer-fan/color_helper.lua | 0 .../zwave-fan/src/homeseer-fan/led_helper.lua | 0 .../src/homeseer-fan/multi_tap_helper.lua | 0 .../src/homeseer-fan/profile_helper.lua | 0 .../src/homeseer-switches/init.lua | 25 ++++++++----------- 5 files changed, 11 insertions(+), 14 deletions(-) mode change 100644 => 120000 drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua mode change 100644 => 120000 drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua mode change 100644 => 120000 drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua mode change 100644 => 120000 drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua deleted file mode 100644 index 402bbdb9..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua new file mode 120000 index 00000000..402bbdb9 --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/color_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/color_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua deleted file mode 100644 index c27f2e2b..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/led_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua new file mode 120000 index 00000000..c27f2e2b --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/led_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/led_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua deleted file mode 100644 index 07dbafae..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/multi_tap_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua new file mode 120000 index 00000000..07dbafae --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/multi_tap_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/multi_tap_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua deleted file mode 100644 index 6a21b972..00000000 --- a/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua +++ /dev/null @@ -1 +0,0 @@ -../../../zwave-switch/src/homeseer-switches/profile_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua b/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua new file mode 120000 index 00000000..6a21b972 --- /dev/null +++ b/drivers/SmartThings/zwave-fan/src/homeseer-fan/profile_helper.lua @@ -0,0 +1 @@ +../../../zwave-switch/src/homeseer-switches/profile_helper.lua \ No newline at end of file diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua index 63e1245b..d7086b6e 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua @@ -98,20 +98,17 @@ local capability_handlers = {} --- @param command (Command) Input command value --- @return (nil) function zwave_handlers.switch_multilevel_handler(driver, device, command) - -- Declare local variables 'level' and 'value' - local level = command.args.value or command.args.target_value -- Simplify if-else statement - local value = (level > 0 or level == SwitchBinary.value.ON_ENABLE) and SwitchBinary.value.ON_ENABLE - or SwitchBinary.value.OFF_DISABLE + -- Declare local variables + local level = command.args.value or command.args.target_value + local value = (level > 0 or level == SwitchBinary.value.ON_ENABLE) and SwitchBinary.value.ON_ENABLE or SwitchBinary.value.OFF_DISABLE + local event = value == SwitchBinary.value.ON_ENABLE and capabilities.switch.switch.on() or capabilities.switch.switch.off() + local endpoint = command.src_channel if command.component == "main" then local set = Basic:Set({ value=value }) device:send(set) - if value == SwitchBinary.value.ON_ENABLE then - device:emit_event(capabilities.switch.switch.on()) - else - device:emit_event(capabilities.switch.switch.off()) - end - -- If the device supports switch level capability + device:emit_event_for_endpoint(endpoint, event) + if device:supports_capability(capabilities.switchLevel, nil) then local dimmingDuration = command.args.rate or constants.DEFAULT_DIMMING_DURATION level = math.floor(level + 0.5) -- Round off 'level' to the nearest integer @@ -119,14 +116,14 @@ function zwave_handlers.switch_multilevel_handler(driver, device, command) set = SwitchMultilevel:Set({value = level, duration = dimmingDuration }) device:send(set) -- Send the 'set' command directly to the device and check for errors - local get = function() - device:send(SwitchBinary:Get({})) -- Send a 'get' command to the device to get its current status and check for errors - end - device.thread:call_with_delay(constants.DEFAULT_GET_STATUS_DELAY, get) + device.thread:call_with_delay(constants.DEFAULT_GET_STATUS_DELAY, function() + device:send(SwitchBinary:Get({})) + end) end else command.args.value = value helpers.led.set_status_color(device, command) -- Update the LED status and check for error + device:emit_event_for_endpoint(endpoint, event) end end From 835000420260572df2cf1d92ef26c1f8247be0c5 Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 27 Feb 2023 12:41:28 -0600 Subject: [PATCH 14/18] fix "off" which should be "on" --- .../zwave-sensor/src/homeseer-hsm200-sensor/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua index c4f8440d..a10eeefb 100644 --- a/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua +++ b/drivers/SmartThings/zwave-sensor/src/homeseer-hsm200-sensor/init.lua @@ -101,7 +101,7 @@ function zwave_handlers.switch_multilevel_handler(driver, device, command) device:emit_event_for_endpoint(endpoint, capabilities.colorControl.saturation(0)) else log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, In \"on\"")) - event = capabilities.switch.switch.off() + event = capabilities.switch.switch.on() end --local set = SwitchBinary:Set({ target_value=value, duration=0 }) log.debug(string.format("***** HSM200 *****: switch_multilevel_handler, Basic:Set")) From c5ef5524f7724fb5a0d0fd8a4a18378198facde4 Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 27 Feb 2023 12:41:36 -0600 Subject: [PATCH 15/18] emit testing --- .../SmartThings/zwave-switch/src/homeseer-switches/init.lua | 3 ++- .../zwave-switch/src/homeseer-switches/led_helper.lua | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua index d7086b6e..79b0b50d 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua @@ -122,7 +122,8 @@ function zwave_handlers.switch_multilevel_handler(driver, device, command) end else command.args.value = value - helpers.led.set_status_color(device, command) -- Update the LED status and check for error + local color = helpers.led.set_status_color(device, command) -- Update the LED status and check for error + event = color == SwitchBinary.value.OFF_DISABLE and capabilities.switch.switch.off() or capabilities.switch.switch.on() device:emit_event_for_endpoint(endpoint, event) end end diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua index ccc50c4c..65a7c544 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua @@ -61,7 +61,7 @@ local led = {} --- Sets component color to closest supported color match --- @param device (st.zwave.Device) The device object --- @param command (Command) Input command value ---- @return (nil) +--- @return (number)|(nil) color function led.set_status_color(device, command) local preferences = preferencesMap.get_device_parameters(device) ---@type number @@ -108,7 +108,7 @@ function led.set_status_color(device, command) if not parameter_number or not size then --- If the parameter number or size is missing, log an error and return log.error(string.format("%s: Missing parameter number or size for component %s", device:pretty_print(), component)) - return false + return nil end --- Create a configuration set based on the parameter number, size, and value local set = Configuration:Set({ @@ -117,6 +117,7 @@ function led.set_status_color(device, command) configuration_value = value }) device:send(set) + return value end --- --- ####################################################### From 25ba031e44cae10578f5b17d8bf9736c970ed0bb Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 27 Feb 2023 13:14:46 -0600 Subject: [PATCH 16/18] Update preferences --- .../src/homeseer-switches/init.lua | 11 +++++++++- .../src/homeseer-switches/led_helper.lua | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua index 79b0b50d..632e4b50 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua @@ -201,7 +201,16 @@ function capability_handlers.do_refresh(driver, device, command) device:supports_capability(capabilities.switchLevel, component) and capabilities.switchLevel or nil -- Check if the device supports switch level capability if capability then - device:send_to_component(capability == capabilities.switch and SwitchBinary:Get({}) or SwitchMultilevel:Get({}), component) + if command.component == "main" then + device:send_to_component(capability == capabilities.switch and SwitchBinary:Get({}) or SwitchMultilevel:Get({}), component) + else + local color_id = helpers.led.get_status_color(device,command) + if color_id then + device:emit_event_for_endpoint(command.src_channel,capabilities.switch.switch.on()) + else + device:emit_event_for_endpoint(command.src_channel,capabilities.switch.switch.off()) + end + end end end diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua index 65a7c544..9810a4c0 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua @@ -117,6 +117,7 @@ function led.set_status_color(device, command) configuration_value = value }) device:send(set) + device:update_preferences({component = parameter_number}) return value end --- @@ -125,6 +126,25 @@ end --- ####################################################### --- +--- @function led.get_status_color() -- +--- Gets current component color +--- @param device (st.zwave.Device) The device object +--- @param command (Command) Input command value +--- @return (number)|(nil) color +function led.get_status_color(device, command) + local preferences = preferencesMap.get_device_parameters(device) + ---@type string + local component = "ledStatusColor" .. string.sub(command.component, string.find(command.component, "-") + 1) + ---@type number + local color_id = device.preferences[component] + return color_id +end +--- +--- ####################################################### + +--- ####################################################### +--- + --- @function led.set_blink_bitmask() -- --- Sets LED to blink based upon preference settings --- @param device (st.zwave.Device) The device object From 69a9e9f30a25e4f0e31d6300854670d979ce36f2 Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 27 Feb 2023 13:34:05 -0600 Subject: [PATCH 17/18] debug --- .../SmartThings/zwave-switch/src/homeseer-switches/init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua index 632e4b50..5030c28d 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua @@ -123,6 +123,7 @@ function zwave_handlers.switch_multilevel_handler(driver, device, command) else command.args.value = value local color = helpers.led.set_status_color(device, command) -- Update the LED status and check for error + log.debug(string.format("***** HomeSeer Switches *****: color=%s", color)) event = color == SwitchBinary.value.OFF_DISABLE and capabilities.switch.switch.off() or capabilities.switch.switch.on() device:emit_event_for_endpoint(endpoint, event) end @@ -202,9 +203,12 @@ function capability_handlers.do_refresh(driver, device, command) -- Check if the device supports switch level capability if capability then if command.component == "main" then + log.debug(string.format("***** HomeSeer Switches *****: I'm in the main loop")) device:send_to_component(capability == capabilities.switch and SwitchBinary:Get({}) or SwitchMultilevel:Get({}), component) else + log.debug(string.format("***** HomeSeer Switches *****: I'm in the component loop")) local color_id = helpers.led.get_status_color(device,command) + log.debug(string.format("***** HomeSeer Switches *****: color=%s", color_id)) if color_id then device:emit_event_for_endpoint(command.src_channel,capabilities.switch.switch.on()) else From 377123b21cf841242d48c77be0ae0ebbd7f11103 Mon Sep 17 00:00:00 2001 From: jshessen Date: Mon, 27 Feb 2023 13:40:25 -0600 Subject: [PATCH 18/18] debug --- .../SmartThings/zwave-switch/src/homeseer-switches/init.lua | 6 +++--- .../zwave-switch/src/homeseer-switches/led_helper.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua index 5030c28d..13b5a7df 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/init.lua @@ -198,11 +198,11 @@ end function capability_handlers.do_refresh(driver, device, command) -- Determine the component for the command local component = command and command.component or "main" - local capability = device:supports_capability(capabilities.switch, component) and capabilities.switch or - device:supports_capability(capabilities.switchLevel, component) and capabilities.switchLevel or nil + local capability = device:supports_capability(capabilities.switchLevel, component) and capabilities.switchLevel or + device:supports_capability(capabilities.switch, component) and capabilities.switch or nil -- Check if the device supports switch level capability if capability then - if command.component == "main" then + if component == "main" then log.debug(string.format("***** HomeSeer Switches *****: I'm in the main loop")) device:send_to_component(capability == capabilities.switch and SwitchBinary:Get({}) or SwitchMultilevel:Get({}), component) else diff --git a/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua b/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua index 9810a4c0..a205af85 100644 --- a/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua +++ b/drivers/SmartThings/zwave-switch/src/homeseer-switches/led_helper.lua @@ -132,11 +132,11 @@ end --- @param command (Command) Input command value --- @return (number)|(nil) color function led.get_status_color(device, command) - local preferences = preferencesMap.get_device_parameters(device) ---@type string local component = "ledStatusColor" .. string.sub(command.component, string.find(command.component, "-") + 1) ---@type number local color_id = device.preferences[component] + log.debug(string.format("***** HomeSeer Switches *****: led.get_status_color- color_id=%s", color_id)) return color_id end ---