Listen to Home Assistant default birth topic by default

This commit is contained in:
Thomas Lovén 2021-01-28 14:24:04 +01:00
parent 61d16fc07c
commit 2a3bcb0753
2 changed files with 4 additions and 12 deletions

View file

@ -2,7 +2,7 @@ const EventEmitter = require('events');
const mqtt = require('mqtt');
const Logger = require('./Logger');
const startTopic = 'hass/status';
const startTopics = ['hass/status', 'homeassistant/status'];
const logger = Logger.getLogger('plejd-mqtt');
@ -74,9 +74,9 @@ class MqttClient extends EventEmitter {
this.client.on('connect', () => {
logger.info('Connected to MQTT.');
this.client.subscribe(startTopic, (err) => {
this.client.subscribe(startTopics, (err) => {
if (err) {
logger.error(`Unable to subscribe to ${startTopic}`);
logger.error(`Unable to subscribe to status topics`);
}
self.emit('connected');