From a70ec290534bfe4417114f08f554769762a11419 Mon Sep 17 00:00:00 2001 From: markneve Date: Tue, 26 Jan 2016 10:16:39 +0000 Subject: [PATCH] psutil function is out of date. psutil.avail_phymem() is no longer callable from version v3.0 of psutil and elicits an error from webiopi which causes the tiles to be "grayed out". The issue has been reported in SmartThings forum thread https://community.smartthings.com/t/raspberry-pi-device-type/4969. This is fixed by replacing psutil.avail_phymem() with the new function psutil.virtual_memory().used. --- device-types/raspberry-pi/raspberrypi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-types/raspberry-pi/raspberrypi.py b/device-types/raspberry-pi/raspberrypi.py index c14f279..6350d7e 100644 --- a/device-types/raspberry-pi/raspberrypi.py +++ b/device-types/raspberry-pi/raspberrypi.py @@ -36,7 +36,7 @@ def reboot(t=1): def getData(): temp = round(int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3,1) perc = psutil.cpu_percent() - memAvail = round(psutil.avail_phymem()/1000000,1) + memAvail = round(psutil.virtual_memory().used/1000000,1) diskUsage = psutil.disk_usage('/').percent j = {'cpu_temp': temp, 'cpu_perc': perc, 'mem_avail': memAvail, 'disk_usage': diskUsage} return json.dumps(j,indent=4, separators=(',', ': '))