This commit is contained in:
Wolfgang Hottgenroth
2018-01-31 21:23:57 +01:00
parent 48fe3be0e9
commit a104b53509
4 changed files with 12 additions and 8 deletions

View File

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