Objective: I want a card showing all of my speakers to appear if any are playing or paused.
Methods tried:
- Visual OR coding in the visibility tab
- Implementing various forms of the yaml below
Before anyone lights me up for not doing a simple google search, I have. Came across a few different posts and tried implementing what they did but it either didn’t have any effect or completely hid my whole dashboard (namely this solution).
With that explanation out there, can anyone tell me why my binary sensor isn’t working right? Here’s the yaml.
Raw Config code pulled from dashboard code editor:
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- type: media-control
entity: media_player.living_room_speaker
- type: media-control
entity: media_player.office_speaker
- type: media-control
entity: media_player.kitchen_speaker
- type: media-control
entity: media_player.bedroom_speaker
visibility:
- type: conditional
conditions:
- entity: binary_sensor.speaker_playing
state: 'on'
Template code - speaker_playing:
template:
- binary_sensor:
- name: "speaker_playing"
state: {{ expand('media_player.all_media_players') | selectattr('state','in',['on','playing']) | list | count > 0 }}