I have 3 inputs:
preferences {
input name: "wakeUpInterval", type: "number", title: "Wake Up Interval (0-24h)", description: "24", displayDuringSetup: true, range:"0..24"
input name: "report", type: "enum", title: "Report Type", description: "Alert Report", displayDuringSetup: true, options: ["Alert Report","Sensor Binary Report","Basic Report"], defaultValue: "Alert Report"
input name: "led", type: "bool", title: "LED", description: "LED", required: true, displayDuringSetup: true, defaultValue: true
}
But since the attribute “defaultValue” does not work, I need a workaround.
I have the method:
def resultConfiguration() {
def result = []
def timeString = new Date().format("MMM d yyyy, hh:mm:ss", location.timeZone)
result << createEvent(name: "tamper", value: timeString , descriptionText: "$device.displayName was tampered")
if ( wakeUpInterval != null) {
result << response(zwave.wakeUpV1.wakeUpIntervalSet(seconds:3600*wakeUpInterval, nodeid:zwaveHubNodeId).format())
}
if ( led != null ) {
if (led) {
result << response(zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, scaledConfigurationValue: 1).format())
} else {
result << response(zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, scaledConfigurationValue: 0).format())
}
}
}
First , I tried to define the variables’ values in configure(), but it didn’t work - I guess they are defined only locally.
Then I tried the above: using “if” statements to catch when the variables are null and not to execute their respective “result”.
But the above method is not working when “led” and “wakeupInterval” are null - the “tamper” event is not sent and I don’t know why - is there something wrong with the syntax? It looks, as the “if” condition is not working properly - the values are null, but still it tries to execute the commands.
Is there a way to set the variables somehow during the configuration to avoid them being null?