remove state for switch actors

This commit is contained in:
2018-09-21 13:38:11 +02:00
parent 3dc256f960
commit f98b1c2f39
4 changed files with 18 additions and 36 deletions

View File

@ -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);
}
}
}