EcoSwitch

This commit is contained in:
Wolfgang Hottgenroth
2018-01-12 10:50:25 +01:00
parent 5eac6dfab6
commit c474d22265
6 changed files with 143 additions and 1 deletions

56
dist/MaxEcoSwitch.js vendored Normal file
View File

@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
class MaxEcoSwitch extends AHomematicItem_1.AHomematicItem {
constructor(floor, room, item, label, hmId, mainScene, ecoScene) {
super(floor, room, item, label, hmId);
this.buttonTopic1 = `${this.deviceTopicPre}/1/PRESS`;
this.buttonTopic2 = `${this.deviceTopicPre}/2/PRESS`;
this.subscribeTopics = [this.buttonTopic1, this.buttonTopic2];
this.mainTopic = mainScene.getStateTopic();
this.ecoTopic = ecoScene.getStateTopic();
this.state = 'OFF';
}
processMessage(topic, payload) {
switch (this.state) {
case 'OFF':
if (topic == this.mainTopic) {
this.state = 'ON';
}
else if (topic == this.ecoTopic) {
this.state = 'ECO';
}
break;
case 'ON':
if (topic == this.mainTopic) {
this.state = 'OFF';
}
else if (topic == this.ecoTopic) {
this.state = 'ECO';
}
break;
case 'ECO':
if (topic == this.mainTopic) {
this.state = 'ON';
}
else if (topic == this.ecoTopic) {
this.state = 'OFF';
}
break;
}
switch (this.state) {
case 'OFF':
MqttDispatcher_1.mqttHandler.send(this.mainTopic, 'OFF');
break;
case 'ON':
MqttDispatcher_1.mqttHandler.send(this.mainTopic, 'ON');
break;
case 'ECO':
MqttDispatcher_1.mqttHandler.send(this.ecoTopic, 'ON');
break;
}
}
}
exports.MaxEcoSwitch = MaxEcoSwitch;
//# sourceMappingURL=MaxEcoSwitch.js.map