Skip to content

Commit

Permalink
fix(mqtt): Only migrate HAss topics if enabled (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
depau committed May 10, 2021
1 parent a05dcfe commit eb2edaf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/mqtt/MqttController.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ class MqttController {
await HassAnchor.getTopicReference(HassAnchor.REFERENCE.AVAILABILITY).post(this.stateTopic);

// TODO: temporary, remove!
await this.asyncClient.subscribe(this.getHassMigrationTopics());
if (this.hassEnabled) {
await this.asyncClient.subscribe(this.getHassMigrationTopics());
}

await this.robotHandle.configure();
if (this.hassEnabled) {
Expand All @@ -319,11 +321,12 @@ class MqttController {

this.client.on("message", (topic, message) => {
// TODO: temporary, remove!
if (topic.startsWith(this.hassController.autoconfPrefix + "/") && message.toString().length > 0) {
this.migrateHass(topic).then();
return;
if (this.hassEnabled) {
if (topic.startsWith(this.hassController.autoconfPrefix + "/") && message.toString().length > 0) {
this.migrateHass(topic).then();
return;
}
}

if (!Object.prototype.hasOwnProperty.call(this.subscriptions, topic)) {
return;
}
Expand Down

0 comments on commit eb2edaf

Please sign in to comment.