typescriptifying

This commit is contained in:
Wolfgang Hottgenroth
2018-01-09 16:36:14 +01:00
parent 9e39d74084
commit 8d85314fc9
21 changed files with 372 additions and 182 deletions

32
dist/M433SwitchItem.js vendored Normal file
View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AItem_1 = require("./AItem");
class M433SwitchItem extends AItem_1.AItem {
constructor(floor, room, item, onCode, offCode) {
super(floor, room, item);
this.stateTopic = `${this.topicFirstPart}/state`;
this.subscribeTopics = [this.stateTopic];
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
this.actionTopic = 'IoT/Mqtt433Gateway/Message';
this.state = 'OFF';
this.oldState = undefined;
this.onCode = onCode;
this.offCode = offCode;
}
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;
//# sourceMappingURL=M433SwitchItem.js.map