On-Off-Switch with 2 Relays

Hi everybody,
I am new to HomeAssistant and am currently trying to control a device with an on-switch and an off-switch using two relays.
To turn the device on, relay1 should activate the on-switch for 100ms. To turn the device off, relay2 should activate the off-switch for 100ms.

Is there a way to do this in Home Assistant directly on the Raspberry?
I found this example for a garage door but I don’t have state_pins for my application.