From cd52128e448f1dbc8c36f3a943c1577d93e3000c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 25 Jul 2018 02:30:58 +0200 Subject: [PATCH] Reverted batch instead of mean value --- platypush/plugins/adafruit/io.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platypush/plugins/adafruit/io.py b/platypush/plugins/adafruit/io.py index 5df864592..9700b1ccd 100644 --- a/platypush/plugins/adafruit/io.py +++ b/platypush/plugins/adafruit/io.py @@ -1,4 +1,5 @@ import ast +import statistics import time from threading import Thread @@ -101,8 +102,10 @@ class AdafruitIoPlugin(Plugin): for (feed, values) in data.items(): if values: + value = statistics.mean(values) + try: - self.send(feed, values, enqueue=False) + self.send(feed, value, enqueue=False) except ThrottlingError: self.logger.warning('Adafruit IO throttling threshold hit, taking a nap before retrying') time.sleep(self.throttle_seconds) @@ -128,10 +131,7 @@ 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 - if isinstance(value, list): - self.aio.send_batch_data(feed, value) - else: - self.aio.send(feed, value) + 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()