typescriptifying completed
This commit is contained in:
48
dist/HomematicSwitchItem.js
vendored
Normal file
48
dist/HomematicSwitchItem.js
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const AHomematicItem_1 = require("./AHomematicItem");
|
||||
class HomematicSwitchItem extends AHomematicItem_1.AHomematicItem {
|
||||
constructor(floor, room, item, hmId) {
|
||||
super(floor, room, item, hmId);
|
||||
this.stateTopic = `${this.topicFirstPart}/state`;
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||
this.deviceFeedbackTopic = `${this.deviceTopicPre}/1/STATE`;
|
||||
this.actionTopic = `${this.actionTopicPre}/1/STATE`;
|
||||
this.subscribeTopics = [
|
||||
this.stateTopic,
|
||||
this.deviceFeedbackTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
switch (topic) {
|
||||
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') {
|
||||
this.state = 'ON';
|
||||
}
|
||||
else {
|
||||
this.state = 'OFF';
|
||||
}
|
||||
this.oldState = this.state;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.HomematicSwitchItem = HomematicSwitchItem;
|
||||
//# sourceMappingURL=HomematicSwitchItem.js.map
|
Reference in New Issue
Block a user