From 39cdbfcc189f1d763b6a170dbb31a0ab7cdc1f81 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sun, 21 Jun 2026 08:10:21 +1000 Subject: [PATCH] PLG: add connections attribute to mqtt #1681 --- front/plugins/_publisher_mqtt/mqtt.py | 11 ++++++++--- front/plugins/rest_import/README.md | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/front/plugins/_publisher_mqtt/mqtt.py b/front/plugins/_publisher_mqtt/mqtt.py index 438264b3..f40c50dd 100755 --- a/front/plugins/_publisher_mqtt/mqtt.py +++ b/front/plugins/_publisher_mqtt/mqtt.py @@ -156,6 +156,13 @@ class sensor_config: self.state_topic = f'{topic_root}/{self.sensorType}/{self.deviceId}/state' self.unique_id = f'{self.deviceId}_sensor_{self.sensorName}' + if self.mac != "": + connections_snippet = [ + ["mac", self.mac] + ] + else: + connections_snippet = [] + # Update the message dictionary, expanding it without overwriting self.message.update({ "name": self.sensorName, @@ -166,9 +173,7 @@ class sensor_config: "identifiers": [f"{self.deviceId}_sensor"], "manufacturer": "NetAlertX", "name": self.deviceName, - "connections": [ - ["mac", self.mac] - ], + "connections": connections_snippet }, "icon": f'mdi:{self.icon}' }) diff --git a/front/plugins/rest_import/README.md b/front/plugins/rest_import/README.md index 78d1f2ab..6d1d317a 100644 --- a/front/plugins/rest_import/README.md +++ b/front/plugins/rest_import/README.md @@ -48,7 +48,7 @@ Enable **Generate Fake MAC** when the API does not expose MAC addresses (e.g. re ### Example: OPNsense Dnsmasq API -See the [OPNsense configuration guide](https://docs.netalertx.com/PLUGINS) for details. +See the [OPNsense configuration guide](https://docs.netalertx.com/REST_IMPORT) for details. **Response:** ```json