From f75de912bae671a4b0e9eb0c244a79a8e80b3429 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 24 May 2018 23:26:38 +0200 Subject: [PATCH] debug keller licht --- dist/HomematicSwitchItem.js | 2 +- dist/main.js | 12 ++++++++- homekit.json | 53 ++++++++++++++++++++++++++++++++++++- openhab.items | 3 +++ src/HomematicSwitchItem.ts | 2 +- src/main.ts | 11 +++++++- 6 files changed, 78 insertions(+), 5 deletions(-) diff --git a/dist/HomematicSwitchItem.js b/dist/HomematicSwitchItem.js index 266e85b..5133484 100644 --- a/dist/HomematicSwitchItem.js +++ b/dist/HomematicSwitchItem.js @@ -32,7 +32,6 @@ 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; @@ -58,6 +57,7 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem { MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state); break; } + this.emit('somethingChanged'); } } exports.HomematicSwitchItem = HomematicSwitchItem; diff --git a/dist/main.js b/dist/main.js index 0f07567..e1bdbd4 100644 --- a/dist/main.js +++ b/dist/main.js @@ -367,11 +367,21 @@ let basementSmallLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', ' basementSmallLight.start(); allLabeledItems.push(basementSmallLight); allRelevantLights.push(basementSmallLight); +basementSmallLight.on('somethingChanged', () => { + if ((basementLargeLight.getState() == 'OFF') && (basementSmallLight.getState() == 'ON')) { + setTimeout(() => { + MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'OFF'); + }, (3 * 1000)); + } + else if ((basementLargeLight.getState() == 'ON') && (basementSmallLight.getState() == 'OFF')) { + MqttDispatcher_1.mqttHandler.send(basementLargeLight.getStateTopic(), 'OFF'); + } +}); let basementLargeLight = new HomematicSwitchItem_1.HomematicSwitchItem('Base', 'Hallway', 'LargeLight', 'Licht Keller hell', 35, 2); basementLargeLight.start(); allLabeledItems.push(basementLargeLight); allRelevantLights.push(basementLargeLight); -basementLargeLight.on('somethingChange', () => { +basementLargeLight.on('somethingChanged', () => { if (basementLargeLight.getState() == 'ON') { MqttDispatcher_1.mqttHandler.send(basementSmallLight.getStateTopic(), 'ON'); } diff --git a/homekit.json b/homekit.json index 418b9c8..3a3a426 100644 --- a/homekit.json +++ b/homekit.json @@ -742,5 +742,56 @@ "onContactDetected": "CLOSED" } }, - "": {} + "": {}, + "Base_Workshop_Light": { + "id": "Base_Workshop_Light", + "name": "Licht Werkstatt", + "service": "Lightbulb", + "topic": { + "setOn": "dispatcher_ng/items/Base/Workshop/Light/state", + "statusOn": "dispatcher_ng/items/Base/Workshop/Light/state/feedback" + }, + "payload": { + "onTrue": "ON", + "onFalse": "OFF", + "brightnessFactor": "", + "hueFactor": "", + "saturationFactor": "" + }, + "config": {} + }, + "Base_Hallway_SmallLight": { + "id": "Base_Hallway_SmallLight", + "name": "Licht Keller einfach", + "service": "Lightbulb", + "topic": { + "setOn": "dispatcher_ng/items/Base/Hallway/SmallLight/state", + "statusOn": "dispatcher_ng/items/Base/Hallway/SmallLight/state/feedback" + }, + "payload": { + "onTrue": "ON", + "onFalse": "OFF", + "brightnessFactor": "", + "hueFactor": "", + "saturationFactor": "" + }, + "config": {} + }, + "Base_Hallway_LargeLight": { + "id": "Base_Hallway_LargeLight", + "name": "Licht Keller hell", + "service": "Lightbulb", + "topic": { + "setOn": "dispatcher_ng/items/Base/Hallway/LargeLight/state", + "statusOn": "dispatcher_ng/items/Base/Hallway/LargeLight/state/feedback" + }, + "payload": { + "onTrue": "ON", + "onFalse": "OFF", + "brightnessFactor": "", + "hueFactor": "", + "saturationFactor": "" + }, + "config": {} + } } \ No newline at end of file diff --git a/openhab.items b/openhab.items index fa48b9c..3b4ad9e 100644 --- a/openhab.items +++ b/openhab.items @@ -65,4 +65,7 @@ Switch base_labor_relaybox1 "Herd" {mqtt=">[localbroker:dispatcher_ng/items/base String base_labor_relaybox1Conflict "Herd [%s]" {mqtt="<[localbroker:dispatcher_ng/items/base/labor/relaybox/conflict/1:state:default]"} Switch base_labor_relaybox2 "Waschküche" {mqtt=">[localbroker:dispatcher_ng/items/base/labor/relaybox/state/2:command:*:default],<[localbroker:dispatcher_ng/items/base/labor/relaybox/feedback/2:state:default]"} String base_labor_relaybox2Conflict "Waschküche [%s]" {mqtt="<[localbroker:dispatcher_ng/items/base/labor/relaybox/conflict/2:state:default]"} +Switch Base_Workshop_Light "Licht Werkstatt"{mqtt=">[localbroker:dispatcher_ng/items/Base/Workshop/Light/state:command:*:default],<[localbroker:dispatcher_ng/items/Base/Workshop/Light/state/feedback:state:default]"} +Switch Base_Hallway_SmallLight "Licht Keller einfach"{mqtt=">[localbroker:dispatcher_ng/items/Base/Hallway/SmallLight/state:command:*:default],<[localbroker:dispatcher_ng/items/Base/Hallway/SmallLight/state/feedback:state:default]"} +Switch Base_Hallway_LargeLight "Licht Keller hell"{mqtt=">[localbroker:dispatcher_ng/items/Base/Hallway/LargeLight/state:command:*:default],<[localbroker:dispatcher_ng/items/Base/Hallway/LargeLight/state/feedback:state:default]"} Switch HeatingMainSwitch "Heizung Hauptschalter" {mqtt=">[localbroker:dispatcher_ng/items/heatingMainSwitch:command:*:default],<[localbroker:dispatcher_ng/items/heatingMainSwitch:state:default]"} \ No newline at end of file diff --git a/src/HomematicSwitchItem.ts b/src/HomematicSwitchItem.ts index 1467b0a..e93d931 100644 --- a/src/HomematicSwitchItem.ts +++ b/src/HomematicSwitchItem.ts @@ -47,7 +47,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee } processMessage(topic: string, payload: string) : void { - this.emit('somethingChanged') switch (topic) { case this.stateTopic: this.state = payload @@ -71,5 +70,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee mqttHandler.send(this.stateFeedbackTopic, this.state) break } + this.emit('somethingChanged') } } diff --git a/src/main.ts b/src/main.ts index bfdc4f9..5eeab83 100644 --- a/src/main.ts +++ b/src/main.ts @@ -458,12 +458,21 @@ let basementSmallLight = new HomematicSwitchItem('Base', 'Hallway', 'SmallLight' basementSmallLight.start() allLabeledItems.push(basementSmallLight) allRelevantLights.push(basementSmallLight) +basementSmallLight.on('somethingChanged', () => { + if ((basementLargeLight.getState() == 'OFF') && (basementSmallLight.getState() == 'ON')) { + setTimeout(() => { + mqttHandler.send(basementSmallLight.getStateTopic(), 'OFF') + }, (3 * 1000)) + } else if ((basementLargeLight.getState() == 'ON') && (basementSmallLight.getState() == 'OFF')) { + mqttHandler.send(basementLargeLight.getStateTopic(), 'OFF') + } +}) let basementLargeLight = new HomematicSwitchItem('Base', 'Hallway', 'LargeLight', 'Licht Keller hell', 35, 2) basementLargeLight.start() allLabeledItems.push(basementLargeLight) allRelevantLights.push(basementLargeLight) -basementLargeLight.on('somethingChange', () => { +basementLargeLight.on('somethingChanged', () => { if (basementLargeLight.getState() == 'ON') { mqttHandler.send(basementSmallLight.getStateTopic(), 'ON') } else if (basementLargeLight.getState() == 'OFF') {