fix in setting temperature, avoid feedback loop

This commit is contained in:
Wolfgang Hottgenroth
2018-01-15 20:06:01 +01:00
parent d87fceb73e
commit 85cab38058

View File

@ -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}`)
}
}
}