Updating command_line switch with new value

I’m using a template_switch which controls a command_line switch to start/stop/get_state.
The command line controls another device (hardware) using a python script, and it has a turn on/turn off/query state options.

I’ve set the command_line switch scan_interval to 30 seconds, however, as I turn on the device, the template switch turns on for 1 second, goes back off and stays off until the next scan interval of the command_line switch which theoretically can be ~30 seconds afterwards.

I’ve tried adding a call for homeassistant.update_entity (even with delay of 5 seconds) but it looks like it doesn’t send the new command before the output is printed to logs (or something like that), which may take a few seconds.
When I set the delay to 10 seconds it seems fine, but I guess it’s still a race and I’ll be happy to get rid of the ‘on > off > on’ visuality

Any ideas?

Did you end up finding a solution for this? I’m having the same issue with my command line switch…