I'm trying to control my laptop fan speed using WMI in python.
This is my python code:
import wmi
c = wmi.WMI ()
cim_fan = c.CIM_Fan()
fan_speed = 4000
cim_fan[0].SetSpeed(fan_speed)
But it throws this error:
Traceback (most recent call last):
File "C:\Users\AliEnt\Desktop\Athena Codes\control_fan\main.py", line 7, in <module>
cim_fan[0].SetSpeed(fan_speed)
File "C:\Users\AliEnt\AppData\Roaming\Python\Python39\site-packages\wmi.py", line 473, in __call__
handle_com_error()
File "C:\Users\AliEnt\AppData\Roaming\Python\Python39\site-packages\wmi.py", line 258, in handle_com_error
raise klass(com_error=err)
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147352567, 'Exception occurred.', (0, 'SWbemObjectEx', 'This method is not implemented in any class ', None, 0, -2147217323), None)>
Then I took a closer look at the CIM_Fan class documentation and saw this:
Method | Description |
---|---|
Reset | Requests a reset of the logical device. Not implemented by WMI. |
SetPowerState | Defines the desired power state for a logical device and when a device should be put into that state. Not implemented by WMI. |
SetSpeed | Sets the fan speed. Not implemented by WMI. |
Here it is said that I have to implement it on my own provider. I don't understand what does it mean by saying provider.
I'm familiar with C++ but I'm pretty new with Microsoft APIs. So I prefer to do it by using python instead of compiling a C++ program. Or at least with a minimum C++ code and a wrapper.