dimmer
This commit is contained in:
@ -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