How to toggle state diffrent than switch

Hi there this is my first post and also my first project.

I purchased a sonoff 4ch r2 pro. I flashed the device with tasmoto and have the device in inching modus. I want to use the device to control my garden sprinklers (hunter). The pump valves run on 24v ac and switch with a pulse. So when I toggle the switch in HA it go’s to on for one sec and switches back to off. In this case the sprinklers are still working. If I press the switch again the state of the switch goes on for a sec and back off. Now the sprinklers are off. Is there a way to keep the state in the HA to on even if the state of the switch is off? I know that this way there is a possibility of running out of sync. But I still would like this to work. Can somebody point me in the right direction?

Use a template switch to display the status and ON/OFF state and use some automation to display the ON/OFF based on whatever you chose

And how would i do this? I’m just getting started with this. Thanks for the reply!