Can HA + Raspberry Pi + Servo control how much it turns?

im working on water valve with a servo…
i have one working with a Ardunino and a toggle Swtich it can turn the Servo 90 degrees and then back when u turn off swtich

but wanted to know can i do it with HA running Raspberry Pi with the Servo connected to the Pi… so i dont need 2 devices side by side…

or is only way to have them run side by side… and wires from RPI to simulate a Switch toggle to run the script on the Ardunio