Skip to content

Commit

Permalink
ICP-4607 Add initial polling to ZWave motion sensor (SmartThingsCommu…
Browse files Browse the repository at this point in the history
…nity#3006)

* ICP-4607 Add initial polling to Z-Wave motion sensor
  • Loading branch information
greens authored Apr 16, 2018
1 parent f36aa74 commit 165088c
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ metadata {
def installed() {
// Device wakes up every 4 hours, this interval allows us to miss one wakeup notification before marking offline
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
response(initialPoll())
}

def updated() {
Expand Down Expand Up @@ -246,3 +247,25 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerS
result << createEvent(descriptionText: "$device.displayName MSR: $msr", isStateChange: false)
result
}

def initialPoll() {
def request = []
request << zwave.batteryV1.batteryGet()
request << zwave.sensorBinaryV2.sensorBinaryGet(sensorType: 0x0C) //motion
commands(request) + ["delay 20000", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]
}

private commands(commands, delay=200) {
log.info "sending commands: ${commands}"
delayBetween(commands.collect{ command(it) }, delay)
}

private command(physicalgraph.zwave.Command cmd) {
if (zwaveInfo && zwaveInfo.zw?.contains("s")) {
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
} else if (zwaveInfo && zwaveInfo.cc?.contains("56")){
zwave.crc16EncapV1.crc16Encap().encapsulate(cmd).format()
} else {
cmd.format()
}
}

0 comments on commit 165088c

Please sign in to comment.