From 76724240f46d1c08b890938595a38c7c2593b39b Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 16 Jan 2023 10:17:59 -0600 Subject: [PATCH] Add a check on device id before concatenating it to the device name (#1398) to avoid concatenating an unknown array --- main/ZmqttDiscovery.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index b0670a1..03d8e7c 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -332,7 +332,7 @@ void createDiscovery(const char* sensor_type, identifiers.add(String(getMacAddress())); } else { //The Connections - if (device_id[0] != 0) { + if (device_id[0]) { JsonArray connections = device.createNestedArray("connections"); JsonArray connection_mac = connections.createNestedArray(); connection_mac.add("mac"); @@ -352,7 +352,7 @@ void createDiscovery(const char* sensor_type, // generate unique device name by adding the second half of the device_id only if device_name and device_id are different if (device_name[0]) { - if (strcmp(device_id, device_name) != 0) { + if (strcmp(device_id, device_name) != 0 && device_id[0]) { device["name"] = device_name + String("-") + String(device_id + 6); } else { device["name"] = device_name;