Im building a stack in Lovelace showing my media players and a picture of a cinema i like. I want the picture to light up when on of the media players has the status playingor paused. And only showing them when there in those states.
Everything works except for the picture because the picture-entity-card can only have one entity. Someone in discord adviced to look at sensor.template to make it read as one entity. I am not good in templating etc so i hope someone can help me.
I know this is kind of old but it’s all I can find that seems at all relevant.
Is it possible to create a template to trigger a binary sensor based on a media player’s source? I’m really new to templating and just can’t work it out.
You don’t normally trigger a binary_sensor, you trigger an automation.
That being said you can create a binary sensor that will return a true/false status based on a state / attribute of a media player.
It would work along the lines of
value_template: '{% if state_attr("media_player.name", "attribute_name") == "state to compare" %}true{% else %}false{% endif %}'
Thanks, yes that’s what I meant. I said “trigger” because I’d just been reading about templates by trigger (or something like that).
I had it setup dependent on the “state” until I realised that the states are “playing” etc. I thought it’d need to identify which attribute somehow but I guess not! Thanks again!
Edit: I just noticed the “attribute_name” so ignore my last sentence