EcoSwitch
This commit is contained in:
56
dist/MaxEcoSwitch.js
vendored
Normal file
56
dist/MaxEcoSwitch.js
vendored
Normal 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
6
dist/Scene.js
vendored
@ -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
3
dist/main.js
vendored
@ -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
|
||||
|
Reference in New Issue
Block a user