From eab3a825f26407198a67833240654479b7e8cf23 Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Sun, 3 Mar 2024 16:00:18 +0100 Subject: [PATCH] Fixed missing code from removing abstraction --- src/handler/dht22_climate.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/handler/dht22_climate.py b/src/handler/dht22_climate.py index 2cebb57..df7678c 100644 --- a/src/handler/dht22_climate.py +++ b/src/handler/dht22_climate.py @@ -1,11 +1,17 @@ import Adafruit_DHT -class Dht22Climate(): - def __init__(self, pin): - super().__init__() +class Dht22Climate: + + def __init__(self, pin: int): self.sensor = Adafruit_DHT.AM2302 self.pin = pin + self.last_read = None + + def get_last_read(self): + if self.last_read is None: + return self.read() + return self.last_read def read(self): humidity, temperature = Adafruit_DHT.read_retry(self.sensor, self.pin)