tom_l
June 27, 2022, 9:11am
1
The System Monitor integration uses psutil so I figured I could use this command line sensor to obtain the CPU fan rpm:
- platform: command_line
name: CPU Fan RPM
command: "psutil.sensors_fans()"
unit_of_measurement: "RPM"
Of course that would be far too easy. It failed with:
ERROR (SyncWorker_4) [homeassistant.components.command_line] Command failed: psutil.sensors_fans()
Is there any way to get this information?
HA OS Generic x86 install.
tom_l
June 27, 2022, 1:03pm
2
Ok so as Tinkerer pointed out on Discord, I am trying to run a python function at the command line.
tom_l:
psutil.sensors_fans()
That looks more like a library function call, not a shell command.
SSH in and see if it works from command line?
tom_l
June 27, 2022, 1:05pm
4
It does not. It returns function>
See my facepalm above.
tom_l
June 27, 2022, 1:09pm
5
So I guess I do this?
- platform: command_line
name: Fan Speed
scan_interval: 60
command_timeout: 30
unit_of_measurement: "RPM"
command: "python3 /config/python_scripts/fan-speed.py"
/config/python_scripts/fan-speed.py
import psutil
print(psutil.sensors_fans())
I may not even need the import as psutil is included in System Monitor integration which I use?
tom_l
June 27, 2022, 1:33pm
6
Without the import it fails.
With the import:
What am I doing wrong?
tom_l
June 27, 2022, 1:40pm
8
Yep that’s what I said:
However it does not work with the import either:
tom_l:
With the import:
Step 1 is to get the python program working.
Just because psutil can report fan speed, it doesn’t mean you have the hardware in place to monitor the fan speed. Are you able to see evidence of the fan speed being reported anywhere else?
Try the program with something you know works - like CPU - that you are currently getting via the integration. If this doesn’t work then you may be using the api incorrectly. If it does, then it becomes more likely your hardware doesn’t know the fan speed.
tom_l
June 27, 2022, 2:00pm
10
First I removed the unit of measurement as I though it may be a non numeric result.
No change, still got the empty dictionary {}
Then I tried with psutil.sensors_temperatures()
which returned:
{'acpitz': [shwtemp(label='', current=-263.2, high=None, critical=None), shwtemp(label='', current=29.0, high=119.0, critical=119.0)], 'iwlwifi_1': [shwtemp(label='', current=32.0, high=None, critical=None)]}
So I guess the issue is that I don’t have a fan speed sensor.