From c0dd65510c1f4f2710937def2db45704360f1446 Mon Sep 17 00:00:00 2001 From: Masoko Date: Mon, 21 Oct 2024 20:33:00 +0300 Subject: [PATCH] fix cpu temp decimal point (#141) --- src/rpi-cpu2mqtt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpi-cpu2mqtt.py b/src/rpi-cpu2mqtt.py index 7ca7f81..5ca814b 100644 --- a/src/rpi-cpu2mqtt.py +++ b/src/rpi-cpu2mqtt.py @@ -94,7 +94,7 @@ def check_memory(): def check_cpu_temp(): - full_cmd = "cat /sys/class/thermal/thermal_zone*/temp 2> /dev/null | sed 's/\\(.\\)..$//' | tail -n 1" + full_cmd = "awk '{printf (\"%.2f\\n\", $1/1000); }' $(for zone in /sys/class/thermal/thermal_zone*/; do grep -iq \"cpu\" \"${zone}type\" && echo \"${zone}temp\"; done)" try: p = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0] cpu_temp = p.decode("utf-8").strip()