From 702925d7d06032540cfb06b4d5575c9fa2254625 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 9 Jan 2024 07:46:17 -0600 Subject: [PATCH] [DISC] Fix empty topic publication (#1858) --- main/ZmqttDiscovery.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index 124af60..4d531ec 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -413,6 +413,9 @@ void createDiscovery(const char* sensor_type, } void eraseTopic(const char* sensor_type, const char* unique_id) { + if (sensor_type == NULL || unique_id == NULL) { + return; + } String topic = String(discovery_Topic) + "/" + String(sensor_type) + "/" + String(unique_id) + "/config"; Log.trace(F("Erase entity discovery %s on %s" CR), String(sensor_type).c_str(), topic.c_str()); pubMQTT((char*)topic.c_str(), "", true); @@ -1228,7 +1231,7 @@ void pubMqttDiscovery() { "false", "true" //state_off, state_on ); -# define EntitiesCount 10 +# define EntitiesCount 9 const char* obsoleteEntities[EntitiesCount][2] = { // Remove previously created entities for version < 1.4.0 {"switch", "active_scan"}, // Replaced by adaptive scan