Lovelace template > run script


Anyone knows if there is any way to put a template into a lovelace card?
I use popup from browser mod. When I pus a button, I will have a popup with an alarm control panel and when I push the “Enter” button after I insert the code, I want that the popup close itself if the code was good.

I was thinking at somethink like: If alarm_control_panel entity will change it’s state, run that service… But I don’t know how to do that, if is possible

Thank you!