Skip to content

Commit

Permalink
Added allowResendOnOff
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwi-cam authored Jul 3, 2021
1 parent fead1e4 commit 17d59af
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions base/accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class HomebridgeAccessory {
this.config.allowResend = !this.config.preventResendHex;
}
}
if (this.config.allowResendOnOff === undefined) {
this.config.allowResendOnOff = true;
}
}

restoreStateOrder() { }
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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.`)}

Expand Down

0 comments on commit 17d59af

Please sign in to comment.