28 lines
656 B
Python
28 lines
656 B
Python
import subprocess
|
|
import json
|
|
|
|
def getSensors():
|
|
result = subprocess.run(['sensors', '-j', '-A'], stdout=subprocess.PIPE)
|
|
result = result.stdout.decode('utf-8')
|
|
|
|
print(result)
|
|
devices = json.loads(result)
|
|
|
|
return devices
|
|
|
|
def getTemps():
|
|
devices = getSensors()
|
|
|
|
temps = {}
|
|
for device in devices:
|
|
temps[device] = {}
|
|
for sensor in devices[device]:
|
|
for data in devices[device][sensor]:
|
|
if "temp" in data:
|
|
if "input" in data:
|
|
temps[device][sensor] = devices[device][sensor][data]
|
|
return temps
|
|
|
|
if __name__ == "__main__":
|
|
getTemps()
|