From f362c90b91b4554e950d15b0b73076302d07abb4 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Mon, 15 Jan 2018 21:24:53 +0100 Subject: [PATCH] some changes --- dist/M433SwitchItem.js | 3 +++ dist/MaxThermostat.js | 25 +++++++++++++++++-------- dist/MaxWindowContact.js | 7 ++++++- dist/main.js | 12 ++++++++++-- src/M433SwitchItem.ts | 6 +++++- src/MaxThermostat.ts | 4 ++-- src/MaxWindowContact.ts | 8 ++++++-- src/main.ts | 14 ++++++++++++-- 8 files changed, 61 insertions(+), 18 deletions(-) diff --git a/dist/M433SwitchItem.js b/dist/M433SwitchItem.js index d6492e8..e9457e6 100644 --- a/dist/M433SwitchItem.js +++ b/dist/M433SwitchItem.js @@ -7,6 +7,9 @@ class M433SwitchItem extends AItem_1.AItem { getStateTopic() { return this.stateTopic; } + getInTopic() { + return this.stateTopic; + } getStateFeedbackTopic() { return this.stateFeedbackTopic; } diff --git a/dist/MaxThermostat.js b/dist/MaxThermostat.js index 96df9cd..3af8235 100644 --- a/dist/MaxThermostat.js +++ b/dist/MaxThermostat.js @@ -27,8 +27,14 @@ class MaxThermostat extends AHomematicItem_1.AHomematicItem { }); } processMessage(topic, payload) { - if ((topic == this.temperatureTopic) || (topic == this.deviceFeedbackTopic)) { + let setTemperature = false; + if (topic == this.temperatureTopic) { this.temperature = parseFloat(payload); + setTemperature = true; + } + else if (topic == this.deviceFeedbackTopic) { + // this.temperature = parseFloat(payload) + setTemperature = false; } else if (topic in this.windowContactMap) { this.windowContactMap[topic].state = payload; @@ -38,14 +44,17 @@ class MaxThermostat extends AHomematicItem_1.AHomematicItem { this.windowOpen = true; } }); + setTemperature = true; } - if (!this.windowOpen) { - MqttDispatcher_1.mqttHandler.send(this.temperatureFeedbackTopic, `${this.temperature}`); - MqttDispatcher_1.mqttHandler.send(this.actionTopic, `${this.temperature}`); - } - else { - MqttDispatcher_1.mqttHandler.send(this.temperatureFeedbackTopic, `${WINDOW_OPEN_TEMPERATURE}`); - MqttDispatcher_1.mqttHandler.send(this.actionTopic, `${WINDOW_OPEN_TEMPERATURE}`); + if (setTemperature) { + if (!this.windowOpen) { + MqttDispatcher_1.mqttHandler.send(this.temperatureFeedbackTopic, `${this.temperature}`); + MqttDispatcher_1.mqttHandler.send(this.actionTopic, `${this.temperature}`); + } + else { + MqttDispatcher_1.mqttHandler.send(this.temperatureFeedbackTopic, `${WINDOW_OPEN_TEMPERATURE}`); + MqttDispatcher_1.mqttHandler.send(this.actionTopic, `${WINDOW_OPEN_TEMPERATURE}`); + } } } } diff --git a/dist/MaxWindowContact.js b/dist/MaxWindowContact.js index 2cf0a99..1d0f289 100644 --- a/dist/MaxWindowContact.js +++ b/dist/MaxWindowContact.js @@ -18,7 +18,12 @@ class MaxWindowContact extends AHomematicItem_1.AHomematicItem { ]; } processMessage(topic, payload) { - this.state = payload; + if (payload == 'true') { + this.state = 'OPEN'; + } + else { + this.state = 'CLOSED'; + } MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state); } } diff --git a/dist/main.js b/dist/main.js index ffabdb7..1ee22f8 100644 --- a/dist/main.js +++ b/dist/main.js @@ -23,6 +23,14 @@ let allLabeledItems = new Array(); let aquariumLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Anna', 'AquariumLight', 'Aquariumlicht', '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-7', 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 Anna', '14668116 24 1', '14668113 24 1'); annaBedLight.start(); @@ -147,9 +155,9 @@ let thermostatBathroomGndCron = new Cron_1.Cron('thermostatBathroomGndCron', the { cronTime: '00 00 23 * * *', output: '5.0' } ]); thermostatBathroomGndCron.start(); -let windowContactBathroom1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Fenster Bad oben', 7); +let windowContactBathroom1st = new MaxWindowContact_1.MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Fenster Bad oben', 2); windowContactBathroom1st.start(); -let thermostatBathroom1st = new MaxThermostat_1.MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 4, [windowContactBathroom1st]); +let thermostatBathroom1st = new MaxThermostat_1.MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 3, [windowContactBathroom1st]); thermostatBathroom1st.start(); let thermostatBathroom1stCron = new Cron_1.Cron('thermostatBathroom1stCron', thermostatBathroom1st, [ { cronTime: '00 00 06 * * 1-5', output: '21.0' }, diff --git a/src/M433SwitchItem.ts b/src/M433SwitchItem.ts index 306bc0d..e8f0b6d 100644 --- a/src/M433SwitchItem.ts +++ b/src/M433SwitchItem.ts @@ -1,6 +1,6 @@ import * as logger from './log' import { mqttHandler } from './MqttDispatcher' -import { AItem, HasStateAndFeedbackTopic } from './AItem' +import { AItem, HasStateAndFeedbackTopic, HasInTopic } from './AItem' import { SwitchExport, ExportType } from './Export' @@ -18,6 +18,10 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopic { return this.stateTopic } + getInTopic() : string { + return this.stateTopic + } + getStateFeedbackTopic() : string { return this.stateFeedbackTopic } diff --git a/src/MaxThermostat.ts b/src/MaxThermostat.ts index 1b6484f..0ca8a8c 100644 --- a/src/MaxThermostat.ts +++ b/src/MaxThermostat.ts @@ -51,7 +51,7 @@ export class MaxThermostat extends AHomematicItem implements HasInTopic { this.temperature = parseFloat(payload) setTemperature = true } else if (topic == this.deviceFeedbackTopic) { - this.temperature = parseFloat(payload) + // this.temperature = parseFloat(payload) setTemperature = false } else if (topic in this.windowContactMap) { this.windowContactMap[topic].state = payload @@ -76,4 +76,4 @@ export class MaxThermostat extends AHomematicItem implements HasInTopic { } -} \ No newline at end of file +} diff --git a/src/MaxWindowContact.ts b/src/MaxWindowContact.ts index 67324f1..b73f687 100644 --- a/src/MaxWindowContact.ts +++ b/src/MaxWindowContact.ts @@ -25,8 +25,12 @@ export class MaxWindowContact extends AHomematicItem { } processMessage(topic: string, payload: string) : void { - this.state = payload + if (payload == 'true') { + this.state = 'OPEN' + } else { + this.state = 'CLOSED' + } mqttHandler.send(this.stateFeedbackTopic, this.state) } -} \ No newline at end of file +} diff --git a/src/main.ts b/src/main.ts index 5e92885..e78cdc4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,6 +30,16 @@ let aquariumLight = new M433SwitchItem('1st', 'Anna', 'AquariumLight', 'Aquarium aquariumLight.start() allLabeledItems.push(aquariumLight) +let aquariumLightCron = new Cron('aquariumLightCron', aquariumLight, [ + {cronTime: '00 00 07 * * 1-5', output: 'ON'}, + {cronTime: '00 00 09 * * 6-7', 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('1st', 'Anna', 'BedLight', 'Bettlicht Anna', '14668116 24 1', '14668113 24 1') annaBedLight.start() @@ -195,10 +205,10 @@ let thermostatBathroomGndCron = new Cron('thermostatBathroomGndCron', thermostat thermostatBathroomGndCron.start() -let windowContactBathroom1st = new MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Fenster Bad oben', 7) +let windowContactBathroom1st = new MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Fenster Bad oben', 2) windowContactBathroom1st.start() -let thermostatBathroom1st = new MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 4, [windowContactBathroom1st]) +let thermostatBathroom1st = new MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 3, [windowContactBathroom1st]) thermostatBathroom1st.start() let thermostatBathroom1stCron = new Cron('thermostatBathroom1stCron', thermostatBathroom1st, [