couple large and small basement light

This commit is contained in:
2018-05-24 22:43:55 +02:00
parent ab08986ca2
commit 27153262bc
6 changed files with 30 additions and 2 deletions

4
dist/AItem.js vendored
View File

@ -1,8 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
class AItem {
const Events = require("events");
class AItem extends Events.EventEmitter {
constructor(floor, room, item, label = '') {
super();
this.floor = floor;
this.room = room;
this.item = item;

View File

@ -10,6 +10,9 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
getStateFeedbackTopic() {
return this.stateFeedbackTopic;
}
getState() {
return this.state;
}
constructor(floor, room, item, label, hmId, partId = 1, type = 'bulb') {
super(floor, room, item, label, hmId);
this.partId = partId;
@ -29,6 +32,7 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
return Export_1.SwitchExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.type);
}
processMessage(topic, payload) {
this.emit('somethingChanged');
switch (topic) {
case this.stateTopic:
this.state = payload;

8
dist/main.js vendored
View File

@ -371,6 +371,14 @@ let basementLargeLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', '
basementLargeLight.start();
allLabeledItems.push(basementLargeLight);
allRelevantLights.push(basementLargeLight);
basementLargeLight.on('somethingChange', () => {
if (basementLargeLight.getState() == 'ON') {
MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'ON');
}
else if (basementLargeLight.getState() == 'OFF') {
MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'OFF');
}
});
// ----------------------------------------------------------------------------------------------------------
let twoLedSignal1 = new TwoLedSignal_1.TwoLedSignal('Gnd', 'Hallway', 'TwoLedSignal1', 'Licht- und Fenster-Anzeiger', allRelevantLights, "OFF", "ON", allWindows, "CLOSED", "OPEN");
twoLedSignal1.start();