some changes, not yet done with WindowContact, too cold in Q-West to complete
This commit is contained in:
60
src/MaxThermostat.ts
Normal file
60
src/MaxThermostat.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import * as logger from './log'
|
||||
import { mqttHandler } from './MqttDispatcher'
|
||||
import { AHomematicItem } from './AHomematicItem'
|
||||
import { MaxWindowContact } from './MaxWindowContact';
|
||||
// import { SwitchExport, ExportType } from './Export'
|
||||
|
||||
const WINDOW_OPEN_TEMPERATURE = 4.5
|
||||
|
||||
|
||||
export class MaxThermostat extends AHomematicItem {
|
||||
private actionTopic: string
|
||||
private deviceFeedbackTopic: string
|
||||
private temperatureFeedbackTopic: string
|
||||
private temperatureTopic: string
|
||||
private temperature: number
|
||||
private windowContacts: MaxWindowContact[]
|
||||
private windowContactTopics: string[]
|
||||
private windowOpen: boolean
|
||||
// Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE
|
||||
|
||||
constructor(floor: string, room: string, item: string, label: string, hmId: number, windowContacts: MaxWindowContact[]) {
|
||||
super(floor, room, item, label, hmId)
|
||||
this.temperatureTopic = `${this.topicFirstPart}/temperature`
|
||||
this.temperatureFeedbackTopic = `${this.topicFirstPart}/temperature/feedback`
|
||||
this.deviceFeedbackTopic = `${this.deviceTopicPre}/1/SET_TEMPERATURE`
|
||||
this.actionTopic = `${this.actionTopicPre}/1/SET_TEMPERATURE`
|
||||
this.subscribeTopics = [
|
||||
this.temperatureTopic,
|
||||
this.deviceFeedbackTopic
|
||||
]
|
||||
this.windowContacts = windowContacts
|
||||
this.windowOpen = false
|
||||
this.windowContactTopics = []
|
||||
this.windowContacts.forEach((windowContact) => {
|
||||
this.subscribeTopics.push(windowContact.getStateFeedbackTopic())
|
||||
this.windowContactTopics.push(windowContact.getStateFeedbackTopic())
|
||||
})
|
||||
}
|
||||
|
||||
processMessage(topic: string, payload: string) : void {
|
||||
if (topic == this.temperatureTopic) {
|
||||
this.temperature = parseFloat(payload)
|
||||
mqttHandler.send(this.temperatureFeedbackTopic, `${this.temperature}`)
|
||||
mqttHandler.send(this.actionTopic, `${this.temperature}`)
|
||||
} else if (topic == this.deviceFeedbackTopic) {
|
||||
this.temperature = parseFloat(payload)
|
||||
mqttHandler.send(this.temperatureFeedbackTopic, `${this.temperature}`)
|
||||
} else if (this.windowContactTopics.indexOf(topic) >= 0) {
|
||||
if (payload == 'CLOSED') {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user