From 95a85e9886f6d99be1ba45b88876930e6bf0c505 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:30:51 +0200 Subject: [PATCH] Berry statedata fix non-printable delimiter --- tasmota/berry/examples/statedata.be | 10 +++++----- ...{discovery_statedata.be => statedata_v2.be} | 16 ++++++++-------- ...ry_statedata_version.be => statedata_v3.be} | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) rename tasmota/berry/examples/{discovery_statedata.be => statedata_v2.be} (97%) rename tasmota/berry/examples/{discovery_statedata_version.be => statedata_v3.be} (97%) diff --git a/tasmota/berry/examples/statedata.be b/tasmota/berry/examples/statedata.be index 714a7852d..a96e12d6b 100644 --- a/tasmota/berry/examples/statedata.be +++ b/tasmota/berry/examples/statedata.be @@ -64,14 +64,14 @@ class mqttdata_cls ipaddress = state['IPAddress'] # 192.168.2.123 end var last_seen = tasmota.rtc('local') - var line = format("%s,%s,%s,%d", topic, ipaddress, uptime, last_seen) + var line = format("%s\001%s\001%s\001%d", topic, ipaddress, uptime, last_seen) 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 + var topic_delim = format("%s\001", 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_comma) + if 0 == string.find(self.list_buffer[list_index], topic_delim) self.list_buffer.remove(list_index) # Remove current state list_size -= 1 # Continue for duplicates end @@ -121,7 +121,7 @@ class mqttdata_cls var list_index = 0 var list_size = size(self.list_buffer) while list_index < list_size - var splits = string.split(self.list_buffer[list_index], ",") + var splits = string.split(self.list_buffer[list_index], "\001") var last_seen = int(splits[3]) if time_window > last_seen # Remove offline devices self.list_buffer.remove(list_index) @@ -143,7 +143,7 @@ class mqttdata_cls end var msg = "" # Terminate two column table and open new table while list_index < list_size - var splits = string.split(self.list_buffer[list_index], ",") + var splits = string.split(self.list_buffer[list_index], "\001") var topic = splits[0] # topic or hostname var ipaddress = splits[1] var uptime = splits[2] diff --git a/tasmota/berry/examples/discovery_statedata.be b/tasmota/berry/examples/statedata_v2.be similarity index 97% rename from tasmota/berry/examples/discovery_statedata.be rename to tasmota/berry/examples/statedata_v2.be index b5b1fcd0c..163b8dc87 100644 --- a/tasmota/berry/examples/discovery_statedata.be +++ b/tasmota/berry/examples/statedata_v2.be @@ -62,14 +62,14 @@ class mqttdata_cls var hostname = config['hn'] var ipaddress = config['ip'] var devicename = config['dn'] - var line = format("%s,%s,%s,%s", topic, hostname, ipaddress, devicename) + var line = format("%s\001%s\001%s\001%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 + var topic_delim = format("%s\001", 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_comma) + if 0 == string.find(self.list_config[list_index], topic_delim) self.list_config.remove(list_index) # Remove current config list_size -= 1 # Continue for duplicates end @@ -112,14 +112,14 @@ class mqttdata_cls ipaddress = state['IPAddress'] # 192.168.2.208 end var last_seen = tasmota.rtc('local') - var line = format("%s,%s,%s,%d,%s", topic, ipaddress, uptime, last_seen, devicename) + var line = format("%s\001%s\001%s\001%d\001%s", topic, ipaddress, uptime, last_seen, devicename) 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 + var topic_delim = format("%s\001", 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_comma) + if 0 == string.find(self.list_buffer[list_index], topic_delim) self.list_buffer.remove(list_index) # Remove current state list_size -= 1 # Continue for duplicates end @@ -169,7 +169,7 @@ class mqttdata_cls var list_index = 0 var list_size = size(self.list_buffer) while list_index < list_size - var splits = string.split(self.list_buffer[list_index], ",") + var splits = string.split(self.list_buffer[list_index], "\001") var last_seen = int(splits[3]) if time_window > last_seen # Remove offline devices self.list_buffer.remove(list_index) @@ -191,7 +191,7 @@ class mqttdata_cls end var msg = "
" # Terminate two column table and open new table while list_index < list_size - var splits = string.split(self.list_buffer[list_index], ",") + var splits = string.split(self.list_buffer[list_index], "\001") var topic = splits[0] # topic or hostname var ipaddress = splits[1] var uptime = splits[2] diff --git a/tasmota/berry/examples/discovery_statedata_version.be b/tasmota/berry/examples/statedata_v3.be similarity index 97% rename from tasmota/berry/examples/discovery_statedata_version.be rename to tasmota/berry/examples/statedata_v3.be index 44bd6106c..427b1d1c4 100644 --- a/tasmota/berry/examples/discovery_statedata_version.be +++ b/tasmota/berry/examples/statedata_v3.be @@ -70,14 +70,14 @@ class mqttdata_cls var ipaddress = config['ip'] var devicename = config['dn'] var version = config['sw'] - var line = format("%s,%s,%s,%s,%s", topic, hostname, ipaddress, devicename, version) + var line = format("%s\001%s\001%s\001%s\001%s", topic, hostname, ipaddress, devicename, version) # 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 + var topic_delim = format("%s\001", 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_comma) + if 0 == string.find(self.list_config[list_index], topic_delim) self.list_config.remove(list_index) # Remove current config list_size -= 1 # Continue for duplicates end @@ -108,7 +108,7 @@ class mqttdata_cls var state = json.load(data) if state # Valid JSON state message - var config_splits = string.split(self.list_config[topic_index], ",") + var config_splits = string.split(self.list_config[topic_index], "\001") topic = config_splits[1] # Hostname var ipaddress = config_splits[2] var devicename = config_splits[3] @@ -121,14 +121,14 @@ class mqttdata_cls ipaddress = state['IPAddress'] # 192.168.2.208 end var last_seen = tasmota.rtc('local') - var line = format("%s,%s,%s,%d,%s,%s", topic, ipaddress, uptime, last_seen, devicename, version) + var line = format("%s\001%s\001%s\001%d\001%s\001%s", topic, ipaddress, uptime, last_seen, devicename, version) 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 + var topic_delim = format("%s\001", 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_comma) + if 0 == string.find(self.list_buffer[list_index], topic_delim) self.list_buffer.remove(list_index) # Remove current state list_size -= 1 # Continue for duplicates end @@ -195,7 +195,7 @@ class mqttdata_cls var list_index = 0 var list_size = size(self.list_buffer) while list_index < list_size - var splits = string.split(self.list_buffer[list_index], ",") + var splits = string.split(self.list_buffer[list_index], "\001") var last_seen = int(splits[3]) if time_window > last_seen # Remove offline devices self.list_buffer.remove(list_index) @@ -217,7 +217,7 @@ class mqttdata_cls end var msg = "
" # Terminate two column table and open new table while list_index < list_size - var splits = string.split(self.list_buffer[list_index], ",") + var splits = string.split(self.list_buffer[list_index], "\001") var topic = splits[0] # topic or hostname var ipaddress = splits[1] var uptime = splits[2]