diff --git a/src/MaxThermostat.ts b/src/MaxThermostat.ts index fbca323..1b6484f 100644 --- a/src/MaxThermostat.ts +++ b/src/MaxThermostat.ts @@ -46,8 +46,13 @@ export class MaxThermostat extends AHomematicItem implements HasInTopic { } processMessage(topic: string, payload: string) : void { - if ((topic == this.temperatureTopic) || (topic == this.deviceFeedbackTopic)) { + let setTemperature : boolean = 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 this.windowOpen = false @@ -56,14 +61,17 @@ export class MaxThermostat extends AHomematicItem implements HasInTopic { this.windowOpen = true } }) + setTemperature = true } - if (! this.windowOpen) { - mqttHandler.send(this.temperatureFeedbackTopic, `${this.temperature}`) - mqttHandler.send(this.actionTopic, `${this.temperature}`) - } else { - mqttHandler.send(this.temperatureFeedbackTopic, `${WINDOW_OPEN_TEMPERATURE}`) - mqttHandler.send(this.actionTopic, `${WINDOW_OPEN_TEMPERATURE}`) + if (setTemperature) { + if (! this.windowOpen) { + mqttHandler.send(this.temperatureFeedbackTopic, `${this.temperature}`) + mqttHandler.send(this.actionTopic, `${this.temperature}`) + } else { + mqttHandler.send(this.temperatureFeedbackTopic, `${WINDOW_OPEN_TEMPERATURE}`) + mqttHandler.send(this.actionTopic, `${WINDOW_OPEN_TEMPERATURE}`) + } } }