From 6dc86635a4b28b16f7643a8cdb1cd988ef314417 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 25 Jul 2018 02:18:20 +0200 Subject: [PATCH] Send the whole batch of values in the throttler thread instead of getting the mean --- platypush/plugins/adafruit/io.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/adafruit/io.py b/platypush/plugins/adafruit/io.py index 161d0789ff..d5fdf5d344 100644 --- a/platypush/plugins/adafruit/io.py +++ b/platypush/plugins/adafruit/io.py @@ -1,5 +1,4 @@ import ast -import statistics import time from threading import Thread @@ -100,8 +99,7 @@ class AdafruitIoPlugin(Plugin): for (feed, values) in data.items(): if values: - value = statistics.mean(values) - self.send(feed, value, enqueue=False) + self.send(feed, values, enqueue=False) last_processed_batch_timestamp = time.time() data = {} @@ -125,7 +123,10 @@ class AdafruitIoPlugin(Plugin): if not self.throttle_seconds or not enqueue: # If no throttling is configured, or enqueue is false then send the value directly to Adafruit - self.aio.send(feed, value) + if isinstance(value, list): + self.aio.send_batch_data(feed, value) + else: + self.aio.send(feed, value) else: # Otherwise send it to the Redis queue to be picked up by the throttler thread redis = self._get_redis()