"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