Newbie automation help

I am struggling trying to figure out a way to automate a switch to turn on at a set time and then turn off at another given time.

I currently have 2 automations, one that turns the switch on and one that turns the switch off.
I was hoping I could simplify this into one automation,. I can’t figure out how to approach this problem. My first thought was a template, but after reading the docs and searching this forum, I am not sure this can be done.

Thanks in advance.

I tend to have 2 automations for this type of scenario.
having a single template will actually complicate things a bit and make it more difficult to troubleshoot later one.
If you really want to do it, use a service_template: