dimmer
This commit is contained in:
9
dist/TouchSwitchMultiButtonThing.js
vendored
9
dist/TouchSwitchMultiButtonThing.js
vendored
@ -8,7 +8,7 @@ class TouchSwitchButtonSingleItem {
|
||||
this.actionTopic = actionTopic;
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
switch (topic) {
|
||||
switch (payload) {
|
||||
case 'SHORT':
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'SHORT', true);
|
||||
break;
|
||||
@ -30,7 +30,7 @@ class TouchSwitchMultiButtonThing extends AItem_1.AItem {
|
||||
constructor(floor, room, item, itemObjs) {
|
||||
super(floor, room, item, '');
|
||||
this.itemObjs = itemObjs;
|
||||
this.deviceTopicPre = `IoT/Touchswitch/${this.floor}/${this.room}/${this.item}`;
|
||||
this.deviceTopicPre = `IoT/TouchSwitch/${this.floor}/${this.room}/${this.item}`;
|
||||
this.subscribeTopics = [
|
||||
`${this.deviceTopicPre}/#`
|
||||
];
|
||||
@ -38,9 +38,10 @@ class TouchSwitchMultiButtonThing extends AItem_1.AItem {
|
||||
processMessage(topic, payload) {
|
||||
logger.info(`TSMBT: ${topic}, ${payload}`);
|
||||
let buttonRelatedPart = topic.substring(this.deviceTopicPre.length + 1);
|
||||
let buttonIdx = parseInt(buttonRelatedPart.substring(0, buttonRelatedPart.indexOf('/')));
|
||||
let buttonIdx = parseInt(buttonRelatedPart);
|
||||
logger.info(`TSMBT: pre: ${this.deviceTopicPre}, buttonRelatedPart: ${buttonRelatedPart}, buttonIdx: ${buttonIdx}`);
|
||||
if (buttonIdx >= 1 && buttonIdx <= this.itemObjs.length) {
|
||||
this.itemObjs[buttonIdx - 1].processMessage(buttonRelatedPart.substring(buttonRelatedPart.indexOf('/') + 1), payload);
|
||||
this.itemObjs[buttonIdx - 1].processMessage('-', payload);
|
||||
}
|
||||
else {
|
||||
logger.warn(`TSMBT: no handling available for ${topic}`);
|
||||
|
1
dist/main.js
vendored
1
dist/main.js
vendored
@ -119,6 +119,7 @@ let bedRoomWolfgangBedLight = new HueColorBulbItem_1.HueColorBulbItem('1st', 'Be
|
||||
bedRoomWolfgangBedLight.start();
|
||||
allLabeledItems.push(bedRoomWolfgangBedLight);
|
||||
let touchSwitchMultiButtonThing = new TouchSwitchMultiButtonThing_1.TouchSwitchMultiButtonThing('1st', 'Bedroom', 'Wolfgang', [new TouchSwitchMultiButtonThing_1.TouchSwitchButtonSingleItem(bedRoomWolfgangBedLight.getStateTopic())]);
|
||||
touchSwitchMultiButtonThing.start();
|
||||
// Schlafzimmer Pattys Seite 13980756 24 1 13980753 24 1
|
||||
let bedRoomPattysSide = new M433SwitchItem_1.M433SwitchItem('1st', 'BedRoom', 'PattysSide', 'Pattys Seite Schlafzimmer', '13980756 24 1', '13980753 24 1');
|
||||
bedRoomPattysSide.start();
|
||||
|
@ -11,7 +11,7 @@ export class TouchSwitchButtonSingleItem {
|
||||
}
|
||||
|
||||
processMessage(topic: string, payload: string) {
|
||||
switch(topic) {
|
||||
switch(payload) {
|
||||
case 'SHORT':
|
||||
mqttHandler.send(this.actionTopic, 'SHORT', true)
|
||||
break
|
||||
@ -36,7 +36,7 @@ export class TouchSwitchMultiButtonThing extends AItem {
|
||||
constructor(floor: string, room: string, item: string, itemObjs: TouchSwitchButtonSingleItem[]) {
|
||||
super(floor, room, item, '')
|
||||
this.itemObjs = itemObjs
|
||||
this.deviceTopicPre = `IoT/Touchswitch/${this.floor}/${this.room}/${this.item}`
|
||||
this.deviceTopicPre = `IoT/TouchSwitch/${this.floor}/${this.room}/${this.item}`
|
||||
this.subscribeTopics = [
|
||||
`${this.deviceTopicPre}/#`
|
||||
]
|
||||
@ -45,9 +45,10 @@ export class TouchSwitchMultiButtonThing extends AItem {
|
||||
processMessage(topic: string, payload: string) {
|
||||
logger.info(`TSMBT: ${topic}, ${payload}`)
|
||||
let buttonRelatedPart = topic.substring(this.deviceTopicPre.length+1)
|
||||
let buttonIdx = parseInt(buttonRelatedPart.substring(0, buttonRelatedPart.indexOf('/')))
|
||||
let buttonIdx = parseInt(buttonRelatedPart)
|
||||
logger.info(`TSMBT: pre: ${this.deviceTopicPre}, buttonRelatedPart: ${buttonRelatedPart}, buttonIdx: ${buttonIdx}`)
|
||||
if (buttonIdx >= 1 && buttonIdx <= this.itemObjs.length) {
|
||||
this.itemObjs[buttonIdx-1].processMessage(buttonRelatedPart.substring(buttonRelatedPart.indexOf('/')+1), payload)
|
||||
this.itemObjs[buttonIdx-1].processMessage('-', payload)
|
||||
} else {
|
||||
logger.warn(`TSMBT: no handling available for ${topic}`)
|
||||
}
|
||||
|
Reference in New Issue
Block a user