From 0beea18adbbfee8a2d3ff31d3518aaf91326574d Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 28 Sep 2020 19:43:04 +0200 Subject: [PATCH] Fix devices being undiscovered from Home Assistant when a non-standard Home Assistant discovery topic is used. #4480 --- lib/extension/homeassistant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 1e06de4e..3bcb8f48 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -5,7 +5,6 @@ const zigbee2mqttVersion = require('../../package.json').version; const Extension = require('./extension'); const objectAssignDeep = require(`object-assign-deep`); const stringify = require('json-stable-stringify-without-jsonify'); -const discoveryRegex = new RegExp(`homeassistant/(.*)/(.*)/(.*)/config`); const cfg = { // Binary sensor @@ -2425,6 +2424,7 @@ class HomeAssistant extends Extension { } onMQTTMessage(topic, message) { + const discoveryRegex = new RegExp(`${this.discoveryTopic}/(.*)/(.*)/(.*)/config`); const discoveryMatch = topic.match(discoveryRegex); const isDeviceAutomation = discoveryMatch && discoveryMatch[1] === 'device_automation'; if (discoveryMatch) {