I think this has something to do with the version of HA-Raspberry-pi-GPIO-PWM. I had the same issues, but updated, and it fixed the yaml validation stuff.
Oddly, I seem to have two declared instances of the same thing (and two separate directories in my CONFIG/custom_components Folder)
Not sure which one is actually ‘active’, and the other ‘non-active’, so left them
Any one offer up some advice ? pigpio is a up to date and install it as per instructions - same for GPIO PWM which in stalled from here
its when add the temp sensor and light device that I run into issues
Ok so I was afraid you were gonna say this.
When I try installing through HACS, I search for “ha-rpi_gpio_pwm” I find nothing. But if I search for “gpio” I find to integrations to install :
Thanks fredu - really helpful. I did not occur to me this was a custom directory.
So I got a few steps closer. Both addon installs gone ok and the config file updated without any issues.
But now I’m getting the following error in the logs on startup
Error executing script: expected int for dictionary value @ data['brightness']
Also when I go to test the python script as a service I am unable to set a value for the fan speed.
Also on startup my shim fan does not power up - I’m assuming its because I need to create an automation to turn it on ? but I cant because of the above issue
Yup. I think there is a bug with the service call ui - it doesnt show the data part. I too, can’t add the data, unless you switch to YAML mode and enter it directly.
It’s wise to configure a startup automation, and set it to some value
The error message above is odd; it looks like you have an automation but are supplying the wrong data. Did you try everything in section 5 above (right at the top of this post), with the service data part set to fan_speed: 128 (or something of your choosing)?
Filling in the data {} portion was the final piece of the puzzle for me on HAOS 2022.9.7. I only used the initial 3-line Python script. I then created a pair of automations via the web UI to turn the fan on and off. The trigger for each is a Numeric State of CPU Temperature. The action for each is a Call Service for Python Scripts: rpi_fan_pwm. The service data is set as fan_speed: 140 for 60%, and fan_speed: 0 for off.
I’m using a pair of Noctua NF-A4x10 5V PWM fans, an Ice Tower Cooler, and a custom case (1 fan ventilates the case). 60% drops the pi temp from 40C to 35C very fast with no noise. Using developer tools helped to find the maximum noise-free speed. I changed the trigger temps to 60 on, 40 off after testing.
I tried it and thank you so much for this. It works for me on RPi 4 with Case Fan (RPi 4) pretty well. I’ve a small note - the correct folder for Python script is "python_scripts" eg. with underscore.
Anyone got this to work? When calling the Python Script with a set fan_speed, nothing changes and by using the brightness slider using the entity card.
Edit: Logs below
Error executing script: expected int for dictionary value @ data['brightness']
14:29:13 – (ERROR) Python Scripts - message first occurred at 14:25:55 and shows up 2 times
I have no error messages, the ‘light’ turns on and off without error. The script sets the ‘light’ brightness so my software seems installed fine… Just the fan doesn’t spin at any brightness. Here is my setup, any suggestions…
In the config you should be addressing the GPIO pin, not the physical pin number, so it should be 24. For example, I’m using the official RPi4 Case Fan and it’s connected to the physical pin #8, which is GPIO 14, and I got it working using “pin: 14”.
Also, I just signed up to say this guide was extremely helpful, thank you @VauxhallViva and also to @fredu for how to install the GPIO-PWM integration through HACS, that was the step I got stuck on
That should be handled by the “Set Fan Speed on Startup” automation in the OP. If you have that set up and it’s not working, but you can manually turn the fan on or set the fan speed, check the step before that, creating the python script to set fan speed.