[DISC] Fix empty unique_id suffix for gateway entities (#2401)

createDiscoveryFromList() used column [2] as the unique id suffix of
gateway entities whenever it was non null. The gateway sensors (RF, RF2,
IR, Pilight, SRFB, RFM69, LORA, 2G, hcsr501...) pass "" there, so they
all got the unique_id "<MAC>-": entities of a multi module gateway
collide in Home Assistant, and the ids changed from the
"<MAC>-gatewayLORA" form used by v1.8.1, duplicating entities on
upgrade. Treat an empty suffix like a null one and fall back to the
name, as already done for column [11].

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pwshandClaude Opus 5.5 authored and GitHub committed 2026-10-12 06:52:18 -05:00
1 parent 3986d9d1f7
commit f06b4b1de6
1 file changed
+1 -1
+1 -1
View File
@@ -186,7 +186,7 @@ void createDiscoveryFromList(const char* mac,
for (int i = 0; i < sensorCount; i++) {
String unique_id;
if (gateway_entity) {
unique_id = getUniqueId(sensorList[i][2] ? sensorList[i][2] : sensorList[i][1], "");
unique_id = getUniqueId(sensorList[i][2] && sensorList[i][2][0] ? sensorList[i][2] : sensorList[i][1], "");
} else if (mac) {
unique_id = String(mac) + "-" + sensorList[i][1];
} else {