Tv take 10 sec to open

Hi, I have an harmony remote that send power toggle command to my tv. So I create an input boolean so I can keep track if my tv is open or close. My issue is my tv take 10 Seconds to open so I’m looking for a way to prevent trigger the input boolean 10 seconds after trigger on or off

I try with a automation but it started to be really complicated ( like over 30 line plus a script for on command and same thing for off command )

I heard something about switch template but I don’t know if it could do what I want