summaryrefslogtreecommitdiff
path: root/bin/temphum_smbus_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/temphum_smbus_util.py')
-rwxr-xr-xbin/temphum_smbus_util.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/temphum_smbus_util.py b/bin/temphum_smbus_util.py
new file mode 100755
index 0000000..1cfaa84
--- /dev/null
+++ b/bin/temphum_smbus_util.py
@@ -0,0 +1,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}')