From 3c062a330de027264832bc19f1450e7ae0a44e02 Mon Sep 17 00:00:00 2001 From: Koenkk Date: Mon, 11 Jun 2018 20:31:05 +0200 Subject: [PATCH] Resend cached states on MQTT reconnect. #105 --- lib/controller.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/controller.js b/lib/controller.js index ea4ece494..c1e676a04 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -85,6 +85,13 @@ class Controller { } }); } + + // Resend all cached states. + this.zigbee.getAllClients().forEach((device) => { + if (this.stateCache.hasOwnProperty(device.ieeeAddr)) { + this.mqttPublishDeviceState(device.ieeeAddr, this.stateCache[device.ieeeAddr], false); + } + }); } softResetTimeout(start) {