Script to turn on HA entity

Hi
I have integrate my “not smart” soundbar with a broadlink mini3 as media player in HA.
I can turn it on-off-mute and also toggle between the sources.

In my phone I have a widget script that toggles (turns on-off) the soundbar.
When I run the script the soundbar in HA shows that is off although it is on.
I am wondering if and how I could use an input boolean or something eg. when I run the script in my phone to turn on the soundbar through HA. Any ideas what I should do?

Try a switch template paired with an input boolean to keep track of the state of the device