Picture-entity card running script but which state depends on another entity state

Hi to everyone,

I have in my UI a picture-entity card which runs a script to turn on my tv on.
This card displays “active” (and changes color) during the excution of the script, but as soons as the script is over, the card turns inactive.

Which I understand since the card’s state depends on it’s entity, in this case : the script.

But is there a way , for this picture-entity card, to toggle a script on press, but link its state ton another entity (something in my case like switch.tv_on = ‘on’)

Oh, and in the same way, is it possible to control the name of this picture-entity card depending on the state on the previous entity?

So the final result would be : a card showing a tv picture all greyed out, and name sayin ‘Wtach Tv’
Pressing this picture would trigger the script : then the picture would be “alive” (with colours and stuff), but since it would be linked ton the tv status (power on) it would stay alive. And the name would change to ‘Turn off TV’
Then, pressing it again would trigger the script again (handling the tv state on/off condition to turn it off or on), the picture would go grey again, and the name would change to its initial state “Watch TV”.

I’m not sure if it makes sense : basically, using a picture as a switch running a script, but with its apperance chaning depending on the state of an another entity.

Here is my actuel picture-entity card, pretty basic for now

type: picture-entity
entity: script.tv_on
image: './local/tv.jpg'
name: Watch TV
tap_action:
  action: toggle
hold_action:
  action: more-info

Many thanks in advance! I’m pretty sure it’s been asked befoire but could’nt figure it out googling it for now

Change the entity to media_player.whatever_your_tv_is and change the tap action to call-service and specify your script in the service data.

The name changing would require using custom Lovelace template card.

Thanks for your quick reply! So simple!

It works fine, and I’ll check the template card for further customasiation

Many htanks