From 3c4898d8cc819513dfb6956074acf1dbf37c244d Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Sat, 25 Oct 2025 20:40:43 +1000 Subject: [PATCH 1/3] client: Skip empty results If ttn_parse() returns an empty results let's skip it, otherwise we can end up overwritting data with an empty packet if multiple packets have been sent. Signed-off-by: Alistair Francis --- src/ttn_client/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ttn_client/client.py b/src/ttn_client/client.py index 1364271..ee3d405 100644 --- a/src/ttn_client/client.py +++ b/src/ttn_client/client.py @@ -103,6 +103,11 @@ async def __storage_api_call(self, options) -> DATA_TYPE: # Get device_id and uplink_message from measurement device_id = application_up["end_device_ids"]["device_id"] - ttn_values[device_id] = ttn_parse(application_up) + ttn_output = ttn_parse(application_up) + + if ttn_output == {}: + continue + + ttn_values[device_id] = ttn_output return ttn_values From f127d619fd0c200ce86c7939544becd1cd729ea2 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Sat, 25 Oct 2025 20:42:29 +1000 Subject: [PATCH 2/3] client: OR together the dictionary parsing OR together all of the results of ttn_parse() so that we don't miss any data. According to PEP0584 (https://peps.python.org/pep-0584/#specification) the newset value should be used if the value is set multiple times. Signed-off-by: Alistair Francis --- src/ttn_client/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ttn_client/client.py b/src/ttn_client/client.py index ee3d405..73fed44 100644 --- a/src/ttn_client/client.py +++ b/src/ttn_client/client.py @@ -108,6 +108,9 @@ async def __storage_api_call(self, options) -> DATA_TYPE: if ttn_output == {}: continue - ttn_values[device_id] = ttn_output + if device_id in ttn_values: + ttn_values[device_id] |= ttn_output + else: + ttn_values[device_id] = ttn_output return ttn_values From 5b0d5d84cd6a1dd76ec6fc0d54985e388ff8030c Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Sat, 25 Oct 2025 20:49:54 +1000 Subject: [PATCH 3/3] client: Add some more debug prints Signed-off-by: Alistair Francis --- src/ttn_client/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ttn_client/client.py b/src/ttn_client/client.py index 73fed44..9fb156f 100644 --- a/src/ttn_client/client.py +++ b/src/ttn_client/client.py @@ -108,6 +108,8 @@ async def __storage_api_call(self, options) -> DATA_TYPE: if ttn_output == {}: continue + _LOGGER.debug("TTN parsed values: %s", ttn_output) + if device_id in ttn_values: ttn_values[device_id] |= ttn_output else: