Skip to content
Merged
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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should refactor this to remove state.configured and replace it with the two boolean configuration flags that you are using elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need all these 3 configuration flags for the initial configuration and it would be less clear if we replace that with two checkings for individual parameters

Copy link
Contributor

Choose a reason for hiding this comment

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

now that there's only one preference I think you can refactor this to remove the configured flag. state.minDimmingLevel and settings.minDimmingLevel should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

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")
}