PLG: add connections attribute to mqtt #1681

This commit is contained in:
jokob-sk
2026-06-21 08:10:21 +10:00
parent b6c8f9be5d
commit 39cdbfcc18
2 changed files with 9 additions and 4 deletions

View File

@@ -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}'
})

View File

@@ -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