From 2a3bcb0753a81a339177de4e11b84e2853a23b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 28 Jan 2021 14:24:04 +0100 Subject: [PATCH] Listen to Home Assistant default birth topic by default --- README.md | 10 +--------- plejd/MqttClient.js | 6 +++--- 2 files changed, 4 insertions(+), 12 deletions(-) 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..fb5b185 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');