Reverted batch instead of mean value
This commit is contained in:
parent
5d8cc403dc
commit
cd52128e44
1 changed files with 5 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
import ast
|
import ast
|
||||||
|
import statistics
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
@ -101,8 +102,10 @@ class AdafruitIoPlugin(Plugin):
|
||||||
|
|
||||||
for (feed, values) in data.items():
|
for (feed, values) in data.items():
|
||||||
if values:
|
if values:
|
||||||
|
value = statistics.mean(values)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.send(feed, values, enqueue=False)
|
self.send(feed, value, enqueue=False)
|
||||||
except ThrottlingError:
|
except ThrottlingError:
|
||||||
self.logger.warning('Adafruit IO throttling threshold hit, taking a nap before retrying')
|
self.logger.warning('Adafruit IO throttling threshold hit, taking a nap before retrying')
|
||||||
time.sleep(self.throttle_seconds)
|
time.sleep(self.throttle_seconds)
|
||||||
|
@ -128,9 +131,6 @@ class AdafruitIoPlugin(Plugin):
|
||||||
|
|
||||||
if not self.throttle_seconds or not enqueue:
|
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 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:
|
else:
|
||||||
# Otherwise send it to the Redis queue to be picked up by the throttler thread
|
# Otherwise send it to the Redis queue to be picked up by the throttler thread
|
||||||
|
|
Loading…
Reference in a new issue