Custom Button Card Entity Attribute State

custom:button-card doesn’t use Jinja (this is what you are using in your code below) but Java. There are multiple examples in the documentation and in the main community topic.
I cannot really debug your code because I don’t use it anymore.