Can someone tell whats wrong with this code. Iâm trying to add setup for the light.
[pre]Preformatted text
/**
*zw:Ls type:1001 mfr:0326 prod:0003 model:0012 ver:4.01 zwv:6.01 lib:03 cc:5E,55,98,9F
*sec:86,25,70,85,8E,59,72,5A,73,6C,7A role:05 ff:8700 ui:8700
*
*TODKI Wireless Smart Power Switch Plug hub - TD-ZW101
*/
metadata {
definition(name: âTODKI TD-ZW101â, namespace: âsmartthingsâ, author: âTmasterâ, ocfDeviceType: âoic.d.switchâ, runLocally: false, minHubCoreVersion: â000.019.00012â, executeCommandsLocally: false) {
capability âSwitchâ
capability âIndicatorâ
capability âRefreshâ
capability âPollingâ
capability âActuatorâ
capability âSensorâ
capability âHealth Checkâ
capability âConfigurationâ
fingerprint inClusters: "0x25,0x98"
fingerprint deviceId: "0x10", inClusters: "0x98"
fingerprint mfr: "0326", prod: "0003", model: "0012", deviceJoinName: "TODKI TD-ZW101 Switch"
}
simulator {
status "on": "command: 9881, payload: 002503FF"
status "off": "command: 9881, payload: 00250300"
reply "9881002001FF,delay 200,9881002502": "command: 9881, payload: 002503FF"
reply "988100200100,delay 200,9881002502": "command: 9881, payload: 00250300"
}
preferences
{
section {
input "ledIndicator", "enum", title: "LED Indicator", description: "Turn LED indicator... ", required: false, options:["on": "When On", "off": "When Off", "never": "Never"], defaultValue: "on"
}
section {
input title: "Device Debug", description: "This feature allows you log message handling to the device for troubleshooting purposes.", displayDuringSetup: false, type: "paragraph", element: "paragraph"
input title: "Enable debug messages?", displayDuringSetup: false, type: "bool", name: "debugEnabled"
}
}
// tile definitions
tiles {
standardTile("switch", "device.switch", width: 4, height: 4, canChangeIcon: true) {
state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00a0dc"
state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
}
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label: '', action: "refresh.refresh", icon: "st.secondary.refresh"
}
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00A0DC"
attributeState "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
}
}
main "switch"
details(["switch", "refresh"])
}
}
def installed() {
// Device-Watch simply pings if no device events received for checkInterval duration of 32min = 2 * 15min + 2min lag time
sendEvent(name: âcheckIntervalâ, value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: âzwaveâ, hubHardwareId: device.hub.hardwareID, offlinePingable: â1â])
}
def updated() {
response(refresh())
}
def parse(description) {
def result = null
if (description.startsWith(âErr 106â)) {
result = createEvent(descriptionText: description, isStateChange: true)
} else if (description != âupdatedâ) {
def cmd = zwave.parse(description, [0x20: 1, 0x25: 1, 0x70: 1, 0x98: 1])
if (cmd) {
result = zwaveEvent(cmd)
log.debug("â$descriptionâ parsed to $result")
} else {
log.debug(âCouldnât zwave.parse â$descriptionââ)
}
}
result
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
createEvent(name: âswitchâ, value: cmd.value ? âonâ : âoffâ)
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
createEvent(name: âswitchâ, value: cmd.value ? âonâ : âoffâ)
}
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
createEvent(name: âswitchâ, value: cmd.value ? âonâ : âoffâ)
}
def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
createEvent(name: âhailâ, value: âhailâ, descriptionText: âSwitch button was pressedâ, displayed: false)
}
def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
def encapsulatedCommand = cmd.encapsulatedCommand([0x20: 1, 0x25: 1])
if (encapsulatedCommand) {
zwaveEvent(encapsulatedCommand)
}
}
def zwaveEvent(physicalgraph.zwave.Command cmd) {
log.debug âUnhandled: $cmdâ
null
}
def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
def value = âwhen offâ
if (cmd.configurationValue[0] == 1) {value = âwhen onâ}
if (cmd.configurationValue[0] == 2) {value = âneverâ}
[name: âindicatorStatusâ, value: value, displayed: false]
}
def on() {
commands([
zwave.basicV1.basicSet(value: 0xFF),
zwave.basicV1.basicGet()
])
}
def off() {
commands([
zwave.basicV1.basicSet(value: 0x00),
zwave.basicV1.basicGet()
])
}
def ping() {
refresh()
}
def poll() {
refresh()
}
def refresh() {
command(zwave.basicV1.basicGet())
}
private command(physicalgraph.zwave.Command cmd) {
if ((zwaveInfo.zw == null && state.sec != 0) || zwaveInfo?.zw?.contains(âsâ)) {
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
} else {
cmd.format()
}
}
private commands(commands, delay = 200) {
delayBetween(commands.collect { command(it) }, delay)
}
[/pre]