diff --git a/dist/HomematicSwitchItem.js b/dist/HomematicSwitchItem.js index 6c669d6..0ce7605 100644 --- a/dist/HomematicSwitchItem.js +++ b/dist/HomematicSwitchItem.js @@ -31,7 +31,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem { this.deviceFeedbackTopic ]; this.state = 'OFF'; - this.oldState = undefined; this.type = type; } exportItem() { @@ -42,14 +41,11 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem { case this.stateTopic: this.state = payload; MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state); - if (this.state != this.oldState) { - if (this.state == 'ON') { - MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true'); - } - else { - MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false'); - } - this.oldState = this.state; + if (this.state == 'ON') { + MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true'); + } + else { + MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false'); } break; case this.deviceFeedbackTopic: @@ -59,7 +55,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem { else { this.state = 'OFF'; } - this.oldState = this.state; MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state); break; } diff --git a/dist/M433SwitchItem.js b/dist/M433SwitchItem.js index 76c9860..848a10b 100644 --- a/dist/M433SwitchItem.js +++ b/dist/M433SwitchItem.js @@ -26,7 +26,6 @@ class M433SwitchItem extends AItem_1.AItem { this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`; this.actionTopic = 'IoT/Mqtt433Gateway/Message'; this.state = 'OFF'; - this.oldState = undefined; this.onCode = onCode; this.offCode = offCode; this.type = type; @@ -37,14 +36,11 @@ class M433SwitchItem extends AItem_1.AItem { processMessage(topic, payload) { this.state = payload; MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state); - if (this.state != this.oldState) { - if (this.state == 'ON') { - MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.onCode); - } - else { - MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.offCode); - } - this.oldState = this.state; + if (this.state == 'ON') { + MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.onCode); + } + else { + MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.offCode); } } } diff --git a/src/HomematicSwitchItem.ts b/src/HomematicSwitchItem.ts index 0b5687b..d90a1c1 100644 --- a/src/HomematicSwitchItem.ts +++ b/src/HomematicSwitchItem.ts @@ -46,7 +46,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee this.deviceFeedbackTopic ] this.state = 'OFF' - this.oldState = undefined this.type = type } @@ -59,13 +58,10 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee case this.stateTopic: this.state = payload mqttHandler.send(this.stateFeedbackTopic, this.state) - if (this.state != this.oldState) { - if (this.state == 'ON') { - mqttHandler.send(this.actionTopic, 'true') - } else { - mqttHandler.send(this.actionTopic, 'false') - } - this.oldState = this.state + if (this.state == 'ON') { + mqttHandler.send(this.actionTopic, 'true') + } else { + mqttHandler.send(this.actionTopic, 'false') } break case this.deviceFeedbackTopic: @@ -74,7 +70,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee } else { this.state = 'OFF' } - this.oldState = this.state mqttHandler.send(this.stateFeedbackTopic, this.state) break } diff --git a/src/M433SwitchItem.ts b/src/M433SwitchItem.ts index f73d3d4..3c1c66c 100644 --- a/src/M433SwitchItem.ts +++ b/src/M433SwitchItem.ts @@ -41,7 +41,6 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback` this.actionTopic = 'IoT/Mqtt433Gateway/Message' this.state = 'OFF' - this.oldState = undefined this.onCode = onCode this.offCode = offCode this.type = type @@ -54,13 +53,10 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd processMessage(topic: string, payload: string) { this.state = payload; mqttHandler.send(this.stateFeedbackTopic, this.state); - if (this.state != this.oldState) { - if (this.state == 'ON') { - mqttHandler.send(this.actionTopic, this.onCode); - } else { - mqttHandler.send(this.actionTopic, this.offCode); - } - this.oldState = this.state; + if (this.state == 'ON') { + mqttHandler.send(this.actionTopic, this.onCode); + } else { + mqttHandler.send(this.actionTopic, this.offCode); } } }