couple large and small basement light
This commit is contained in:
4
dist/AItem.js
vendored
4
dist/AItem.js
vendored
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||||
class AItem {
|
const Events = require("events");
|
||||||
|
class AItem extends Events.EventEmitter {
|
||||||
constructor(floor, room, item, label = '') {
|
constructor(floor, room, item, label = '') {
|
||||||
|
super();
|
||||||
this.floor = floor;
|
this.floor = floor;
|
||||||
this.room = room;
|
this.room = room;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
4
dist/HomematicSwitchItem.js
vendored
4
dist/HomematicSwitchItem.js
vendored
@ -10,6 +10,9 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
|||||||
getStateFeedbackTopic() {
|
getStateFeedbackTopic() {
|
||||||
return this.stateFeedbackTopic;
|
return this.stateFeedbackTopic;
|
||||||
}
|
}
|
||||||
|
getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
constructor(floor, room, item, label, hmId, partId = 1, type = 'bulb') {
|
constructor(floor, room, item, label, hmId, partId = 1, type = 'bulb') {
|
||||||
super(floor, room, item, label, hmId);
|
super(floor, room, item, label, hmId);
|
||||||
this.partId = partId;
|
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);
|
return Export_1.SwitchExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.type);
|
||||||
}
|
}
|
||||||
processMessage(topic, payload) {
|
processMessage(topic, payload) {
|
||||||
|
this.emit('somethingChanged');
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case this.stateTopic:
|
case this.stateTopic:
|
||||||
this.state = payload;
|
this.state = payload;
|
||||||
|
8
dist/main.js
vendored
8
dist/main.js
vendored
@ -371,6 +371,14 @@ let basementLargeLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', '
|
|||||||
basementLargeLight.start();
|
basementLargeLight.start();
|
||||||
allLabeledItems.push(basementLargeLight);
|
allLabeledItems.push(basementLargeLight);
|
||||||
allRelevantLights.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");
|
let twoLedSignal1 = new TwoLedSignal_1.TwoLedSignal('Gnd', 'Hallway', 'TwoLedSignal1', 'Licht- und Fenster-Anzeiger', allRelevantLights, "OFF", "ON", allWindows, "CLOSED", "OPEN");
|
||||||
twoLedSignal1.start();
|
twoLedSignal1.start();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as logger from './log'
|
import * as logger from './log'
|
||||||
import { mqttHandler } from './MqttDispatcher'
|
import { mqttHandler } from './MqttDispatcher'
|
||||||
import { ExportType } from './Export'
|
import { ExportType } from './Export'
|
||||||
|
import * as Events from 'events'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ export interface HasInTopic {
|
|||||||
getInTopic() : string
|
getInTopic() : string
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class AItem {
|
export abstract class AItem extends Events.EventEmitter {
|
||||||
protected topicFirstPart: string
|
protected topicFirstPart: string
|
||||||
protected itemId: string
|
protected itemId: string
|
||||||
protected label: string
|
protected label: string
|
||||||
@ -31,6 +32,7 @@ export abstract class AItem {
|
|||||||
|
|
||||||
|
|
||||||
constructor(floor: string, room: string, item: string, label: string = '') {
|
constructor(floor: string, room: string, item: string, label: string = '') {
|
||||||
|
super()
|
||||||
this.floor = floor
|
this.floor = floor
|
||||||
this.room = room
|
this.room = room
|
||||||
this.item = item
|
this.item = item
|
||||||
|
@ -22,6 +22,10 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
|||||||
return this.stateFeedbackTopic
|
return this.stateFeedbackTopic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getState() : string {
|
||||||
|
return this.state
|
||||||
|
}
|
||||||
|
|
||||||
constructor(floor: string, room: string, item: string, label: string, hmId: number, partId: number = 1, type: string = 'bulb') {
|
constructor(floor: string, room: string, item: string, label: string, hmId: number, partId: number = 1, type: string = 'bulb') {
|
||||||
super(floor, room, item, label, hmId)
|
super(floor, room, item, label, hmId)
|
||||||
this.partId = partId
|
this.partId = partId
|
||||||
@ -43,6 +47,7 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
|||||||
}
|
}
|
||||||
|
|
||||||
processMessage(topic: string, payload: string) : void {
|
processMessage(topic: string, payload: string) : void {
|
||||||
|
this.emit('somethingChanged')
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case this.stateTopic:
|
case this.stateTopic:
|
||||||
this.state = payload
|
this.state = payload
|
||||||
|
@ -463,6 +463,13 @@ let basementLargeLight = new HomematicSwitchItem('Base', 'Hallway', 'LargeLight'
|
|||||||
basementLargeLight.start()
|
basementLargeLight.start()
|
||||||
allLabeledItems.push(basementLargeLight)
|
allLabeledItems.push(basementLargeLight)
|
||||||
allRelevantLights.push(basementLargeLight)
|
allRelevantLights.push(basementLargeLight)
|
||||||
|
basementLargeLight.on('somethingChange', () => {
|
||||||
|
if (basementLargeLight.getState() == 'ON') {
|
||||||
|
mqttHandler.send(basementSmallLight.getStateTopic(), 'ON')
|
||||||
|
} else if (basementLargeLight.getState() == 'OFF') {
|
||||||
|
mqttHandler.send(basementSmallLight.getStateTopic(), 'OFF')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user