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)