homematic switch device feedback
This commit is contained in:
@ -5,8 +5,9 @@ class AHomematicItem extends AItem {
|
||||
constructor(floor, room, item, hmId) {
|
||||
super(floor, room, item);
|
||||
this.hmId = hmId;
|
||||
this.actionTopicPre = `homegear/instance1/set/${this.hmId}`;
|
||||
this.deviceTopicPre = `homegear/instance1/plain/${this.hmId}`;
|
||||
this.homegearTopicPre = 'homegear/instance1';
|
||||
this.actionTopicPre = `${this.homegearTopicPre}/set/${this.hmId}`;
|
||||
this.deviceTopicPre = `${this.homegearTopicPre}/plain/${this.hmId}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,11 @@ class HomematicSwitchItem extends AHomematicItem {
|
||||
super(floor, room, item, hmId);
|
||||
this.stateTopic = `${this.topicFirstPart}/state`;
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||
this.deviceFeedbackTopic = `${this.deviceTopicPre}/1/STATE`;
|
||||
this.actionTopic = `${this.actionTopicPre}/1/STATE`;
|
||||
this.subscribeTopics = [
|
||||
this.stateTopic
|
||||
this.stateTopic,
|
||||
this.deviceFeedbackTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
@ -31,6 +33,15 @@ class HomematicSwitchItem extends AHomematicItem {
|
||||
this.oldState = this.state;
|
||||
}
|
||||
break;
|
||||
case this.deviceFeedbackTopic:
|
||||
if (payload == 'true') {
|
||||
this.state = 'ON';
|
||||
} else {
|
||||
this.state = 'OFF';
|
||||
}
|
||||
this.oldState = this.state;
|
||||
mqtt.send(this.stateFeedbackTopic, this.state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user