Files
dispatcher_ng/dist/main.js

177 lines
11 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const config = require("./config");
const logger = require("./log");
const MqttDispatcher_1 = require("./MqttDispatcher");
const M433SwitchItem_1 = require("./M433SwitchItem");
const HomematicFourButtonThing_1 = require("./HomematicFourButtonThing");
const DimmerAdaptor_1 = require("./DimmerAdaptor");
const TimerAdaptor_1 = require("./TimerAdaptor");
const HomematicDimmerItem_1 = require("./HomematicDimmerItem");
const HomematicSwitchItem_1 = require("./HomematicSwitchItem");
const Forwarder_1 = require("./Forwarder");
logger.info("Dispatcher starting");
let allLabeledItems = new Array();
// Anna -----------------------------------------------------------------------------------------------------
// Anna Aquarium 14665044 24 1 14665041 24 1
let aquariumLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Anna', 'AquariumLight', 'Aquariumlicht', '14665044 24 1', '14665041 24 1');
aquariumLight.start();
allLabeledItems.push(aquariumLight);
// Anna Bett 14668116 24 1 14668113 24 1
let annaBedLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Anna', 'BedLight', 'Bettlicht Anna', '14668116 24 1', '14668113 24 1');
annaBedLight.start();
allLabeledItems.push(annaBedLight);
// Matthias -------------------------------------------------------------------------------------------------
// Matthias Stehlampen 7 24 1 6 24 1
let matthiasStandLights = new M433SwitchItem_1.M433SwitchItem('1st', 'Matthias', 'Stehlampen Matthias', 'StandLight', '7 24 1', '6 24 1');
matthiasStandLights.start();
allLabeledItems.push(matthiasStandLights);
// Matthias Bett 15 24 1 14 24 1
let matthiasBedLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Matthias', 'BedLight', 'Bettlicht Matthias', '15 24 1', '14 24 1');
matthiasBedLight.start();
allLabeledItems.push(matthiasBedLight);
// Matthias Lautsprecher 11 24 1 10 24 1
let matthiasSpeaker = new M433SwitchItem_1.M433SwitchItem('1st', 'Matthias', 'Speaker', 'Lautsprecher Matthias', '11 24 1', '10 24 1', 'outlet');
matthiasSpeaker.start();
allLabeledItems.push(matthiasSpeaker);
// Esszimmer ------------------------------------------------------------------------------------------------
// Esszimmer kleine Lampe 69653 24 1 69652 24 1
let diningRoomSmallLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'DiningRoom', 'SmallLight', 'kleine Lampe Esszimmer', '69653 24 1', '69652 24 1');
diningRoomSmallLight.start();
allLabeledItems.push(diningRoomSmallLight);
// Esszimmer Stehlampe 86037 24 1 86036 24 1
let diningRoomStandLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'DiningRoom', 'StandLight', 'Stehlampe Esszimmer', '86037 24 1', '86036 24 1');
diningRoomStandLight.start();
allLabeledItems.push(diningRoomStandLight);
// Esszimmer Schranklicht 65813 24 1 65812 24 1
let diningRoomCupboardLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'DiningRoom', 'CupboardLight', 'Schranklicht Esszimmer', '65813 24 1', '65812 24 1');
diningRoomCupboardLight.start();
allLabeledItems.push(diningRoomCupboardLight);
// Wohnzimmer -----------------------------------------------------------------------------------------------
// Wohnzimmer grosse Lampe 65557 24 1 65556 24 1
let livingRoomLargeLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'LivingRoom', 'LargeLight', 'große Lampe Wohnzimmer', '65557 24 1', '65556 24 1');
livingRoomLargeLight.start();
allLabeledItems.push(livingRoomLargeLight);
// Wohnzimmer kleine Lampe 87061 24 1 87060 24 1
let livingRoomSmallLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'LivingRoom', 'SmallLight', 'kleine Lampe Wohnzimmer', '87061 24 1', '87060 24 1');
livingRoomSmallLight.start();
allLabeledItems.push(livingRoomSmallLight);
// Wohnzimmer Sterne 69909 24 1 69908 24 1
let livingRoomStars = new M433SwitchItem_1.M433SwitchItem('Gnd', 'LivingRoom', 'Stars', 'Sterne Wohnzimmer', '69909 24 1', '69908 24 1');
livingRoomStars.start();
allLabeledItems.push(livingRoomStars);
// Wohnzimmer kleine Stehlampe 81941 24 1 81940 24 1
let livingRoomStandLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'LivingRoom', 'StandLight', 'Stehlampe Wohnzimmer', '81941 24 1', '81940 24 1');
livingRoomStandLight.start();
allLabeledItems.push(livingRoomStandLight);
// Flur -----------------------------------------------------------------------------------------------------
// Flur Schreibtisch 83221 24 1 83220 24 1
let hallwayDeskLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Hallway', 'DeskLight', 'Schreibtischlampe Flur', '83221 24 1', '83220 24 1');
hallwayDeskLight.start();
allLabeledItems.push(hallwayDeskLight);
// Flur Stehlampe 8704914 24 5 8793154 24 5
let hallwayStandLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Hallway', 'StandLight', 'Stehlampe Flur', '8704914 24 5', '8793154 24 5');
hallwayStandLight.start();
allLabeledItems.push(hallwayStandLight);
// Flur Schranklicht 66581 24 1 66580 24 1
let hallwayWardrobeLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Hallway', 'WardrobeLight', 'Schranklicht Flur', '66581 24 1', '66580 24 1');
hallwayWardrobeLight.start();
allLabeledItems.push(hallwayWardrobeLight);
// Küche ----------------------------------------------------------------------------------------------------
// Küche Fensterbank 66837 24 1 66836 24 1
let kitchenWindowLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Kitchen', 'WindowLight', 'Fensterbanklicht Küche', '66837 24 1', '66836 24 1');
kitchenWindowLight.start();
allLabeledItems.push(kitchenWindowLight);
// Küche Deckenlampe 82197 24 1 82196 24 1
let kitchenCeilingLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Kitchen', 'CeilingLight', 'Deckenlampe Küche', '82197 24 1', '82196 24 1');
kitchenCeilingLight.start();
allLabeledItems.push(kitchenCeilingLight);
// Schlafzimmer ---------------------------------------------------------------------------------------------
// Schlafzimmer Wolfgangs Seite 13976916 24 1 13976913 24 1
let bedRoomWolfgangsSide = new M433SwitchItem_1.M433SwitchItem('1st', 'BedRoom', 'WolfgangsSide', 'Wolfgangs Seite Schlafzimmer', '13976916 24 1', '13976913 24 1');
bedRoomWolfgangsSide.start();
allLabeledItems.push(bedRoomWolfgangsSide);
// Schlafzimmer Pattys Seite 13980756 24 1 13980753 24 1
let bedRoomPattysSide = new M433SwitchItem_1.M433SwitchItem('1st', 'BedRoom', 'PattysSide', 'Pattys Seite Schlafzimmer', '13980756 24 1', '13980753 24 1');
bedRoomPattysSide.start();
allLabeledItems.push(bedRoomPattysSide);
// Schlafzimmer Fensterbank 13979988 24 1 13979985 24 1
let bedRoomWindowLight = new M433SwitchItem_1.M433SwitchItem('1st', 'BedRoom', 'WindowLight', 'Fensterbanklicht Schlafzimmer', '13979988 24 1', '13979985 24 1');
bedRoomWindowLight.start();
allLabeledItems.push(bedRoomWindowLight);
// ---------------------------------------------------------------------------------------------------------
let morningLightForwarder = new Forwarder_1.Forwarder('Gnd', 'Hallway', 'MorningLight', 'state', 'MorningLight', [
kitchenWindowLight.stateTopic,
kitchenCeilingLight.stateTopic,
hallwayDeskLight.stateTopic,
hallwayStandLight.stateTopic,
hallwayWardrobeLight.stateTopic
]);
morningLightForwarder.start();
let dayLightForwarder = new Forwarder_1.Forwarder('Gnd', 'Hallway', 'DayLight', 'state', 'DayLight', [
kitchenWindowLight.stateTopic,
kitchenCeilingLight.stateTopic,
hallwayDeskLight.stateTopic,
hallwayStandLight.stateTopic,
hallwayWardrobeLight.stateTopic,
diningRoomSmallLight.stateTopic,
diningRoomStandLight.stateTopic,
diningRoomCupboardLight.stateTopic,
livingRoomLargeLight.stateTopic,
livingRoomSmallLight.stateTopic,
livingRoomStars.stateTopic,
livingRoomStandLight.stateTopic
]);
dayLightForwarder.start();
let ecoLightForwarder = new Forwarder_1.Forwarder('Gnd', 'Hallway', 'EcoLight', 'state', 'EcoLight', [
kitchenWindowLight.stateTopic,
hallwayDeskLight.stateTopic,
hallwayWardrobeLight.stateTopic,
diningRoomSmallLight.stateTopic,
diningRoomStandLight.stateTopic,
diningRoomCupboardLight.stateTopic,
livingRoomStars.stateTopic,
livingRoomStandLight.stateTopic
]);
ecoLightForwarder.start();
// ----------------------------------------------------------------------------------------------------------
let testFourButton = new HomematicFourButtonThing_1.HomematicFourButtonThing('Gnd', 'Hallway', 'TestButton', 9, [
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Hallway/Testlight/dimmerIn'),
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Hallway/DeskLight/timerIn'),
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/3'),
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/4')
]);
testFourButton.start();
let testDimmerAdaptor = new DimmerAdaptor_1.DimmerAdaptor('Gnd', 'Hallway', 'Testlight');
testDimmerAdaptor.start();
let testTimerAdaptor = new TimerAdaptor_1.TimerAdaptor('Gnd', 'Hallway', 'DeskLight', 10);
testTimerAdaptor.start();
let testLight = new HomematicDimmerItem_1.HomematicDimmerItem('Gnd', 'Hallway', 'Testlight', 'Testlampe mit Dimmer', 8);
testLight.start();
let testLight2 = new HomematicSwitchItem_1.HomematicSwitchItem('Gnd', 'Hallway', 'Testlight2', 'Testlampe ohne Dimmer', 5);
testLight2.start();
let testForwarder = new Forwarder_1.Forwarder('Gnd', 'Hallway', 'TestForwarder', 'state', 'TestForwarder', [
'dispatcher_ng/items/Gnd/Hallway/Testlight2/state',
'dispatcher_ng/items/Gnd/Hallway/DeskLight/state'
]);
testForwarder.start();
// ----------------------------------------------------------------------------------------------------------
// Homekit export
let homekitObject = {};
let openhabList = [];
allLabeledItems.forEach((item) => {
let exportData = item.exportItem();
if (exportData != null) {
if ('id' in exportData['homekit']) {
homekitObject[exportData['homekit']['id']] = exportData['homekit']['object'];
}
openhabList.push(exportData['openhab']);
}
});
fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4));
fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n'));
// ----------------------------------------------------------------------------------------------------------
MqttDispatcher_1.mqttHandler.exec();
logger.info("Dispatcher running");
//# sourceMappingURL=main.js.map