56 lines
2.0 KiB
JavaScript
56 lines
2.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const MqttDispatcher_1 = require("./MqttDispatcher");
|
|
const AHomegearItem_1 = require("./AHomegearItem");
|
|
class MaxEcoSwitch extends AHomegearItem_1.AHomegearItem {
|
|
constructor(floor, room, item, label, hmId, mainScene, ecoScene) {
|
|
super(floor, room, item, label, hmId);
|
|
this.mainButtonTopic = `${this.deviceTopicPre}/1/PRESS`;
|
|
this.ecoButtonTopic = `${this.deviceTopicPre}/2/PRESS`;
|
|
this.subscribeTopics = [this.mainButtonTopic, this.ecoButtonTopic];
|
|
this.mainTopic = mainScene.getStateTopic();
|
|
this.ecoTopic = ecoScene.getStateTopic();
|
|
this.state = 'OFF';
|
|
}
|
|
processMessage(topic, payload) {
|
|
switch (this.state) {
|
|
case 'OFF':
|
|
if (topic == this.mainButtonTopic) {
|
|
this.state = 'ON';
|
|
}
|
|
else if (topic == this.ecoButtonTopic) {
|
|
this.state = 'ECO';
|
|
}
|
|
break;
|
|
case 'ON':
|
|
if (topic == this.mainButtonTopic) {
|
|
this.state = 'OFF';
|
|
}
|
|
else if (topic == this.ecoButtonTopic) {
|
|
this.state = 'ECO';
|
|
}
|
|
break;
|
|
case 'ECO':
|
|
if (topic == this.mainButtonTopic) {
|
|
this.state = 'ON';
|
|
}
|
|
else if (topic == this.ecoButtonTopic) {
|
|
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
|