From c1fdc09b87be7c6dd7e5e995c2931df042c7bc2d Mon Sep 17 00:00:00 2001 From: Masoko Date: Sat, 26 Oct 2024 16:28:21 +0300 Subject: [PATCH] cpu_thermal_zone is configurable now (#151) --- src/config.py.example | 5 ++++- src/rpi-cpu2mqtt.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.py.example b/src/config.py.example index 01d559d..79697ab 100644 --- a/src/config.py.example +++ b/src/config.py.example @@ -77,4 +77,7 @@ rpi5_fan_speed = False rpi_power_status = False # Check for apt updates - experimental feature, disabled by default, updateed with update_check_interval -apt_updates = False \ No newline at end of file +apt_updates = False + +# Change the thermal zone if you have issues with cpu temps +cpu_thermal_zone = 'cpu' \ No newline at end of file diff --git a/src/rpi-cpu2mqtt.py b/src/rpi-cpu2mqtt.py index 0d79d9a..929ce66 100644 --- a/src/rpi-cpu2mqtt.py +++ b/src/rpi-cpu2mqtt.py @@ -108,7 +108,7 @@ def check_rpi_power_status(): def check_cpu_temp(): - 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)" + full_cmd = f"awk '{{printf (\"%.2f\\n\", $1/1000); }}' $(for zone in /sys/class/thermal/thermal_zone*/; do grep -iq \"{config.cpu_thermal_zone}\" \"${{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().replace(",", ".")