From c901fa0832696287b7c967497007642e1eac75b5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 24 Sep 2025 17:04:25 +0200 Subject: [PATCH] Fix examples remove uniqueness --- tasmota/berry/examples/discovery_statedata.be | 10 +++++++--- tasmota/berry/examples/statedata.be | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tasmota/berry/examples/discovery_statedata.be b/tasmota/berry/examples/discovery_statedata.be index 85dd30ecf..b5b1fcd0c 100644 --- a/tasmota/berry/examples/discovery_statedata.be +++ b/tasmota/berry/examples/discovery_statedata.be @@ -63,11 +63,13 @@ class mqttdata_cls var ipaddress = config['ip'] var devicename = config['dn'] var line = format("%s,%s,%s,%s", topic, hostname, ipaddress, devicename) +# tasmota.log(format("STD: 111 Size %03d, Topic '%s', Line '%s'", self.list_config.size(), topic, line), 3) if self.list_config.size() var list_index = 0 var list_size = size(self.list_config) + var topic_comma = format("%s,", topic) # Add find delimiter while list_index < list_size # Use while loop as counter is decremented - if 0 == string.find(self.list_config[list_index], topic) + if 0 == string.find(self.list_config[list_index], topic_comma) self.list_config.remove(list_index) # Remove current config list_size -= 1 # Continue for duplicates end @@ -75,7 +77,7 @@ class mqttdata_cls end end self.list_config.push(line) # Add (re-discovered) config as last entry -# tasmota.log(format("STD: Size %d, Line '%s'", self.list_config.size(), line), 3) +# tasmota.log(format("STD: 222 Size %03d, Topic '%s', Line '%s'", self.list_config.size(), topic, line), 3) end end @@ -93,6 +95,7 @@ class mqttdata_cls break end end +# tasmota.log(format("STD: Topic '%s', Index %d, Size %d, Line '%s'", topic, topic_index, self.list_config.size(), self.list_config[topic_index]), 3) if topic_index == -1 return true end # Assume topic is in retained discovery list var state = json.load(data) @@ -114,8 +117,9 @@ class mqttdata_cls if self.list_buffer.size() var list_index = 0 var list_size = size(self.list_buffer) + var topic_comma = format("%s,", topic) # Add find delimiter while list_index < list_size # Use while loop as counter is decremented - if 0 == string.find(self.list_buffer[list_index], topic) + if 0 == string.find(self.list_buffer[list_index], topic_comma) self.list_buffer.remove(list_index) # Remove current state list_size -= 1 # Continue for duplicates end diff --git a/tasmota/berry/examples/statedata.be b/tasmota/berry/examples/statedata.be index a41b94f57..714a7852d 100644 --- a/tasmota/berry/examples/statedata.be +++ b/tasmota/berry/examples/statedata.be @@ -69,8 +69,9 @@ class mqttdata_cls if self.list_buffer.size() var list_index = 0 var list_size = size(self.list_buffer) + var topic_comma = format("%s,", topic) # Add find delimiter while list_index < list_size # Use while loop as counter is decremented - if 0 == string.find(self.list_buffer[list_index], topic) + if 0 == string.find(self.list_buffer[list_index], topic_comma) self.list_buffer.remove(list_index) # Remove current state list_size -= 1 # Continue for duplicates end @@ -150,14 +151,14 @@ class mqttdata_cls msg += "