diff --git a/README.md b/README.md index 01ff80f..b12eaa7 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ If you restore a backup from a 32bit system to a new 64bit system, use the Rebui ### Configuration -You need to add the following to your `configuration.yaml` file: +You need to add the MQTT integration to Home Assistant either by going to Configuration -> Integrations and clicking the Add Integration button, or by adding the following to your `configuration.yaml` file: ``` mqtt: @@ -102,16 +102,8 @@ mqtt: password: !secret mqtt_password discovery: true discovery_prefix: homeassistant - birth_message: - topic: 'hass/status' - payload: 'online' - will_message: - topic: 'hass/status' - payload: 'offline' ``` -The above is used to notify the add-on when Home Assistant has started successfully and let the add-on send the discovery response (containing all devices). - The plugin needs you to configure some settings before working. You find these on the Add-on page after you've installed it. | Parameter | Value | diff --git a/plejd/MqttClient.js b/plejd/MqttClient.js index 4747d30..bdf1224 100644 --- a/plejd/MqttClient.js +++ b/plejd/MqttClient.js @@ -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'); @@ -100,7 +100,7 @@ class MqttClient extends EventEmitter { ? JSON.parse(message.toString()) : message.toString(); - if (topic === startTopic) { + if (startTopics.includes(topic)) { logger.info('Home Assistant has started. lets do discovery.'); self.emit('connected'); } else if (topic.includes('set')) {