Send the whole batch of values in the throttler thread instead of getting the mean
This commit is contained in:
parent
db98e6e05a
commit
6dc86635a4
1 changed files with 5 additions and 4 deletions
|
@ -1,5 +1,4 @@
|
||||||
import ast
|
import ast
|
||||||
import statistics
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
@ -100,8 +99,7 @@ class AdafruitIoPlugin(Plugin):
|
||||||
|
|
||||||
for (feed, values) in data.items():
|
for (feed, values) in data.items():
|
||||||
if values:
|
if values:
|
||||||
value = statistics.mean(values)
|
self.send(feed, values, enqueue=False)
|
||||||
self.send(feed, value, enqueue=False)
|
|
||||||
|
|
||||||
last_processed_batch_timestamp = time.time()
|
last_processed_batch_timestamp = time.time()
|
||||||
data = {}
|
data = {}
|
||||||
|
@ -125,7 +123,10 @@ 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
|
||||||
self.aio.send(feed, value)
|
if isinstance(value, list):
|
||||||
|
self.aio.send_batch_data(feed, value)
|
||||||
|
else:
|
||||||
|
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
|
||||||
redis = self._get_redis()
|
redis = self._get_redis()
|
||||||
|
|
Loading…
Reference in a new issue