diff --git a/devicetypes/smartthings/zwave-switch.src/zwave-switch.groovy b/devicetypes/smartthings/zwave-switch.src/zwave-switch.groovy index 798aa63..c46c6a7 100644 --- a/devicetypes/smartthings/zwave-switch.src/zwave-switch.groovy +++ b/devicetypes/smartthings/zwave-switch.src/zwave-switch.groovy @@ -15,7 +15,7 @@ metadata { definition (name: "Z-Wave Switch", namespace: "smartthings", author: "SmartThings") { capability "Actuator" capability "Indicator" - capability "Switch" + capability "Switch" capability "Polling" capability "Refresh" capability "Sensor" @@ -33,6 +33,10 @@ metadata { reply "200100,delay 100,2502": "command: 2503, payload: 00" } + preferences { + input "ledIndicator", "enum", title: "LED Indicator", description: "Turn LED indicator... ", required: false, options:["on": "When On", "off": "When Off", "never": "Never"], defaultValue: "off" + } + // tile definitions tiles(scale: 2) { multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){ @@ -52,10 +56,35 @@ metadata { } main "switch" - details(["switch","refresh","indicator"]) + details(["switch","refresh"]) } } +def installed(){ + initialized() +} + +def updated(){ + initialized() +} + +def initialized() { + switch (ledIndicator) { + case "on": + indicatorWhenOn() + break + case "off": + indicatorWhenOff() + break + case "never": + indicatorNever() + break + default: + indicatorWhenOn() + break + } +} + def parse(String description) { def result = null def cmd = zwave.parse(description, [0x20: 1, 0x70: 1]) @@ -139,19 +168,19 @@ def refresh() { ]) } -def indicatorWhenOn() { +void indicatorWhenOn() { sendEvent(name: "indicatorStatus", value: "when on", display: false) - zwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 3, size: 1).format() + sendHubCommand(new physicalgraph.device.HubAction(zwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 3, size: 1).format())) } -def indicatorWhenOff() { +void indicatorWhenOff() { sendEvent(name: "indicatorStatus", value: "when off", display: false) - zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 3, size: 1).format() + sendHubCommand(new physicalgraph.device.HubAction(zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 3, size: 1).format())) } -def indicatorNever() { +void indicatorNever() { sendEvent(name: "indicatorStatus", value: "never", display: false) - zwave.configurationV1.configurationSet(configurationValue: [2], parameterNumber: 3, size: 1).format() + sendHubCommand(new physicalgraph.device.HubAction(zwave.configurationV1.configurationSet(configurationValue: [2], parameterNumber: 3, size: 1).format())) } def invertSwitch(invert=true) {