summaryrefslogtreecommitdiff
path: root/src/home/temphum/__init__.py
blob: 55a7e1feb44a390198c99c14e2e74a6548fa4fe7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from .base import SensorType, TempHumSensor
from .si7021 import Si7021
from .dht12 import DHT12

__all__ = [
    'SensorType',
    'TempHumSensor',
    'create_sensor'
]


def create_sensor(type: SensorType, bus: int) -> TempHumSensor:
    if type == SensorType.Si7021:
        return Si7021(bus)
    elif type == SensorType.DHT12:
        return DHT12(bus)
    else:
        raise ValueError('unexpected sensor type')