Skip to content

Commit

Permalink
[ICP-13278] Added preferences for Aeotec Nano Dimmer to adjusting the…
Browse files Browse the repository at this point in the history
… dimmer level (SmartThingsCommunity#37125)

* Added preferences for Aeotec Nano Dimmer to adjusting the dimmer level

* Added requested changes

* Changed name of the method

* Fix

* Updated the description of the needed preference and removed unnecessary one

* Fix

Co-authored-by: Zuzanna Wozniak/Home IoT Development (IoT) /SRPOL/Engineer/Samsung Electronics <[email protected]>
  • Loading branch information
ZWozniakS and Zuzanna Wozniak/Home IoT Development (IoT) /SRPOL/Engineer/Samsung Electronics authored Aug 25, 2020
1 parent 77f0330 commit 7b0d046
Showing 1 changed file with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ metadata {

main(["switch","power","energy"])
details(["switch", "power", "energy", "refresh", "reset"])

preferences {
section {
input(
title: "Settings Available For Aeotec Nano Dimmer Only",
type: "paragraph",
element: "paragraph"
)
input(
title: "Set the MIN brightness level (Aeotec Nano Dimmer Only):",
description: "This may need to be adjusted for bulbs that are not dimming properly.",
name: "minDimmingLevel",
type: "number",
range: "0..99",
defaultValue: 0
)
}
}
}

def getCommandClassVersions() {
Expand All @@ -114,7 +132,15 @@ def installed() {
def updated() {
// Device-Watch simply pings if no device events received for 32min(checkInterval)
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
response(refresh())

def results = []
results << refresh()

if (isAeotecNanoDimmer()) {
results << getAeotecNanoDimmerConfigurationCommands()
}

response(results)
}

// parse events into attributes
Expand Down Expand Up @@ -229,8 +255,14 @@ def setLevel(level, rate = null) {

def configure() {
log.debug "configure()"

def result = []

if (isAeotecNanoDimmer()) {
state.configured = false
result << response(getAeotecNanoDimmerConfigurationCommands())
}

log.debug "Configure zwaveInfo: "+zwaveInfo

if (zwaveInfo.mfr == "0086") { // Aeon Labs meter
Expand Down Expand Up @@ -270,6 +302,36 @@ def normalizeLevel(level) {
level == 99 ? 100 : level
}

def getAeotecNanoDimmerConfigurationCommands() {
def result = []
Integer minDimmingLevel = (settings.minDimmingLevel as Integer) ?: 0 // default value (parameter 131) for Aeotec Nano Dimmer

if (!state.minDimmingLevel) {
state.minDimmingLevel = 0 // default value (parameter 131) for Aeotec Nano Dimmer
}

if (!state.configured || (minDimmingLevel != state.minDimmingLevel)) {
state.configured = false // this flag needs to be set to false when settings are changed (and the device was initially configured before)
result << encap(zwave.configurationV1.configurationSet(parameterNumber: 131, size: 1, scaledConfigurationValue: minDimmingLevel))
result << encap(zwave.configurationV1.configurationGet(parameterNumber: 131))
}

return result
}

def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
if (isAeotecNanoDimmer()) {
if (cmd.parameterNumber == 131) {
state.minDimmingLevel = cmd.scaledConfigurationValue
state.configured = true
}

log.debug "${device.displayName} parameter '${cmd.parameterNumber}' with a byte size of '${cmd.size}' is set to '${cmd.configurationValue}'"
}

return [:]
}

/*
* Security encapsulation support:
*/
Expand Down Expand Up @@ -319,3 +381,7 @@ private encap(physicalgraph.zwave.Command cmd) {
private encapSequence(cmds, Integer delay=250) {
delayBetween(cmds.collect{ encap(it) }, delay)
}

private isAeotecNanoDimmer() {
zwaveInfo?.mfr?.equals("0086") && zwaveInfo?.model?.equals("006F")
}

0 comments on commit 7b0d046

Please sign in to comment.