homematic switch device feedback

This commit is contained in:
Wolfgang Hottgenroth
2018-01-04 20:45:45 +01:00
parent eb9e2acc30
commit 42e780cb69
2 changed files with 15 additions and 3 deletions

View File

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

View File

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