typescriptifying
This commit is contained in:
32
dist/M433SwitchItem.js
vendored
Normal file
32
dist/M433SwitchItem.js
vendored
Normal 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
|
Reference in New Issue
Block a user