added sensor reading utility
parent
856392749c
commit
87d9131ccf
|
@ -0,0 +1,20 @@
|
||||||
|
import os, json, sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
sensor_group = sys.argv[1]
|
||||||
|
sensor = sys.argv[2]
|
||||||
|
except IndexError:
|
||||||
|
print("usage: python3 "+sys.argv[0]+" <sensor group> <sensor>")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
sensors_process = os.popen("sensors -j")
|
||||||
|
temps_str = sensors_process.read()
|
||||||
|
sensors_process.close()
|
||||||
|
|
||||||
|
temps = json.loads(temps_str)
|
||||||
|
|
||||||
|
try:
|
||||||
|
print([value for key, value in temps[sensor_group][sensor].items() if key.endswith("input")][0])
|
||||||
|
except KeyError:
|
||||||
|
print("Sensor \""+sensor_group+":"+sensor+" not found!")
|
||||||
|
sys.exit(1)
|
Loading…
Reference in New Issue