rename summer/winter switch to heatingMainSwitch

This commit is contained in:
2018-04-09 16:28:24 +02:00
parent 245002acad
commit f0d32b5a2b
7 changed files with 39 additions and 31 deletions

View File

@ -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{

View File

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

View File

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