summaryrefslogtreecommitdiff
path: root/src/home/temphum/base.py
blob: e7744337a7bc62817f93e8ab2465fc325a4d7650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import smbus

from abc import abstractmethod, ABC
from enum import Enum


class TempHumSensor:
    @abstractmethod
    def humidity(self) -> float:
        pass

    @abstractmethod
    def temperature(self) -> float:
        pass


class I2CTempHumSensor(TempHumSensor, ABC):
    def __init__(self, bus: int):
        super().__init__()
        self.bus = smbus.SMBus(bus)


class SensorType(Enum):
    Si7021 = 'si7021'
    DHT12 = 'dht12'