Skip to content

Commit aab5644

Browse files
Push current state every 30 minutes
This will push the current state of all attributes every 30 minutes, so if the bridge was down, it will eventually recover to current state.
1 parent eaea735 commit aab5644

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ def initialize() {
475475

476476
// Update the bridge
477477
updateSubscription()
478+
// Auto-update every 30 minutes
479+
schedule("0 0/30 * * * ?", updateSubscription)
478480
}
479481

480482
// Update the bridge"s subscription
@@ -489,6 +491,12 @@ def updateSubscription() {
489491
}
490492
settings[key].each {device ->
491493
attributes[attribute].push(device.displayName)
494+
// Send current value
495+
inputHandler([
496+
displayName: device.displayName,
497+
value: device.currentState(attribute).value,
498+
name: attribute
499+
])
492500
}
493501
}
494502
}
@@ -500,7 +508,6 @@ def updateSubscription() {
500508
])
501509

502510
log.debug "Updating subscription: ${json}"
503-
504511
bridge.deviceNotification(json)
505512
}
506513

0 commit comments

Comments
 (0)