How to Connect a Servo to ESP32 using a Button on Home Assistant

Hello

I have connected my MG90S servo to an ESP32 using an external 5V power supply and am trying to make the servo move to position two on a button click and then after a few seconds move back to initial position but I have no idea how to do that. I have used the instructions here: https://siytek.com/esphome-servo-example/ to just get the servo functional but i don’t know how to modify it so that it can work from a button press on my dashboard as opposed to a slider and for some reason the servo only moves 180 degrees using the slider.

Any help would be appreciated

Thanks.