diff options
| author | root <root@turin.home> | 2022-01-16 13:36:16 +0000 |
|---|---|---|
| committer | root <root@turin.home> | 2022-01-16 13:36:16 +0000 |
| commit | 7104802fedc605cb386339733a6162e10da2aabd (patch) | |
| tree | 4f3e58920a51b2214a6901ce86c7bce01ff7b9ca | |
| parent | 4f95a0a75be6948a7eb36a8f5563301e740c8d32 (diff) | |
Add rolling average to heating with queue
| -rw-r--r-- | heating.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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() |
