fix MaxSwitch

This commit is contained in:
Wolfgang Hottgenroth
2018-01-12 19:39:04 +01:00
parent c474d22265
commit e88f9d225c
4 changed files with 23 additions and 23 deletions

View File

@ -6,18 +6,18 @@ import { LightScene } from './Scene'
export class MaxEcoSwitch extends AHomematicItem {
private ecoTopic: string
private mainTopic: string
private buttonTopic2: string
private buttonTopic1: string
private mainButtonTopic: string
private ecoButtonTopic: string
private state: string
constructor(floor: string, room: string, item: string, label: string, hmId: number,
mainScene: LightScene, ecoScene: LightScene) {
super(floor, room, item, label, hmId)
this.buttonTopic1 = `${this.deviceTopicPre}/1/PRESS`
this.buttonTopic2 = `${this.deviceTopicPre}/2/PRESS`
this.mainButtonTopic = `${this.deviceTopicPre}/1/PRESS`
this.ecoButtonTopic = `${this.deviceTopicPre}/2/PRESS`
this.subscribeTopics = [ this.buttonTopic1, this.buttonTopic2 ]
this.subscribeTopics = [ this.mainButtonTopic, this.ecoButtonTopic ]
this.mainTopic = mainScene.getStateTopic()
this.ecoTopic = ecoScene.getStateTopic()
@ -30,23 +30,23 @@ export class MaxEcoSwitch extends AHomematicItem {
processMessage(topic: string, payload: string) : void {
switch(this.state) {
case 'OFF':
if (topic == this.mainTopic) {
if (topic == this.mainButtonTopic) {
this.state = 'ON'
} else if (topic == this.ecoTopic) {
} else if (topic == this.ecoButtonTopic) {
this.state = 'ECO'
}
break
case 'ON':
if (topic == this.mainTopic) {
if (topic == this.mainButtonTopic) {
this.state = 'OFF'
} else if (topic == this.ecoTopic) {
} else if (topic == this.ecoButtonTopic) {
this.state = 'ECO'
}
break
case 'ECO':
if (topic == this.mainTopic) {
if (topic == this.mainButtonTopic) {
this.state = 'ON'
} else if (topic == this.ecoTopic) {
} else if (topic == this.ecoButtonTopic) {
this.state = 'OFF'
}
break
@ -63,4 +63,4 @@ export class MaxEcoSwitch extends AHomematicItem {
break
}
}
}
}

View File

@ -159,7 +159,7 @@ let ecoLightScene = new LightScene('Gnd', 'Hallway', 'EcoLight', 'EcoLight',
ecoLightScene.start()
allLabeledItems.push(ecoLightScene)
let ecoSwitch = new MaxEcoSwitch('Gnd', 'Hallway', 'EcoSwitch', 'EcoSwitch', 5, dayLightScene, ecoLightScene)
let ecoSwitch = new MaxEcoSwitch('Gnd', 'Hallway', 'EcoSwitch', 'EcoSwitch', 6, dayLightScene, ecoLightScene)
ecoSwitch.start()
let morningLightScene = new LightScene('Gnd', 'Hallway', 'MorningLight', 'MorningLight',