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

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