From 0ffa6554177f9e163b96a391f729323815e75cbd Mon Sep 17 00:00:00 2001 From: jonathan Date: Thu, 20 Apr 2023 18:46:56 +0100 Subject: [PATCH] Advertise with device name, if configured --- lib/discovery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/discovery.js b/lib/discovery.js index 7455709..f131ccd 100644 --- a/lib/discovery.js +++ b/lib/discovery.js @@ -166,8 +166,8 @@ async function onDiscovery(peripheral) { if (config.homeassistant) homeassistant.configDiscovery(decoded, dev, peripheral, d.uuid); for (var k in decoded) { - if (config.mqtt_advertise) mqtt.send(config.mqtt_prefix + "/advertise/" + id + "/" + k, JSON.stringify(decoded[k])); - if (config.mqtt_format_decoded_key_topic) mqtt.send(config.mqtt_prefix + "/" + k + "/" + id, JSON.stringify(decoded[k])); + if (config.mqtt_advertise) mqtt.send(config.mqtt_prefix + "/advertise/" + dev.name + "/" + k, JSON.stringify(decoded[k])); + if (config.mqtt_format_decoded_key_topic) mqtt.send(config.mqtt_prefix + "/" + k + "/" + dev.name, JSON.stringify(decoded[k])); } if (config.mqtt_format_json) {