"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 SwitchOffAdaptor_1 = require("./SwitchOffAdaptor"); 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"); const MaxThermostat_1 = require("./MaxThermostat"); const MaxWindowContact_1 = require("./MaxWindowContact"); const UrlSwitchItem_1 = require("./UrlSwitchItem"); const Cron_1 = require("./Cron"); const HueColorBulbItem_1 = require("./HueColorBulbItem"); const TouchSwitchMultiButtonThing_1 = require("./TouchSwitchMultiButtonThing"); const RelayBox_1 = require("./RelayBox"); const HeatingScene_1 = require("./HeatingScene"); const TwoLedSignal_1 = require("./TwoLedSignal"); const MySwitchThing_1 = require("./MySwitchThing"); logger.info("Dispatcher starting"); let allLabeledItems = new Array(); let allThermostatItems = new Array(); let allWindows = new Array(); let allRelevantLights = new Array(); let allLights = new Array(); let allLightScenes = new Array(); // Anna ----------------------------------------------------------------------------------------------------- // Anna Aquarium 14665044 24 1 14665041 24 1 let aquariumLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Anna', 'AquariumLight', 'Aquarium', '14665044 24 1', '14665041 24 1'); aquariumLight.start(); allLabeledItems.push(aquariumLight); let aquariumLightCron = new Cron_1.Cron('aquariumLightCron', aquariumLight, [ { cronTime: '00 00 07 * * 1-5', output: 'ON' }, { cronTime: '00 00 09 * * 6,0', output: 'ON' }, { cronTime: '00 00 13 * * *', output: 'OFF' }, { cronTime: '00 00 14 * * *', output: 'ON' }, { cronTime: '00 00 22 * * *', output: 'OFF' } ]); aquariumLightCron.start(); // Anna Bett 14668116 24 1 14668113 24 1 let annaBedLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Anna', 'BedLight', 'Bettlicht', '14668116 24 1', '14668113 24 1'); annaBedLight.start(); allLabeledItems.push(annaBedLight); allRelevantLights.push(annaBedLight); allLights.push(annaBedLight); let windowContactAnna1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Anna', 'WindowContact', 'Anna', 20); windowContactAnna1st.start(); allLabeledItems.push(windowContactAnna1st); allWindows.push(windowContactAnna1st); let thermostatAnna1st = new MaxThermostat_1.MaxThermostat('1st', 'Anna', 'Thermostat', 'Thermostat Anna', 21, [windowContactAnna1st]); thermostatAnna1st.start(); thermostatAnna1st.setPresetTemperature(21.0); allLabeledItems.push(thermostatAnna1st); allThermostatItems.push(thermostatAnna1st); let thermostatAnna1stCron = new Cron_1.Cron('thermostatAnna1stCron', thermostatAnna1st, [ { cronTime: '00 05 06 * * *', output: 'ON' }, { cronTime: '00 05 08 * * 1-5', output: 'OFF' }, { cronTime: '00 05 16 * * 1', output: 'ON' }, { cronTime: '00 05 14 * * 2', output: 'ON' }, { cronTime: '00 05 14 * * 3', output: 'ON' }, { cronTime: '00 05 16 * * 4', output: 'ON' }, { cronTime: '00 05 14 * * 5', output: 'ON' }, { cronTime: '00 58 23 * * *', output: 'OFF' } ]); thermostatAnna1stCron.start(); // Matthias ------------------------------------------------------------------------------------------------- // Matthias Stehlampen 7 24 1 6 24 1 let matthiasStandLights = new M433SwitchItem_1.M433SwitchItem('1st', 'Matthias', 'StandLight', 'Stehlampen', '7 24 1', '6 24 1'); matthiasStandLights.start(); allLabeledItems.push(matthiasStandLights); allRelevantLights.push(matthiasStandLights); allLights.push(matthiasStandLights); // Matthias Bett 15 24 1 14 24 1 let matthiasBedLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Matthias', 'BedLight', 'Bettlicht', '15 24 1', '14 24 1'); matthiasBedLight.start(); allLabeledItems.push(matthiasBedLight); allRelevantLights.push(matthiasBedLight); allLights.push(matthiasBedLight); // Matthias Lautsprecher 11 24 1 10 24 1 let matthiasSpeaker = new M433SwitchItem_1.M433SwitchItem('1st', 'Matthias', 'Speaker', 'Lautsprecher', '11 24 1', '10 24 1', 'outlet'); matthiasSpeaker.start(); allLabeledItems.push(matthiasSpeaker); allRelevantLights.push(matthiasSpeaker); allLights.push(matthiasSpeaker); let windowContactMatthias = new MaxWindowContact_1.MaxWindowContact('1st', 'Matthias', 'WindowContact', 'Matthias', 24); windowContactMatthias.start(); allLabeledItems.push(windowContactMatthias); allWindows.push(windowContactMatthias); // Esszimmer ------------------------------------------------------------------------------------------------ // Esszimmer kleine Lampe 69653 24 1 69652 24 1 let diningRoomSmallLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Esszimmer', 'SmallLight', 'kleine Lampe', '69653 24 1', '69652 24 1'); diningRoomSmallLight.start(); allLabeledItems.push(diningRoomSmallLight); allRelevantLights.push(diningRoomSmallLight); allLights.push(diningRoomSmallLight); // Esszimmer Stehlampe 86037 24 1 86036 24 1 let diningRoomStandLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Esszimmer', 'StandLight', 'Stehlampe', '86037 24 1', '86036 24 1'); diningRoomStandLight.start(); allLabeledItems.push(diningRoomStandLight); allRelevantLights.push(diningRoomStandLight); allLights.push(diningRoomStandLight); // Esszimmer Schranklicht 65813 24 1 65812 24 1 let diningRoomCupboardLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Esszimmer', 'CupboardLight', 'Schranklicht', '65813 24 1', '65812 24 1'); diningRoomCupboardLight.start(); allLabeledItems.push(diningRoomCupboardLight); allRelevantLights.push(diningRoomCupboardLight); allLights.push(diningRoomCupboardLight); // Esszimmer Regallicht let diningRoomShelfLight = new UrlSwitchItem_1.UrlSwitchItem('Gnd', 'Esszimmer', 'ShelfLight', 'Regallicht', 'http://172.16.2.43/dv?dv=1023', 'http://172.16.2.43/dv?dv=0'); // diningRoomShelfLight.start() // allLabeledItems.push(diningRoomShelfLight) // allRelevantLights.push(diningRoomShelfLight) let diningRoomNaehkaestchenLight = new HueColorBulbItem_1.HueColorBulbItem('Gnd', 'Esszimmer', 'NaehkaestchenLight', 'Nähkästchen', 15); diningRoomNaehkaestchenLight.start(); allLabeledItems.push(diningRoomNaehkaestchenLight); allRelevantLights.push(diningRoomNaehkaestchenLight); allLights.push(diningRoomNaehkaestchenLight); let windowContactDiningRoom1 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Esszimmer', 'WindowContact1', 'Essz. links', 26); windowContactDiningRoom1.start(); allLabeledItems.push(windowContactDiningRoom1); allWindows.push(windowContactDiningRoom1); let windowContactDiningRoom2 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Esszimmer', 'WindowContact2', 'Essz. rechts', 27); windowContactDiningRoom2.start(); allLabeledItems.push(windowContactDiningRoom2); allWindows.push(windowContactDiningRoom2); let thermostatDiningRoom = new MaxThermostat_1.MaxThermostat('Gnd', 'Esszimmer', 'Thermostat', 'Thermostat Esszimmer', 31, [windowContactDiningRoom1, windowContactDiningRoom2]); thermostatDiningRoom.start(); thermostatDiningRoom.setPresetTemperature(21.0); allLabeledItems.push(thermostatDiningRoom); allThermostatItems.push(thermostatDiningRoom); // Wohnzimmer ----------------------------------------------------------------------------------------------- // Wohnzimmer grosse Lampe 65557 24 1 65556 24 1 let livingRoomLargeLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Wohnzimmer', 'LargeLight', 'große Lampe', '65557 24 1', '65556 24 1'); livingRoomLargeLight.start(); allLabeledItems.push(livingRoomLargeLight); allRelevantLights.push(livingRoomLargeLight); allLights.push(livingRoomLargeLight); // Wohnzimmer kleine Lampe 87061 24 1 87060 24 1 let livingRoomSmallLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Wohnzimmer', 'SmallLight', 'kleine Lampe', '87061 24 1', '87060 24 1'); livingRoomSmallLight.start(); allLabeledItems.push(livingRoomSmallLight); allRelevantLights.push(livingRoomSmallLight); allLights.push(livingRoomSmallLight); // Wohnzimmer Sterne 69909 24 1 69908 24 1 let livingRoomStars = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Wohnzimmer', 'Stars', 'Sterne', '69909 24 1', '69908 24 1'); livingRoomStars.start(); allLabeledItems.push(livingRoomStars); allRelevantLights.push(livingRoomStars); allLights.push(livingRoomStars); // Wohnzimmer kleine Stehlampe 81941 24 1 81940 24 1 let livingRoomStandLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Wohnzimmer', 'StandLight', 'Stehlampe', '81941 24 1', '81940 24 1'); livingRoomStandLight.start(); allLabeledItems.push(livingRoomStandLight); allRelevantLights.push(livingRoomStandLight); allLights.push(livingRoomStandLight); let windowContactLivingRoom1 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Wohnzimmer', 'WindowContact1', 'Wohnz. rechts', 28); windowContactLivingRoom1.start(); allLabeledItems.push(windowContactLivingRoom1); allWindows.push(windowContactLivingRoom1); let windowContactLivingRoom2 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Wohnzimmer', 'WindowContact2', 'Wohnz. links', 29); windowContactLivingRoom2.start(); allLabeledItems.push(windowContactLivingRoom2); allWindows.push(windowContactLivingRoom2); let thermostatLivingRoom = new MaxThermostat_1.MaxThermostat('Gnd', 'Wohnzimmer', 'Thermostat', 'Thermostat Wohnzimmer', 30, [windowContactLivingRoom1, windowContactLivingRoom2]); thermostatLivingRoom.start(); thermostatLivingRoom.setPresetTemperature(21.0); allLabeledItems.push(thermostatLivingRoom); allThermostatItems.push(thermostatLivingRoom); // Flur ----------------------------------------------------------------------------------------------------- // Flur Schreibtisch 83221 24 1 83220 24 1 let hallwayDeskLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Flur', 'DeskLight', 'Schreibtischlampe', '83221 24 1', '83220 24 1'); hallwayDeskLight.start(); allLabeledItems.push(hallwayDeskLight); allRelevantLights.push(hallwayDeskLight); allLights.push(hallwayDeskLight); // Flur Stehlampe 8704914 24 5 8793154 24 5 let hallwayStandLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Flur', 'StandLight', 'Stehlampe', '8704914 24 5', '8793154 24 5'); hallwayStandLight.start(); allLabeledItems.push(hallwayStandLight); allRelevantLights.push(hallwayStandLight); allLights.push(hallwayStandLight); // Flur Schranklicht 66581 24 1 66580 24 1 let hallwayWardrobeLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Flur', 'WardrobeLight', 'Schranklicht', '66581 24 1', '66580 24 1'); hallwayWardrobeLight.start(); allLabeledItems.push(hallwayWardrobeLight); allRelevantLights.push(hallwayWardrobeLight); allLights.push(hallwayWardrobeLight); let windowContactHallway = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Flur', 'WindowContact', 'Flur', 25); windowContactHallway.start(); allLabeledItems.push(windowContactHallway); allWindows.push(windowContactHallway); let thermostatHallway1 = new MaxThermostat_1.MaxThermostat('Gnd', 'Flur', 'Thermostat1', 'Thermostat Flur vorne', 32, []); thermostatHallway1.start(); thermostatHallway1.setPresetTemperature(19.0); allLabeledItems.push(thermostatHallway1); allThermostatItems.push(thermostatHallway1); let thermostatHallway2 = new MaxThermostat_1.MaxThermostat('Gnd', 'Flur', 'Thermostat2', 'Thermostat Flur hinten', 33, []); thermostatHallway2.start(); thermostatHallway2.setPresetTemperature(5.0); allLabeledItems.push(thermostatHallway2); allThermostatItems.push(thermostatHallway2); // Küche ---------------------------------------------------------------------------------------------------- // Küche Fensterbank 66837 24 1 66836 24 1 let kitchenWindowLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Kueche', 'WindowLight', 'Fensterbanklicht', '66837 24 1', '66836 24 1'); kitchenWindowLight.start(); allLabeledItems.push(kitchenWindowLight); allRelevantLights.push(kitchenWindowLight); allLights.push(kitchenWindowLight); // Küche Deckenlampe 82197 24 1 82196 24 1 let kitchenCeilingLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'Kueche', 'CeilingLight', 'Deckenlampe', '82197 24 1', '82196 24 1'); kitchenCeilingLight.start(); allLabeledItems.push(kitchenCeilingLight); allRelevantLights.push(kitchenCeilingLight); allLights.push(kitchenCeilingLight); // Schlafzimmer --------------------------------------------------------------------------------------------- // Schlafzimmer Wolfgangs Seite 13976916 24 1 13976913 24 1 let bedRoomWolfgangsSide = new M433SwitchItem_1.M433SwitchItem('1st', 'Schlafzimmer', 'WolfgangsSide', 'Wolfgangs Seite', '13976916 24 1', '13976913 24 1'); bedRoomWolfgangsSide.start(); allLabeledItems.push(bedRoomWolfgangsSide); allRelevantLights.push(bedRoomWolfgangsSide); allLights.push(bedRoomWolfgangsSide); let bedRoomWolfgangBedLight = new HueColorBulbItem_1.HueColorBulbItem('1st', 'Schlafzimmer', 'WolfgangBedLight', 'Wolfgangs Bettlicht', 16); bedRoomWolfgangBedLight.start(); allLabeledItems.push(bedRoomWolfgangBedLight); allRelevantLights.push(bedRoomWolfgangBedLight); allLights.push(bedRoomWolfgangBedLight); let bedRoomWolfgangBedLightDimmerAdaptor = new DimmerAdaptor_1.DimmerAdaptor('1st', 'Schlafzimmer', 'WolfgangBedLight'); bedRoomWolfgangBedLightDimmerAdaptor.start(); let touchSwitchMultiButtonThing = new TouchSwitchMultiButtonThing_1.TouchSwitchMultiButtonThing('1st', 'Bedroom', 'Wolfgang', [new TouchSwitchMultiButtonThing_1.TouchSwitchButtonSingleItem(bedRoomWolfgangBedLightDimmerAdaptor.getInTopic())]); touchSwitchMultiButtonThing.start(); // Schlafzimmer Pattys Seite 13980756 24 1 13980753 24 1 let bedRoomPattysSide = new M433SwitchItem_1.M433SwitchItem('1st', 'Schlafzimmer', 'PattysSide', 'Pattys Seite', '13980756 24 1', '13980753 24 1'); bedRoomPattysSide.start(); allLabeledItems.push(bedRoomPattysSide); allRelevantLights.push(bedRoomPattysSide); allLights.push(bedRoomPattysSide); // Schlafzimmer Fensterbank 13979988 24 1 13979985 24 1 let bedRoomWindowLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Schlafzimmer', 'WindowLight', 'Fensterbanklicht', '13979988 24 1', '13979985 24 1'); bedRoomWindowLight.start(); allLabeledItems.push(bedRoomWindowLight); allRelevantLights.push(bedRoomWindowLight); allLights.push(bedRoomWindowLight); let windowContactBedroomStreet1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Bedroom', 'WindowContactStreet', 'Schlafz. Strasse', 17); windowContactBedroomStreet1st.start(); allLabeledItems.push(windowContactBedroomStreet1st); allWindows.push(windowContactBedroomStreet1st); let windowContact1BedroomGarden1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Bedroom', 'WindowContact1Garden', 'Schlafz. Garten 1', 18); windowContact1BedroomGarden1st.start(); allLabeledItems.push(windowContact1BedroomGarden1st); allWindows.push(windowContact1BedroomGarden1st); let windowContact2BedroomGarden1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Bedroom', 'WindowContact2Garden', 'Schlafz. Garten 2', 22); windowContact2BedroomGarden1st.start(); allLabeledItems.push(windowContact2BedroomGarden1st); allWindows.push(windowContact2BedroomGarden1st); let thermostatBedroom1st = new MaxThermostat_1.MaxThermostat('1st', 'Bedroom', 'Thermostat', 'Thermostat Schlafzimmer', 19, [windowContact1BedroomGarden1st, windowContact2BedroomGarden1st, windowContactBedroomStreet1st]); thermostatBedroom1st.start(); thermostatBedroom1st.setPresetTemperature(20.0); allLabeledItems.push(thermostatBedroom1st); allThermostatItems.push(thermostatBedroom1st); let thermostatBedroom1stCron = new Cron_1.Cron('thermostatBedroom1stCron', thermostatBedroom1st, [ { cronTime: '00 01 06 * * 1-5', output: 'ON' }, { cronTime: '00 01 09 * * 1-5', output: 'OFF' }, { cronTime: '00 01 08 * * 6,0', output: 'ON' }, { cronTime: '00 01 11 * * 6,0', output: 'OFF' }, { cronTime: '00 00 17 * * *', output: 'ON' }, { cronTime: '00 59 23 * * *', output: 'OFF' } ]); thermostatBedroom1stCron.start(); // --------------------------------------------------------------------------------------------------------- let dayLightScene = new Scene_1.LightScene('Gnd', 'Szenen', 'DayLight', 'DayLight', [ kitchenWindowLight, kitchenCeilingLight, hallwayDeskLight, hallwayStandLight, hallwayWardrobeLight, diningRoomSmallLight, diningRoomStandLight, diningRoomCupboardLight, diningRoomShelfLight, livingRoomLargeLight, livingRoomSmallLight, livingRoomStars, livingRoomStandLight, diningRoomNaehkaestchenLight ], []); dayLightScene.start(); allLabeledItems.push(dayLightScene); allLightScenes.push(dayLightScene); let ecoLightScene = new Scene_1.LightScene('Gnd', 'Szenen', 'EcoLight', 'EcoLight', [ kitchenWindowLight, hallwayDeskLight, hallwayWardrobeLight, diningRoomSmallLight, diningRoomStandLight, diningRoomCupboardLight, diningRoomShelfLight, livingRoomStars, livingRoomStandLight, diningRoomNaehkaestchenLight ], [ kitchenCeilingLight, hallwayStandLight, livingRoomLargeLight, livingRoomSmallLight ]); ecoLightScene.start(); allLabeledItems.push(ecoLightScene); allLightScenes.push(ecoLightScene); let ecoSwitch = new MaxEcoSwitch_1.MaxEcoSwitch('Gnd', 'Szenen', 'EcoSwitch', 'EcoSwitch', 6, dayLightScene, ecoLightScene); ecoSwitch.start(); let morningLightScene = new Scene_1.LightScene('Gnd', 'Szenen', 'MorningLight', 'MorningLight', [ kitchenWindowLight, kitchenCeilingLight, hallwayDeskLight, hallwayWardrobeLight, hallwayStandLight ], [ diningRoomSmallLight, diningRoomStandLight, diningRoomCupboardLight, diningRoomShelfLight, livingRoomStars, livingRoomStandLight, livingRoomLargeLight, livingRoomSmallLight, diningRoomNaehkaestchenLight ]); morningLightScene.start(); allLabeledItems.push(morningLightScene); allLightScenes.push(morningLightScene); let sceneOfAllLights = new Scene_1.LightScene('Gnd', 'Szenen', 'AllLights', 'Alle Lampen', allLights, []); sceneOfAllLights.start(); allLightScenes.push(sceneOfAllLights); // ---------------------------------------------------------------------------------------------------------- let windowContactBathroomGnd = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Bathroom', 'WindowContact', 'Bad unten', 7); windowContactBathroomGnd.start(); allLabeledItems.push(windowContactBathroomGnd); allWindows.push(windowContactBathroomGnd); let thermostatBathroomGnd = new MaxThermostat_1.MaxThermostat('Gnd', 'Bathroom', 'Thermostat', 'Thermostat Bad unten', 4, [windowContactBathroomGnd]); thermostatBathroomGnd.start(); thermostatBathroomGnd.setPresetTemperature(20.0); allLabeledItems.push(thermostatBathroomGnd); allThermostatItems.push(thermostatBathroomGnd); let thermostatBathroomGndCron = new Cron_1.Cron('thermostatBathroomGndCron', thermostatBathroomGnd, [ { cronTime: '00 02 06 * * 1-5', output: 'ON' }, { cronTime: '00 02 08 * * 6,0', output: 'ON' }, { cronTime: '00 02 11 * * *', output: 'OFF' }, { cronTime: '00 02 19 * * *', output: 'ON' }, { cronTime: '00 00 23 * * *', output: 'OFF' } ]); thermostatBathroomGndCron.start(); let windowContactBathroom1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Bad oben', 2); windowContactBathroom1st.start(); allLabeledItems.push(windowContactBathroom1st); allWindows.push(windowContactBathroom1st); let thermostatBathroom1st = new MaxThermostat_1.MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 3, [windowContactBathroom1st]); thermostatBathroom1st.start(); thermostatBathroom1st.setPresetTemperature(20.0); allLabeledItems.push(thermostatBathroom1st); allThermostatItems.push(thermostatBathroom1st); let thermostatBathroom1stCron = new Cron_1.Cron('thermostatBathroom1stCron', thermostatBathroom1st, [ { cronTime: '00 00 06 * * 1-5', output: 'ON' }, { cronTime: '00 00 08 * * 6,0', output: 'ON' }, { cronTime: '00 00 11 * * *', output: 'OFF' }, { cronTime: '00 00 19 * * *', output: 'ON' }, { cronTime: '00 00 23 * * *', output: 'OFF' } ]); thermostatBathroom1stCron.start(); let windowContactKitchen1 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Kueche', 'WindowContact1', 'Küche Garten', 11); windowContactKitchen1.start(); allLabeledItems.push(windowContactKitchen1); allWindows.push(windowContactKitchen1); let windowContactKitchen2 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Kueche', 'WindowContact2', 'Küche Terassentür', 10); windowContactKitchen2.start(); allLabeledItems.push(windowContactKitchen2); allWindows.push(windowContactKitchen2); let windowContactKitchen3 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Kueche', 'WindowContact3', 'Küche Straße 1', 12); windowContactKitchen3.start(); allLabeledItems.push(windowContactKitchen3); allWindows.push(windowContactKitchen3); let windowContactKitchen4 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Kueche', 'WindowContact4', 'Küche Straße 2', 13); windowContactKitchen4.start(); allLabeledItems.push(windowContactKitchen4); allWindows.push(windowContactKitchen4); let thermostatKitchen = new MaxThermostat_1.MaxThermostat('Gnd', 'Kueche', 'Thermostat', 'Thermostat Küche', 14, [ windowContactKitchen1, windowContactKitchen2, windowContactKitchen3, windowContactKitchen4 ]); thermostatKitchen.start(); thermostatKitchen.setPresetTemperature(20.0); allLabeledItems.push(thermostatKitchen); allThermostatItems.push(thermostatKitchen); let thermostatKitchenCron = new Cron_1.Cron('thermostatKitchenCron', thermostatKitchen, [ { cronTime: '00 00 06 * * 1-5', output: 'ON' }, { cronTime: '00 00 08 * * 6,0', output: 'ON' }, { cronTime: '00 00 10 * * 1-3', output: 'OFF' }, { cronTime: '00 30 13 * * 1-3', output: 'ON' }, { cronTime: '00 00 23 * * *', output: 'OFF' } ]); thermostatKitchenCron.start(); // ---------------------------------------------------------------------------------------------------------- let windowContactFrontdoor = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Flur', 'FrontdoorContact', 'Haustür', 23); windowContactFrontdoor.start(); allLabeledItems.push(windowContactFrontdoor); // ---------------------------------------------------------------------------------------------------------- let relayBox = new RelayBox_1.RelayBoxThing('base', 'labor', 'relaybox', 'IoT/Command/RelayBox', 'IoT/Status/RelayBox', [ "Küche", "Herd", "Waschküche" ]); relayBox.start(); allLabeledItems.push(relayBox); // ---------------------------------------------------------------------------------------------------------- let heatingSceneAll = new HeatingScene_1.HeatingScene('Gnd', 'House', 'Heatings', 'Alle Heizungen', allThermostatItems); heatingSceneAll.start(); // ---------------------------------------------------------------------------------------------------------- // Basement let workshopLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', 'Keller', 'Light', 'Werkstatt', 5); workshopLight.start(); allLabeledItems.push(workshopLight); allRelevantLights.push(workshopLight); allLights.push(workshopLight); let basementSmallLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', 'Keller', 'SmallLight', 'Licht einfach', 35, 1); basementSmallLight.start(); allLabeledItems.push(basementSmallLight); allRelevantLights.push(basementSmallLight); allLights.push(basementSmallLight); basementSmallLight.on('somethingChanged', () => { if (basementSmallLight.getState() == 'ON') { setTimeout(() => { if (basementLargeLight.getState() == 'OFF') { MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'OFF'); } }, (3 * 60 * 1000)); } if ((basementLargeLight.getState() == 'ON') && (basementSmallLight.getState() == 'OFF')) { MqttDispatcher_1.mqttHandler.send(basementLargeLight.getStateTopic(), 'OFF'); } }); let basementLargeLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', 'Keller', 'LargeLight', 'Licht hell', 35, 2); basementLargeLight.start(); allLabeledItems.push(basementLargeLight); allRelevantLights.push(basementLargeLight); allLights.push(basementLargeLight); basementLargeLight.on('somethingChanged', () => { if (basementLargeLight.getState() == 'ON') { MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'ON'); } else if (basementLargeLight.getState() == 'OFF') { MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'OFF'); } }); let basementForwarder = new Forwarder_1.Forwarder('Base', 'All', 'Forwarder', 'state', 'BasementForwarder', [ basementLargeLight.getStateTopic(), basementSmallLight.getStateTopic(), workshopLight.getStateTopic() ]); basementForwarder.start(); let basementForwarderSwitchOffAdaptor = new SwitchOffAdaptor_1.SwitchOffAdaptor('Base', 'All', 'Forwarder'); basementForwarderSwitchOffAdaptor.start(); // ---------------------------------------------------------------------------------------------------------- let twoLedSignal1 = new TwoLedSignal_1.TwoLedSignal('Gnd', 'Flur', 'TwoLedSignal1', 'Licht- und Fenster-Anzeiger', allRelevantLights, "OFF", "ON", allWindows, "CLOSED", "OPEN"); twoLedSignal1.start(); // MySwitchTHing let mySwitchThingWolfgang = new MySwitchThing_1.MySwitchThing('1st', 'Schlafzimmer', 'WolfgangsSwitch', [ new MySwitchThing_1.MySwitchSingleItem(bedRoomWolfgangBedLightDimmerAdaptor.getInTopic()), new MySwitchThing_1.MySwitchSingleItem(basementForwarderSwitchOffAdaptor.getInTopic()), new MySwitchThing_1.MySwitchSingleItem('IoT/InsLeere/2'), ]); mySwitchThingWolfgang.start(); // ---------------------------------------------------------------------------------------------------------- let testFourButton = new HomematicFourButtonThing_1.HomematicFourButtonThing('Gnd', 'Flur', 'TestButton', 9, [ new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/Testlight/dimmerIn'), new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/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', 'Flur', 'Testlight'); testDimmerAdaptor.start(); let testTimerAdaptor = new TimerAdaptor_1.TimerAdaptor('Gnd', 'Flur', 'DeskLight', 10); testTimerAdaptor.start(); let testLight = new HomematicDimmerItem_1.HomematicDimmerItem('Gnd', 'Flur', 'Testlight', 'Testlampe mit Dimmer', 8); testLight.start(); let testForwarder = new Forwarder_1.Forwarder('Gnd', 'Flur', 'TestForwarder', 'state', 'TestForwarder', [ 'dispatcher_ng/items/Gnd/Flur/Testlight2/state', 'dispatcher_ng/items/Gnd/Flur/DeskLight/state' ]); testForwarder.start(); let testScene = new Scene_1.LightScene('Gnd', 'Flur', 'TestScene', 'TestScene', [aquariumLight, annaBedLight], [matthiasStandLights, matthiasBedLight]); testScene.start(); // ---------------------------------------------------------------------------------------------------------- // heartbeat let heartbeatCounter = 0; let heartbeatTimer = setInterval(() => { heartbeatCounter += 1; MqttDispatcher_1.mqttHandler.send(config.dict.heartbeatTopic, `${heartbeatCounter}`); }, config.dict.heartbeatInterval); // watchdog let watchdogCounter = 0; let watchdogTimer = setInterval(() => { watchdogCounter += 1; MqttDispatcher_1.mqttHandler.send(config.dict.watchdogTopic, `${config.dict.watchdogMessage} ${watchdogCounter}`); }, config.dict.watchdogInterval); // ---------------------------------------------------------------------------------------------------------- // Homekit export let homekitObject = {}; let openhabList = []; // logger.info("allLabeledItems") // logger.info(JSON.stringify(allLabeledItems)) allLabeledItems.forEach((item) => { let exportData = item.exportItem(); if (exportData != null) { if ('id' in exportData['homekit']) { homekitObject[exportData['homekit']['id']] = exportData['homekit']['object']; } if (exportData['openhab'] instanceof Array) { let da = exportData['openhab']; da.forEach((o) => openhabList.push(o)); } else { let da = exportData['openhab']; openhabList.push(da); } // logger.info("openHabList") // logger.info(JSON.stringify(openhabList)) } }); let heatingMainSwitchExport = MaxThermostat_1.MaxThermostat.exportHeatingMainSwitchItem(); if (heatingMainSwitchExport != null) { let da = heatingMainSwitchExport['openhab']; openhabList.push(da); } fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4)); fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n')); let roomSwitches = {}; allLights.forEach((item) => { let switchItem = { 'label': item.getLabel(), 'actionTopic': item.getStateTopic(), 'feedbackTopic': item.getStateFeedbackTopic() }; if (item.getRoom() in roomSwitches) { roomSwitches[item.getRoom()].push(switchItem); } else { roomSwitches[item.getRoom()] = [switchItem]; } }); let smartClientConfiguration = {}; smartClientConfiguration['switches'] = []; for (let key in roomSwitches) { let item = { 'room': key, 'switches': roomSwitches[key] }; smartClientConfiguration['switches'].push(item); } smartClientConfiguration['scenes'] = []; allLightScenes.forEach((scene) => { let item = { 'label': scene.getLabel(), 'actionTopic': scene.getStateTopic() }; smartClientConfiguration['scenes'].push(item); }); smartClientConfiguration['windows'] = []; allWindows.forEach((window) => { let item = { 'label': window.getLabel(), 'topic': window.getStateFeedbackTopic() }; smartClientConfiguration['windows'].push(item); }); fs.writeFileSync('smartclient.json', JSON.stringify(smartClientConfiguration, null, 4)); // ---------------------------------------------------------------------------------------------------------- MqttDispatcher_1.mqttHandler.exec(); logger.info("Dispatcher running"); MqttDispatcher_1.mqttHandler.send('smartclient/configuration', JSON.stringify(smartClientConfiguration, null, 4)); //# sourceMappingURL=main.js.map