I have sifted through many comments on PWM using external driver boards, but since the Raspberry Pi has a hardware PWM that can control some of the GPIO pins, is there not a way that Home Assistant could directly control the PWM output, just like rpi_gpio can switch individual pins on and off?
I tried adding a platform: rpi_gpio_pwm in configuration.yaml but in the call service options of an automation there is only “toggle”, switch on, and switch off, nothing to set the duty cycle.
Any help would be most welcome!
I don’t think there is an “out-of-the-box” generic way to handle GPIO PWM, currently, but the following thread might be a good starting point for you
I installed the Poechi reposistory and from this I can control the pwm pins on the rapberry.
Google for that.
Regards
Thank you, Ivan. Could you add a link? I was not able to find the repository…
Reagrds
Thank you again!
Could I trouble you again to show some link to a documentation how Hassio-Addons/pigpio at master · Poeschl/Hassio-Addons · GitHub can be used?
This is how I use the pigpio library in HA venv on Raspberry OS.
It’s just based on the doc:
https://abyz.me.uk/rpi/pigpio/python.html#hardware_PWM
pi_fan_pigpio.py:
import pigpio
import sys
pi = pigpio.pi()
pi.hardware_PWM(18, 25000, int(float(sys.argv[1])))
if not pi.connected: # exit script if no connection
exit()
configuration.yaml:
input_number:
pi_fan_pigpio_inputspeed:
name: Pi Fan pigpio
max: 1000000
min: 0
unit_of_measurement: "μs/s"
shell_command:
pi_fan_pigpio_setspeed: >-
python /home/homeassistant/.homeassistant/pi_fan_pigpio.py {{ states("input_number.pi_fan_pigpio_inputspeed") }}
Many thanks! I’ll try to understand this and give it a go…
It just seems odd that home-assistant doesn’t have some simple direct method to control PWM without needing to have a demon connected!
I’m totally with you Rimh, seems bizare. Did you find a simple way to add a servo as an entity?
Phil
Hello Phil,
In the meantime I switched to a hardware solution using “MyPV” AC-Thor9s to modulate the load according to the available solar energy, so I didn’t pursue the pwm solution …