mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-04-06 06:13:07 +01:00
Z-Wave Lock: fix double updated() commands DVCSMP-1265
This commit is contained in:
@@ -68,15 +68,9 @@ import physicalgraph.zwave.commands.usercodev1.*
|
|||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
try {
|
try {
|
||||||
def cmds = []
|
if (!state.init) {
|
||||||
if (!device.currentState("lock")) {
|
state.init = true
|
||||||
cmds << zwave.doorLockV1.doorLockOperationGet()
|
response(secureSequence([zwave.doorLockV1.doorLockOperationGet(), zwave.batteryV1.batteryGet()]))
|
||||||
}
|
|
||||||
if (!device.currentState("battery")) {
|
|
||||||
cmds << zwave.batteryV1.batteryGet()
|
|
||||||
}
|
|
||||||
if (cmds) {
|
|
||||||
response(secureSequence(cmds))
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warn "updated() threw $e"
|
log.warn "updated() threw $e"
|
||||||
@@ -85,7 +79,7 @@ def updated() {
|
|||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
if (description.startsWith("Err")) {
|
if (description.startsWith("Err 106")) {
|
||||||
if (state.sec) {
|
if (state.sec) {
|
||||||
result = createEvent(descriptionText:description, displayed:false)
|
result = createEvent(descriptionText:description, displayed:false)
|
||||||
} else {
|
} else {
|
||||||
@@ -97,6 +91,8 @@ def parse(String description) {
|
|||||||
displayed: true,
|
displayed: true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else if (description == "updated") {
|
||||||
|
return null
|
||||||
} else {
|
} else {
|
||||||
def cmd = zwave.parse(description, [ 0x98: 1, 0x72: 2, 0x85: 2, 0x86: 1 ])
|
def cmd = zwave.parse(description, [ 0x98: 1, 0x72: 2, 0x85: 2, 0x86: 1 ])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
@@ -518,7 +514,6 @@ def refresh() {
|
|||||||
cmds << secure(zwave.associationV1.associationGet(groupingIdentifier:1))
|
cmds << secure(zwave.associationV1.associationGet(groupingIdentifier:1))
|
||||||
state.associationQuery = now()
|
state.associationQuery = now()
|
||||||
} else if (secondsPast(state.associationQuery, 9)) {
|
} else if (secondsPast(state.associationQuery, 9)) {
|
||||||
log.debug "setting association"
|
|
||||||
cmds << "delay 6000"
|
cmds << "delay 6000"
|
||||||
cmds << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId).format()
|
cmds << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId).format()
|
||||||
cmds << secure(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId))
|
cmds << secure(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId))
|
||||||
@@ -532,24 +527,14 @@ def refresh() {
|
|||||||
|
|
||||||
def poll() {
|
def poll() {
|
||||||
def cmds = []
|
def cmds = []
|
||||||
if (state.assoc != zwaveHubNodeId && secondsPast(state.associationQuery, 19 * 60)) {
|
// Only check lock state if it changed recently or we haven't had an update in an hour
|
||||||
log.debug "setting association"
|
def latest = device.currentState("lock")?.date?.time
|
||||||
cmds << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId).format()
|
if (!latest || !secondsPast(latest, 6 * 60) || secondsPast(state.lastPoll, 55 * 60)) {
|
||||||
cmds << secure(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId))
|
cmds << secure(zwave.doorLockV1.doorLockOperationGet())
|
||||||
cmds << zwave.associationV1.associationGet(groupingIdentifier:2).format()
|
state.lastPoll = now()
|
||||||
cmds << "delay 6000"
|
} else if (!state.lastbatt || now() - state.lastbatt > 53*60*60*1000) {
|
||||||
cmds << secure(zwave.associationV1.associationGet(groupingIdentifier:1))
|
cmds << secure(zwave.batteryV1.batteryGet())
|
||||||
cmds << "delay 6000"
|
state.lastbatt = now() //inside-214
|
||||||
state.associationQuery = now()
|
|
||||||
} else {
|
|
||||||
// Only check lock state if it changed recently or we haven't had an update in an hour
|
|
||||||
def latest = device.currentState("lock")?.date?.time
|
|
||||||
if (!latest || !secondsPast(latest, 6 * 60) || secondsPast(state.lastPoll, 55 * 60)) {
|
|
||||||
cmds << secure(zwave.doorLockV1.doorLockOperationGet())
|
|
||||||
state.lastPoll = now()
|
|
||||||
} else if (!state.lastbatt || now() - state.lastbatt > 53*60*60*1000) {
|
|
||||||
cmds << secure(zwave.batteryV1.batteryGet())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cmds) {
|
if (cmds) {
|
||||||
log.debug "poll is sending ${cmds.inspect()}"
|
log.debug "poll is sending ${cmds.inspect()}"
|
||||||
|
|||||||
Reference in New Issue
Block a user