summaryrefslogtreecommitdiff
path: root/src/temphum_smbus_util.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-05-12 04:33:32 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-05-12 04:33:32 +0300
commitf2a7cafc9be2e1e2ad01c77917108b76624e4a66 (patch)
treee67646ebcdb5c6674bca26b1c8004740b0e00b26 /src/temphum_smbus_util.py
parent883f3181392b1f46c9299cf28396cf635c8ac492 (diff)
temphum: refactoring in progress
Diffstat (limited to 'src/temphum_smbus_util.py')
-rwxr-xr-xsrc/temphum_smbus_util.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/temphum_smbus_util.py b/src/temphum_smbus_util.py
new file mode 100755
index 0000000..0f90835
--- /dev/null
+++ b/src/temphum_smbus_util.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+from argparse import ArgumentParser
+from home.temphum import SensorType, 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}')