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

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

View File

@ -152,6 +152,7 @@ allLabeledItems.push(bedRoomWolfgangBedLight)
let touchSwitchMultiButtonThing = new TouchSwitchMultiButtonThing('1st', 'Bedroom', 'Wolfgang',
[ new TouchSwitchButtonSingleItem(bedRoomWolfgangBedLight.getStateTopic())])
touchSwitchMultiButtonThing.start()
// Schlafzimmer Pattys Seite 13980756 24 1 13980753 24 1
let bedRoomPattysSide = new M433SwitchItem('1st', 'BedRoom', 'PattysSide', 'Pattys Seite Schlafzimmer', '13980756 24 1', '13980753 24 1')