mqtt: always send globally, always retain, thermostat und windowContact completed
This commit is contained in:
44
dist/UrlSwitchItem.js
vendored
Normal file
44
dist/UrlSwitchItem.js
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const AItem_1 = require("./AItem");
|
||||
const Export_1 = require("./Export");
|
||||
const http = require("http");
|
||||
class UrlSwitchItem extends AItem_1.AItem {
|
||||
getStateTopic() {
|
||||
return this.stateTopic;
|
||||
}
|
||||
getStateFeedbackTopic() {
|
||||
return this.stateFeedbackTopic;
|
||||
}
|
||||
constructor(floor, room, item, label, onUrl, offUrl, type = 'bulb') {
|
||||
super(floor, room, item, label);
|
||||
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.onUrl = onUrl;
|
||||
this.offUrl = offUrl;
|
||||
this.type = type;
|
||||
}
|
||||
exportItem() {
|
||||
return Export_1.SwitchExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.type);
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
this.state = payload;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state != this.oldState) {
|
||||
if (this.state == 'ON') {
|
||||
http.get(this.onUrl);
|
||||
}
|
||||
else {
|
||||
http.get(this.offUrl);
|
||||
}
|
||||
this.oldState = this.state;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.UrlSwitchItem = UrlSwitchItem;
|
||||
//# sourceMappingURL=UrlSwitchItem.js.map
|
Reference in New Issue
Block a user