diff --git a/dist/Export.js b/dist/Export.js index 1d15a3c..d7fc539 100644 --- a/dist/Export.js +++ b/dist/Export.js @@ -33,11 +33,11 @@ function RelayBoxExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPr 'openhab': RelayBoxOpenHABExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) }; } exports.RelayBoxExport = RelayBoxExport; -function SummerSwitchExport(summerSwitchTopic) { +function HeatingMainSwitchExport(topic) { return { 'homekit': { 'id': '', 'object': {} }, - 'openhab': `Switch SummerSwitch "Winter?" {mqtt=">[localbroker:${summerSwitchTopic}:command:*:default],<[localbroker:${summerSwitchTopic}:state:default]"}` }; + 'openhab': `Switch HeatingMainSwitch "Heizung Hauptschalter" {mqtt=">[localbroker:${topic}:command:*:default],<[localbroker:${topic}:state:default]"}` }; } -exports.SummerSwitchExport = SummerSwitchExport; +exports.HeatingMainSwitchExport = HeatingMainSwitchExport; function RelayBoxHomekitExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) { return { 'id': '', 'object': {} }; } diff --git a/dist/MaxThermostat.js b/dist/MaxThermostat.js index 683e79a..5915d46 100644 --- a/dist/MaxThermostat.js +++ b/dist/MaxThermostat.js @@ -9,7 +9,7 @@ const DISABLED_TEMPERATURE = 5.0; class MaxThermostat extends AHomegearItem_1.AHomegearItem { constructor(floor, room, item, label, hmId, hardDisablers) { super(floor, room, item, label, hmId); - this.summerFlag = false; + this.heatingMainFlag = false; this.temperatureTopic = `${this.topicFirstPart}/temperature`; this.temperatureFeedbackTopic = `${this.topicFirstPart}/temperature/feedback`; this.presetTemperatureTopic = `${this.topicFirstPart}/presetTemperature`; @@ -22,7 +22,7 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem { this.presetTemperatureTopic, this.deviceFeedbackTopic, this.commandTopic, - MaxThermostat.summerSwitchTopic + MaxThermostat.heatingMainSwitchTopic ]; this.hardDisabled = false; this.hardDisablerMap = {}; @@ -38,8 +38,8 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem { exportItem() { return Export_1.ThermostatExport(this.itemId, this.label, this.temperatureTopic, this.temperatureFeedbackTopic, this.presetTemperatureTopic, this.presetTemperatureFeedbackTopic); } - static exportSummerSwitchItem() { - return Export_1.SummerSwitchExport(MaxThermostat.summerSwitchTopic); + static exportHeatingMainSwitchItem() { + return Export_1.HeatingMainSwitchExport(MaxThermostat.heatingMainSwitchTopic); } setPresetTemperature(presetTemperature) { this.presetTemperature = presetTemperature; @@ -54,7 +54,7 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem { setTemperature = true; } else if (topic == this.commandTopic) { - if (!this.summerFlag) { + if (this.heatingMainFlag) { if (payload == 'ON') { this.temperature = this.presetTemperature; } @@ -64,9 +64,13 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem { setTemperature = true; } } - else if (topic == MaxThermostat.summerSwitchTopic) { - this.summerFlag = (payload == 'ON'); - logger.info(`${this.itemId} switched to ${this.summerFlag ? 'Summer' : 'Winter'} mode`); + else if (topic == MaxThermostat.heatingMainSwitchTopic) { + this.heatingMainFlag = (payload == 'ON'); + logger.info(`${this.itemId} heating main: ${this.heatingMainFlag}`); + if (!this.heatingMainFlag) { + MqttDispatcher_1.mqttHandler.send(this.temperatureFeedbackTopic, `${DISABLED_TEMPERATURE}`); + MqttDispatcher_1.mqttHandler.send(this.actionTopic, `${DISABLED_TEMPERATURE}`); + } } else if (topic == this.presetTemperatureTopic) { this.presetTemperature = parseFloat(payload); @@ -98,6 +102,6 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem { } } } -MaxThermostat.summerSwitchTopic = 'dispatcher_ng/items/summerSwitch'; +MaxThermostat.heatingMainSwitchTopic = 'dispatcher_ng/items/heatingMainSwitch'; exports.MaxThermostat = MaxThermostat; //# sourceMappingURL=MaxThermostat.js.map \ No newline at end of file diff --git a/dist/main.js b/dist/main.js index 537c4a2..618887e 100644 --- a/dist/main.js +++ b/dist/main.js @@ -310,9 +310,9 @@ allLabeledItems.forEach((item) => { // logger.info(JSON.stringify(openhabList)) } }); -let summerSwitchExport = MaxThermostat_1.MaxThermostat.exportSummerSwitchItem(); -if (summerSwitchExport != null) { - let da = summerSwitchExport['openhab']; +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)); diff --git a/openhab.items b/openhab.items index 3a42a43..e5b4305 100644 --- a/openhab.items +++ b/openhab.items @@ -50,4 +50,4 @@ 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 SummerSwitch "Winter?" {mqtt=">[localbroker:dispatcher_ng/items/summerSwitch:command:*:default],<[localbroker:dispatcher_ng/items/summerSwitch:state:default]"} \ No newline at end of file +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/Export.ts b/src/Export.ts index a13f2ac..f5192cd 100644 --- a/src/Export.ts +++ b/src/Export.ts @@ -51,9 +51,9 @@ export function RelayBoxExport(itemId: string, stateTopicPre: string, feedbackTo 'openhab': RelayBoxOpenHABExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames)} } -export function SummerSwitchExport(summerSwitchTopic: string) : ExportType { +export function HeatingMainSwitchExport(topic: string) : ExportType { return {'homekit': {'id':'', 'object': {}}, - 'openhab': `Switch SummerSwitch "Winter?" {mqtt=">[localbroker:${summerSwitchTopic}:command:*:default],<[localbroker:${summerSwitchTopic}:state:default]"}`} + 'openhab': `Switch HeatingMainSwitch "Heizung Hauptschalter" {mqtt=">[localbroker:${topic}:command:*:default],<[localbroker:${topic}:state:default]"}`} } function RelayBoxHomekitExport(itemId: string, stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : HomekitExportType{ diff --git a/src/MaxThermostat.ts b/src/MaxThermostat.ts index c628637..16bdb1e 100644 --- a/src/MaxThermostat.ts +++ b/src/MaxThermostat.ts @@ -3,7 +3,7 @@ import { mqttHandler } from './MqttDispatcher' import { HasInTopic } from './AItem' import { AHomegearItem } from './AHomegearItem' // import { MaxWindowContact } from './MaxWindowContact'; -import { ThermostatExport, SummerSwitchExport, ExportType } from './Export' +import { ThermostatExport, HeatingMainSwitchExport, ExportType } from './Export' import { Disabler } from './Disabler' const DISABLED_TEMPERATURE: number = 5.0 @@ -26,8 +26,8 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic { private hardDisabled: boolean private commandTopic: string - static summerSwitchTopic : string = 'dispatcher_ng/items/summerSwitch' - private summerFlag: boolean = false + static heatingMainSwitchTopic : string = 'dispatcher_ng/items/heatingMainSwitch' + private heatingMainFlag: boolean = false // Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE @@ -39,8 +39,8 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic { return ThermostatExport(this.itemId, this.label, this.temperatureTopic, this.temperatureFeedbackTopic, this.presetTemperatureTopic, this.presetTemperatureFeedbackTopic) } - static exportSummerSwitchItem() : ExportType|null { - return SummerSwitchExport(MaxThermostat.summerSwitchTopic) + static exportHeatingMainSwitchItem() : ExportType|null { + return HeatingMainSwitchExport(MaxThermostat.heatingMainSwitchTopic) } constructor(floor: string, room: string, item: string, label: string, hmId: number, hardDisablers: Disabler[]) { @@ -57,7 +57,7 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic { this.presetTemperatureTopic, this.deviceFeedbackTopic, this.commandTopic, - MaxThermostat.summerSwitchTopic + MaxThermostat.heatingMainSwitchTopic ] this.hardDisabled = false this.hardDisablerMap = {} @@ -81,7 +81,7 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic { this.temperature = parseFloat(payload) setTemperature = true } else if (topic == this.commandTopic) { - if (! this.summerFlag) { + if (this.heatingMainFlag) { if (payload == 'ON') { this.temperature = this.presetTemperature } else if (payload == 'OFF') { @@ -89,9 +89,13 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic { } setTemperature = true } - } else if (topic == MaxThermostat.summerSwitchTopic) { - this.summerFlag = (payload == 'ON') - logger.info(`${this.itemId} switched to ${this.summerFlag ? 'Summer' : 'Winter'} mode`) + } else if (topic == MaxThermostat.heatingMainSwitchTopic) { + this.heatingMainFlag = (payload == 'ON') + logger.info(`${this.itemId} heating main: ${this.heatingMainFlag}`) + if (! this.heatingMainFlag) { + mqttHandler.send(this.temperatureFeedbackTopic, `${DISABLED_TEMPERATURE}`) + mqttHandler.send(this.actionTopic, `${DISABLED_TEMPERATURE}`) + } } else if (topic == this.presetTemperatureTopic) { this.presetTemperature = parseFloat(payload) mqttHandler.send(this.presetTemperatureFeedbackTopic, `${this.presetTemperature}`) diff --git a/src/main.ts b/src/main.ts index fa53680..2263ef0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -401,9 +401,9 @@ allLabeledItems.forEach((item: AItem) => { } }) -let summerSwitchExport : ExportType|null = MaxThermostat.exportSummerSwitchItem() -if (summerSwitchExport != null) { - let da : string = summerSwitchExport['openhab'] as string +let heatingMainSwitchExport : ExportType|null = MaxThermostat.exportHeatingMainSwitchItem() +if (heatingMainSwitchExport != null) { + let da : string = heatingMainSwitchExport['openhab'] as string openhabList.push(da) }