fix MaxSwitch
This commit is contained in:
18
dist/MaxEcoSwitch.js
vendored
18
dist/MaxEcoSwitch.js
vendored
@ -5,9 +5,9 @@ const AHomematicItem_1 = require("./AHomematicItem");
|
|||||||
class MaxEcoSwitch extends AHomematicItem_1.AHomematicItem {
|
class MaxEcoSwitch extends AHomematicItem_1.AHomematicItem {
|
||||||
constructor(floor, room, item, label, hmId, mainScene, ecoScene) {
|
constructor(floor, room, item, label, hmId, mainScene, ecoScene) {
|
||||||
super(floor, room, item, label, hmId);
|
super(floor, room, item, label, hmId);
|
||||||
this.buttonTopic1 = `${this.deviceTopicPre}/1/PRESS`;
|
this.mainButtonTopic = `${this.deviceTopicPre}/1/PRESS`;
|
||||||
this.buttonTopic2 = `${this.deviceTopicPre}/2/PRESS`;
|
this.ecoButtonTopic = `${this.deviceTopicPre}/2/PRESS`;
|
||||||
this.subscribeTopics = [this.buttonTopic1, this.buttonTopic2];
|
this.subscribeTopics = [this.mainButtonTopic, this.ecoButtonTopic];
|
||||||
this.mainTopic = mainScene.getStateTopic();
|
this.mainTopic = mainScene.getStateTopic();
|
||||||
this.ecoTopic = ecoScene.getStateTopic();
|
this.ecoTopic = ecoScene.getStateTopic();
|
||||||
this.state = 'OFF';
|
this.state = 'OFF';
|
||||||
@ -15,26 +15,26 @@ class MaxEcoSwitch extends AHomematicItem_1.AHomematicItem {
|
|||||||
processMessage(topic, payload) {
|
processMessage(topic, payload) {
|
||||||
switch (this.state) {
|
switch (this.state) {
|
||||||
case 'OFF':
|
case 'OFF':
|
||||||
if (topic == this.mainTopic) {
|
if (topic == this.mainButtonTopic) {
|
||||||
this.state = 'ON';
|
this.state = 'ON';
|
||||||
}
|
}
|
||||||
else if (topic == this.ecoTopic) {
|
else if (topic == this.ecoButtonTopic) {
|
||||||
this.state = 'ECO';
|
this.state = 'ECO';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ON':
|
case 'ON':
|
||||||
if (topic == this.mainTopic) {
|
if (topic == this.mainButtonTopic) {
|
||||||
this.state = 'OFF';
|
this.state = 'OFF';
|
||||||
}
|
}
|
||||||
else if (topic == this.ecoTopic) {
|
else if (topic == this.ecoButtonTopic) {
|
||||||
this.state = 'ECO';
|
this.state = 'ECO';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ECO':
|
case 'ECO':
|
||||||
if (topic == this.mainTopic) {
|
if (topic == this.mainButtonTopic) {
|
||||||
this.state = 'ON';
|
this.state = 'ON';
|
||||||
}
|
}
|
||||||
else if (topic == this.ecoTopic) {
|
else if (topic == this.ecoButtonTopic) {
|
||||||
this.state = 'OFF';
|
this.state = 'OFF';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
2
dist/main.js
vendored
2
dist/main.js
vendored
@ -120,7 +120,7 @@ let ecoLightScene = new Scene_1.LightScene('Gnd', 'Hallway', 'EcoLight', 'EcoLig
|
|||||||
]);
|
]);
|
||||||
ecoLightScene.start();
|
ecoLightScene.start();
|
||||||
allLabeledItems.push(ecoLightScene);
|
allLabeledItems.push(ecoLightScene);
|
||||||
let ecoSwitch = new MaxEcoSwitch_1.MaxEcoSwitch('Gnd', 'Hallway', 'EcoSwitch', 'EcoSwitch', 5, dayLightScene, ecoLightScene);
|
let ecoSwitch = new MaxEcoSwitch_1.MaxEcoSwitch('Gnd', 'Hallway', 'EcoSwitch', 'EcoSwitch', 6, dayLightScene, ecoLightScene);
|
||||||
ecoSwitch.start();
|
ecoSwitch.start();
|
||||||
let morningLightScene = new Scene_1.LightScene('Gnd', 'Hallway', 'MorningLight', 'MorningLight', [
|
let morningLightScene = new Scene_1.LightScene('Gnd', 'Hallway', 'MorningLight', 'MorningLight', [
|
||||||
kitchenWindowLight, kitchenCeilingLight, hallwayDeskLight, hallwayWardrobeLight,
|
kitchenWindowLight, kitchenCeilingLight, hallwayDeskLight, hallwayWardrobeLight,
|
||||||
|
@ -6,18 +6,18 @@ import { LightScene } from './Scene'
|
|||||||
export class MaxEcoSwitch extends AHomematicItem {
|
export class MaxEcoSwitch extends AHomematicItem {
|
||||||
private ecoTopic: string
|
private ecoTopic: string
|
||||||
private mainTopic: string
|
private mainTopic: string
|
||||||
private buttonTopic2: string
|
private mainButtonTopic: string
|
||||||
private buttonTopic1: string
|
private ecoButtonTopic: string
|
||||||
private state: string
|
private state: string
|
||||||
|
|
||||||
constructor(floor: string, room: string, item: string, label: string, hmId: number,
|
constructor(floor: string, room: string, item: string, label: string, hmId: number,
|
||||||
mainScene: LightScene, ecoScene: LightScene) {
|
mainScene: LightScene, ecoScene: LightScene) {
|
||||||
super(floor, room, item, label, hmId)
|
super(floor, room, item, label, hmId)
|
||||||
|
|
||||||
this.buttonTopic1 = `${this.deviceTopicPre}/1/PRESS`
|
this.mainButtonTopic = `${this.deviceTopicPre}/1/PRESS`
|
||||||
this.buttonTopic2 = `${this.deviceTopicPre}/2/PRESS`
|
this.ecoButtonTopic = `${this.deviceTopicPre}/2/PRESS`
|
||||||
|
|
||||||
this.subscribeTopics = [ this.buttonTopic1, this.buttonTopic2 ]
|
this.subscribeTopics = [ this.mainButtonTopic, this.ecoButtonTopic ]
|
||||||
|
|
||||||
this.mainTopic = mainScene.getStateTopic()
|
this.mainTopic = mainScene.getStateTopic()
|
||||||
this.ecoTopic = ecoScene.getStateTopic()
|
this.ecoTopic = ecoScene.getStateTopic()
|
||||||
@ -30,23 +30,23 @@ export class MaxEcoSwitch extends AHomematicItem {
|
|||||||
processMessage(topic: string, payload: string) : void {
|
processMessage(topic: string, payload: string) : void {
|
||||||
switch(this.state) {
|
switch(this.state) {
|
||||||
case 'OFF':
|
case 'OFF':
|
||||||
if (topic == this.mainTopic) {
|
if (topic == this.mainButtonTopic) {
|
||||||
this.state = 'ON'
|
this.state = 'ON'
|
||||||
} else if (topic == this.ecoTopic) {
|
} else if (topic == this.ecoButtonTopic) {
|
||||||
this.state = 'ECO'
|
this.state = 'ECO'
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'ON':
|
case 'ON':
|
||||||
if (topic == this.mainTopic) {
|
if (topic == this.mainButtonTopic) {
|
||||||
this.state = 'OFF'
|
this.state = 'OFF'
|
||||||
} else if (topic == this.ecoTopic) {
|
} else if (topic == this.ecoButtonTopic) {
|
||||||
this.state = 'ECO'
|
this.state = 'ECO'
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'ECO':
|
case 'ECO':
|
||||||
if (topic == this.mainTopic) {
|
if (topic == this.mainButtonTopic) {
|
||||||
this.state = 'ON'
|
this.state = 'ON'
|
||||||
} else if (topic == this.ecoTopic) {
|
} else if (topic == this.ecoButtonTopic) {
|
||||||
this.state = 'OFF'
|
this.state = 'OFF'
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -63,4 +63,4 @@ export class MaxEcoSwitch extends AHomematicItem {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ let ecoLightScene = new LightScene('Gnd', 'Hallway', 'EcoLight', 'EcoLight',
|
|||||||
ecoLightScene.start()
|
ecoLightScene.start()
|
||||||
allLabeledItems.push(ecoLightScene)
|
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()
|
ecoSwitch.start()
|
||||||
|
|
||||||
let morningLightScene = new LightScene('Gnd', 'Hallway', 'MorningLight', 'MorningLight',
|
let morningLightScene = new LightScene('Gnd', 'Hallway', 'MorningLight', 'MorningLight',
|
||||||
|
Reference in New Issue
Block a user