Servo motor automation

hi I’m wondering if anybody could help me.
I’ve set up an ESP with a servo motor and it works perfectly, with the slider.
would I would like to do is set up an automation in home assistant to rotate the servo
from 50% to -50% but I would also like a switch on my dashboard to target on and off
the ESP also has a bme280 incase don’t complicate things.

Thank you