From 17d59afb159e4e5f7d274fb52212a2896bf90ce4 Mon Sep 17 00:00:00 2001 From: Cameron <32912464+kiwi-cam@users.noreply.github.com> Date: Sun, 4 Jul 2021 08:13:56 +1200 Subject: [PATCH] Added allowResendOnOff --- base/accessory.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/base/accessory.js b/base/accessory.js index c9b8c522..f55e2ebb 100644 --- a/base/accessory.js +++ b/base/accessory.js @@ -49,6 +49,9 @@ class HomebridgeAccessory { this.config.allowResend = !this.config.preventResendHex; } } + if (this.config.allowResendOnOff === undefined) { + this.config.allowResendOnOff = true; + } } restoreStateOrder() { } @@ -100,7 +103,7 @@ class HomebridgeAccessory { const { config, host, log, name, logLevel } = this; try { - const { delay, resendDataAfterReload, allowResend } = config; + const { delay, resendDataAfterReload, allowResend, allowResendOnOff } = config; const { service, propertyName, onData, offData, setValuePromise, ignorePreviousValue } = props; const capitalizedPropertyName = propertyName.charAt(0).toUpperCase() + propertyName.slice(1); @@ -122,8 +125,9 @@ class HomebridgeAccessory { return; } + log(`${name} set${capitalizedPropertyName}: allowResendOnOff = ${allowResendOnOff} and propertyName = ${propertyName}`); if (!ignorePreviousValue && this.state[propertyName] == value && !this.isReloadingState) { - if (!allowResend) { + if (!allowResend && !(allowResendOnOff && propertyName == 'switchState') && !(allowResendOnOff && propertyName == 'active') ) { if (this.logLevel <= 3) {log(`${name} set${capitalizedPropertyName}: already ${value} (no data sent - B)`);} callback(null); @@ -267,7 +271,7 @@ class HomebridgeAccessory { this.mqttValues = {}; this.mqttValuesTemp = {}; - // Perform some validation of the mqttTopic option in the config. + // Perform some validation of the mqttTopic option in the config. if (typeof mqttTopic !== 'string' && !Array.isArray(mqttTopic)) { if (this.logLevel <= 4) {log(`\x1b[31m[CONFIG ERROR]\x1b[0m ${name} \x1b[33mmqttTopic\x1b[0m value is incorrect. Please check out the documentation for more details.`)}