add summer/winter switch
This commit is contained in:
@ -3,11 +3,10 @@ import { mqttHandler } from './MqttDispatcher'
|
||||
import { HasInTopic } from './AItem'
|
||||
import { AHomegearItem } from './AHomegearItem'
|
||||
// import { MaxWindowContact } from './MaxWindowContact';
|
||||
import { ThermostatExport, ExportType } from './Export'
|
||||
import { ThermostatExport, SummerSwitchExport, ExportType } from './Export'
|
||||
import { Disabler } from './Disabler'
|
||||
|
||||
const DISABLED_TEMPERATURE = 5.0
|
||||
|
||||
const DISABLED_TEMPERATURE: number = 5.0
|
||||
|
||||
type DisabledHolder = {
|
||||
disabler : Disabler
|
||||
@ -27,6 +26,9 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic {
|
||||
private hardDisabled: boolean
|
||||
private commandTopic: string
|
||||
|
||||
static summerSwitchTopic : string = 'dispatcher_ng/items/summerSwitch'
|
||||
private summerFlag: boolean = false
|
||||
|
||||
// Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE
|
||||
|
||||
getInTopic() : string {
|
||||
@ -37,6 +39,10 @@ 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)
|
||||
}
|
||||
|
||||
constructor(floor: string, room: string, item: string, label: string, hmId: number, hardDisablers: Disabler[]) {
|
||||
super(floor, room, item, label, hmId)
|
||||
this.temperatureTopic = `${this.topicFirstPart}/temperature`
|
||||
@ -50,7 +56,8 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic {
|
||||
this.temperatureTopic,
|
||||
this.presetTemperatureTopic,
|
||||
this.deviceFeedbackTopic,
|
||||
this.commandTopic
|
||||
this.commandTopic,
|
||||
MaxThermostat.summerSwitchTopic
|
||||
]
|
||||
this.hardDisabled = false
|
||||
this.hardDisablerMap = {}
|
||||
@ -74,12 +81,16 @@ export class MaxThermostat extends AHomegearItem implements HasInTopic {
|
||||
this.temperature = parseFloat(payload)
|
||||
setTemperature = true
|
||||
} else if (topic == this.commandTopic) {
|
||||
if (payload == 'ON') {
|
||||
this.temperature = this.presetTemperature
|
||||
} else if (payload == 'OFF') {
|
||||
this.temperature = DISABLED_TEMPERATURE
|
||||
if (! this.summerFlag) {
|
||||
if (payload == 'ON') {
|
||||
this.temperature = this.presetTemperature
|
||||
} else if (payload == 'OFF') {
|
||||
this.temperature = DISABLED_TEMPERATURE
|
||||
}
|
||||
setTemperature = true
|
||||
}
|
||||
setTemperature = true
|
||||
} else if (topic == MaxThermostat.summerSwitchTopic) {
|
||||
this.summerFlag = (payload == 'ON')
|
||||
} else if (topic == this.presetTemperatureTopic) {
|
||||
this.presetTemperature = parseFloat(payload)
|
||||
mqttHandler.send(this.presetTemperatureFeedbackTopic, `${this.presetTemperature}`)
|
||||
|
Reference in New Issue
Block a user