remove state for switch actors
This commit is contained in:
5
dist/HomematicSwitchItem.js
vendored
5
dist/HomematicSwitchItem.js
vendored
@ -31,7 +31,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
this.deviceFeedbackTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
this.type = type;
|
||||
}
|
||||
exportItem() {
|
||||
@ -42,15 +41,12 @@ 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;
|
||||
}
|
||||
break;
|
||||
case this.deviceFeedbackTopic:
|
||||
if (payload == 'true') {
|
||||
@ -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;
|
||||
}
|
||||
|
4
dist/M433SwitchItem.js
vendored
4
dist/M433SwitchItem.js
vendored
@ -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,15 +36,12 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.M433SwitchItem = M433SwitchItem;
|
||||
|
@ -46,7 +46,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
this.deviceFeedbackTopic
|
||||
]
|
||||
this.state = 'OFF'
|
||||
this.oldState = undefined
|
||||
this.type = type
|
||||
}
|
||||
|
||||
@ -59,14 +58,11 @@ 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
|
||||
}
|
||||
break
|
||||
case this.deviceFeedbackTopic:
|
||||
if (payload == 'true') {
|
||||
@ -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
|
||||
}
|
||||
|
@ -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,14 +53,11 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user