From 6912c1259323286b4e6e0fc4c3be6e04f053c37c Mon Sep 17 00:00:00 2001 From: XAuge Date: Wed, 11 Oct 2017 15:39:12 +0200 Subject: [PATCH] Raspberry Pi3 including Raspberry Pi3 CPU-Sensor and return temperatur values as floating point value. --- pyspectator/temperature_reader.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyspectator/temperature_reader.py b/pyspectator/temperature_reader.py index 54c84b1..316fbd6 100644 --- a/pyspectator/temperature_reader.py +++ b/pyspectator/temperature_reader.py @@ -6,9 +6,11 @@ class LinuxCpuTemperatureReader(): files = [ '/sys/devices/LNXSYSTM:00/LNXTHERM:00/LNXTHERM:01/thermal_zone/temp', '/sys/bus/acpi/devices/LNXTHERM:00/thermal_zone/temp', + '/sys/class/thermal/thermal_zone0/temp', '/proc/acpi/thermal_zone/THM0/temperature', '/proc/acpi/thermal_zone/THRM/temperature', '/proc/acpi/thermal_zone/THR1/temperature' + ] @classmethod @@ -16,9 +18,10 @@ def get_reader(cls): readers = { cls.files[0]: cls.reader1, cls.files[1]: cls.reader1, - cls.files[2]: cls.reader2, + cls.files[2]: cls.reader1, cls.files[3]: cls.reader2, - cls.files[4]: cls.reader2 + cls.files[4]: cls.reader2, + cls.files[5]: cls.reader2 } for file in cls.files: if path.exists(file): @@ -29,8 +32,8 @@ def get_reader(cls): @classmethod def reader1(cls, file): def reader(file): - temperature = open(file).read().strip() - temperature = int(temperature) // 1000 + temperature = float(open(file).read().strip()) + temperature = temperature / 1000 return temperature return partial(reader, file) @@ -39,7 +42,7 @@ def reader2(cls, file): def reader(file): temperature = open(file).read().strip() temperature = temperature.lstrip('temperature :').rstrip(' C') - return int(temperature) + return float(temperature) return partial(reader, file) @@ -54,7 +57,7 @@ def temperature_reader(): pythoncom.CoInitialize() w = wmi.WMI(namespace='root\\wmi') temperature = w.MSAcpi_ThermalZoneTemperature()[0] - temperature = int(temperature.CurrentTemperature / 10.0 - 273.15) + temperature = float(temperature.CurrentTemperature / 10.0 - 273.15) return temperature return temperature_reader