mirror of
https://github.com/home-assistant/core.git
synced 2025-06-05 05:37:04 +00:00

Some systems expose cpu temperatures differently in psutil. Specifically, running armbian on the Odroid xu4 sbc gives the following temerature output: >>> pp.pprint(psutil.sensors_temperatures()) { 'cpu0-thermal': [ shwtemp(label='', current=54.0, high=115.0, critical=115.0)], 'cpu1-thermal': [ shwtemp(label='', current=56.0, high=115.0, critical=115.0)], 'cpu2-thermal': [ shwtemp(label='', current=58.0, high=115.0, critical=115.0)], 'cpu3-thermal': [ shwtemp(label='', current=56.0, high=115.0, critical=115.0)], } Since the cpu number is embedded inside the name, the current code can't find it. To fix this, check both the name and the constructed label for matches against CPU_SENSOR_PREFIXES, and add the appropriate label cpu0-thermal in the prefix list. While this is slightly less efficient that just generating the label and checking it, it results in easier to understand code.