Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import json, urllib2
- pc_ip = "192.168.0.100" # the ip of the pc where open hardware monitor is running http://openhardwaremonitor.org/
- pc_port = "8085" # the port on which OHM is running (default 8085) - you'll need to start the remote web server from OHM settings
- json_file = "data.json" #this is the name of the json file containing sensor data
- response = urllib2.urlopen('http://'+pc_ip+':'+pc_port+'/'+json_file)
- data = json.load(response)
- cpu_temp = data['Children'][0]['Children'][1]['Children'][1]['Children'][4]['Value']
- cpu_load = data['Children'][0]['Children'][1]['Children'][2]['Children'][4]['Value']
- gpu_temp = data['Children'][0]['Children'][2]['Children'][1]['Children'][0]['Value']
- gpu_load = data['Children'][0]['Children'][2]['Children'][2]['Children'][0]['Value']
- print "CPU ",cpu_temp.split(' ')[0]+ " 'C ", cpu_load
- print "GPU ",gpu_temp.split(' ')[0]+ " 'C ", gpu_load
- # Home Assistant configuration
- #
- #sensor main_cpu_temp:
- # platform: command_line
- # command: "/usr/bin/python /home/pi/py/pc-monitor/pccpu.py | cut -d ' ' -f 3"
- # name: main pc cpu temp
- # unit_of_measurement: "°C"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement