summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@turin.home>2022-01-16 13:36:16 +0000
committerroot <root@turin.home>2022-01-16 13:36:16 +0000
commit7104802fedc605cb386339733a6162e10da2aabd (patch)
tree4f3e58920a51b2214a6901ce86c7bce01ff7b9ca
parent4f95a0a75be6948a7eb36a8f5563301e740c8d32 (diff)
Add rolling average to heating with queue
-rw-r--r--heating.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/heating.py b/heating.py
index 9bb0bc5..f21b986 100644
--- a/heating.py
+++ b/heating.py
@@ -1,4 +1,5 @@
from abc import ABC, abstractmethod
+from queue import circular_queue
import time
import os
@@ -9,6 +10,7 @@ class heating(ABC):
self.target = 19
self.on = False
self.db = db
+ self.queue = circular_queue(20)
def up(self, increase=0.5):
self.target += increase
@@ -19,7 +21,9 @@ class heating(ABC):
self.update()
def update(self):
- self.temperature = self.get_temperature()
+ # rolling average for current temperature
+ self.queue.add(self.get_temperature())
+ self.temperature = self.queue.average()
if self.temperature < self.target:
self.on = True
self.turn_on()