Edit the sudoers file

sudo nano /etc/sudoers

Allow user pi to run commands as su without typing a password

pi ALL=(ALL) NOPASSWD: ALL