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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ components:
- id: refresh
version: 1
categories:
- name: MultiFunctionalSensor
- name: MotionSensor
preferences:
- name: "motionDelayTime"
title: "Motion Sensor Delay Time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.on()
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_event(capabilities.switch.switch.on())
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)
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]
Expand All @@ -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
Expand Down Expand Up @@ -175,14 +193,17 @@ 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)
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)
return function(driver, device, command)
log.debug(string.format("***** HSM200 *****: switch_bianry_handler, value=%s",value))
command.args.value = value
zwave_handlers.switch_multilevel_handler(device,device,command)
log.debug(string.format("***** HSM200 *****: switch_binary_handler, call switch_multilevel_handler"))
zwave_handlers.switch_multilevel_handler(driver,device,command)
end
end

Expand All @@ -194,9 +215,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] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,63 @@ components:
- id: refresh
version: 1
categories:
- name: Switch
- name: Light
- id: LED-1
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
- id: LED-2
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
- id: LED-3
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
- id: LED-4
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
- id: LED-5
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
- id: LED-6
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
- id: LED-7
capabilities:
- id: switch
version: 1
- id: colorControl
version: 1
categories:
- name: Switch
- name: Light
preferences:
- name: "operatingMode"
title: "Switch Operating Mode"
Expand Down Expand Up @@ -128,7 +128,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
Expand All @@ -151,7 +151,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
Expand All @@ -174,7 +174,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
Expand All @@ -197,7 +197,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
Expand All @@ -220,7 +220,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
Expand All @@ -243,7 +243,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
Expand All @@ -266,7 +266,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -110,12 +107,14 @@ 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.trace(string.format("***** HSM200 Driver *****: myhue=%s,mysat=%s", device:pretty_print(),hue, saturation))
log.debug(string.format("***** HSM200 *****: set_switch_color, RGB to HSL, hue=%s, saturation=%s",hue,saturation))
command.args.color = {
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
Expand All @@ -129,6 +128,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()
Expand Down
Loading