initial commit
This commit is contained in:
27
temps.py
Normal file
27
temps.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user