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

6
dist/Scene.js vendored
View File

@ -4,6 +4,12 @@ const AItem_1 = require("./AItem");
const MqttDispatcher_1 = require("./MqttDispatcher");
const Export_1 = require("./Export");
class LightScene extends AItem_1.AItem {
getStateTopic() {
return this.stateTopic;
}
getStateFeedbackTopic() {
return this.stateFeedbackTopic;
}
constructor(floor, room, item, label = '', onItems, offItems) {
super(floor, room, item, label);
this.onItems = onItems;

3
dist/main.js vendored
View File

@ -12,6 +12,7 @@ const HomematicDimmerItem_1 = require("./HomematicDimmerItem");
const HomematicSwitchItem_1 = require("./HomematicSwitchItem");
const Forwarder_1 = require("./Forwarder");
const Scene_1 = require("./Scene");
const MaxEcoSwitch_1 = require("./MaxEcoSwitch");
logger.info("Dispatcher starting");
let allLabeledItems = new Array();
// Anna -----------------------------------------------------------------------------------------------------
@ -119,6 +120,8 @@ let ecoLightScene = new Scene_1.LightScene('Gnd', 'Hallway', 'EcoLight', 'EcoLig
]);
ecoLightScene.start();
allLabeledItems.push(ecoLightScene);
let ecoSwitch = new MaxEcoSwitch_1.MaxEcoSwitch('Gnd', 'Hallway', 'EcoSwitch', 'EcoSwitch', 5, dayLightScene, ecoLightScene);
ecoSwitch.start();
let morningLightScene = new Scene_1.LightScene('Gnd', 'Hallway', 'MorningLight', 'MorningLight', [
kitchenWindowLight, kitchenCeilingLight, hallwayDeskLight, hallwayWardrobeLight,
hallwayStandLight