From 0f8b91d0f5c55b8d17479df14221c1cc2c804402 Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Thu, 12 Sep 2024 16:09:45 -0700 Subject: [PATCH] only add diffs to last diff messages --- farmbot/functions/broker.py | 5 ++--- tests/tests_main.py | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/farmbot/functions/broker.py b/farmbot/functions/broker.py index fdbf1c5..59bb6ca 100644 --- a/farmbot/functions/broker.py +++ b/farmbot/functions/broker.py @@ -143,15 +143,14 @@ def on_message(_client, _userdata, msg): add_message(path_channel, payload) if diff_only: - diff = payload key = path_channel if len(path) > 0 else channel_key last_messages = self.state.last_messages.get(key, []) if len(last_messages) > 1: current = last_messages[-1] previous = last_messages[-2] diff, _is_different = difference(current, previous) - payload = diff - add_message(f"{channel_key}_diffs", payload) + payload = diff + add_message(f"{channel_key}_diffs", payload) self.state.print_status(description="", update_only=True) description = "New message" diff --git a/tests/tests_main.py b/tests/tests_main.py index 631b078..335134c 100644 --- a/tests/tests_main.py +++ b/tests/tests_main.py @@ -629,7 +629,6 @@ def patched_sleep(_seconds): {'location_data': {'position': {'x': 4, 'y': 14, 'z': 100}}} ]) self.assertEqual(self.fb.state.last_messages['status_diffs'], [ - {'x': 0, 'y': 10, 'z': 100}, {'x': 1, 'y': 11}, {'extra': {'idx': 2}, 'x': 2, 'y': 12}, {'extra': {'idx': 3}, 'x': 3, 'y': 13},