blob: 1cfaa8413843ab55dc1f1c077b3c3c2e948be927 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/usr/bin/env python3
import __py_include
from argparse import ArgumentParser
from homekit.temphum import SensorType
from homekit.temphum.i2c import create_sensor
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('-t', '--type', choices=[item.value for item in SensorType],
required=True,
help='Sensor type')
parser.add_argument('-b', '--bus', type=int, default=0,
help='I2C bus number')
arg = parser.parse_args()
sensor = create_sensor(SensorType(arg.type), arg.bus)
temp = sensor.temperature()
hum = sensor.humidity()
print(f'temperature: {temp}')
print(f'rel. humidity: {hum}')
|