giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.3k stars 1.39k forks source link

One-wire senosors unintendendly read on Linux #2451

Open antonverburg opened 1 month ago

antonverburg commented 1 month ago

Summary

Description

When using parasitic-powered 1-wire temperature sensors with the DS2482S-100 line driver, the 1-wire temperature sensors now-and-then reported temperature 85degC. This indicates that the time that the device could consume the parasitic power from the dataline was too short to make a valid temperature readout. Further investigation with oscilloscope showed me that another client was sending readout messages to the one-wire sensor during the time that the dataline was feeding power. This causes the line master to stop feeding power. And for that reason, the sensor returned 85degC. Looking for the cause of this disruption I found that the Systemmonitor of Homeassistant uses psutil for monitoring all kind of system resources, including CPU temperature. Psutil is reading all sensors in /sys/class/hwmon/. As linux also propagates the one-wire sensors in this directory, these sensors are read as well. I think it is not the intention of psutil to read those sensors; a single readout can take up to 1 second time, so if a system contains a lot of these sensors, reading all of them can take a lot of time. Beside that, temperature sensors on the onewire bus are not interesting for system monitoring. So I propose to skip the onewire sensors when reading the content of /sys/class/hwmon. I will prepaire a tested pull request.