Mini-media-player: Volume slider to control another entity? Or controls to another entity?

Created on 6 Jan 2020  Â·  4Comments  Â·  Source: kalkih/mini-media-player

Thanks for the great card. I'm wondering if you have a recommendation for my setup. I have a Yamaha AV receiver that controls the audio and a few inputs like Chromecast, FireTV, Xbox.
With the way it is currently implemented, I have the receiver as the entity in the mini media player card. This allows me to control the volume. However, if I want to pause the media, there is no place to tell it to go to the playing device, and I don't want to replicate a pause button for all three sources.
Conversely, if I make the Chromecast the entity in the mini media player card, I won't be able to adjust the volume with a slider (preferred over using separate buttons for vol up/down), but the media controls will work. However, that limits me to only the Chromecast as the device.

Do you have any recommendations for this?

I tried to see if I could add another row of custom buttons with conditional statements, but it looks like that wasn't working.

My current config:

cards:
- type: conditional
  conditions:
    - entity: switch.projector_power
      state: "on"
  card:
  - type: custom:mini-media-player
    entity: media_player.rx_v675
    icon: mdi:television-classic
    hide:
      controls: true
      source: true
      power: true
    shortcuts:
      columns: 3
      buttons:
      - name: Chromecast
        icon: mdi:google-chrome
        type: service
        id: media_player.select_source
        data:
          entity_id: media_player.rx_v675
          source: HDMI3
      - name: XBOX
        icon: mdi:xbox
        type: service
        id: media_player.select_source
        data:
          entity_id: media_player.rx_v675
          source: HDMI2
      - name: FireTV
        icon: mdi:amazon
        type: service
        id: media_player.select_source
        data:
          entity_id: media_player.rx_v675
          source: HDMI4
      - name: Mi Box 4
        icon: mdi:android-head
        type: service
        id: media_player.select_source
        data:
          entity_id: media_player.rx_v675
          source: HDMI5
      - name: Projector Off
        icon: mdi:television-classic-off
        type: service
        id: switch.turn_off
        data:
          entity_id: switch.projector_screen
question

All 4 comments

Hello!
I would recommend checking out universal media player, and potentially create one consisting of your AVR, Chromecast and maybe even your FireTV and Xbox as well.

I've been running the following setup for a while with my AVR and my Chromecast.

- media_player:
  platform: universal
  name: AVR TV UNI
  children:
    - media_player.chromecast_vardagsrum
    - media_player.avr_tv
  commands:
    turn_on:
      service: media_player.turn_on
      data:
        entity_id: media_player.avr_tv
    turn_off:
      service: media_player.turn_off
      data:
        entity_id: media_player.avr_tv
    volume_mute:
      service: media_player.volume_mute
      data:
        data_template:
          entity_id: media_player.avr_tv
          is_volume_muted: ‘{{ is_volume_muted }}’
    select_source:
      service: media_player.select_source
      data_template:
        entity_id: media_player.avr_tv
        source: '{{ source }}'
    volume_set:
      service: media_player.volume_set
      data_template:
        entity_id: media_player.avr_tv
        volume_level: '{{ volume_level }}'
  attributes:
    state: media_player.avr_tv
    is_volume_muted: media_player.avr_tv|is_volume_muted
    volume_level: media_player.avr_tv|volume_level
    source: media_player.avr_tv|source
    source_list: media_player.avr_tv|source_list

This basically creates a virtual entity where you can map different controls and attributes to different media player entities.
All non specified stuff will fall back to the first child listed in the config above.
So this will allow me to get media information and play/pause e.t.c. from the Chromecast while having volume, source select, mute, on/off mapped to the AVR.

Here's another setup I've been running for a while, not sure if it's relevant but maybe you can find some inspiration from it.
It's basically made with some conditional cards, a couple of button cards and a bunch of mini-media-player cards in different configurations with the large main slider controlling the AVR volume.

Screenshot 2020-01-06 at 18 36 28

@kalkih Can you share the lovelace configuration for that screenshot?

Sure, but be prepared, it's messy! 😆

- type: conditional
  conditions:
    - entity: media_player.samsung_tv
      state_not: 'off'
    - entity: media_player.samsung_tv
      state_not: 'unavailable'
  card:
    type: horizontal-stack
    cards:
      - type: custom:button-card
        name: "â–² Brightness"
        entity: script.media_source
        action: service
        show_icon: false
        styles:
          card:
            - height: 60px
            - letter-spacing: .15em
            - text-transform: uppercase
            - font-size: .9em
            - font-weight: 600
        service:
          domain: shell_command
          action: samsungtv_brightness_high
      - type: custom:button-card
        name: "â–¼ Brightness"
        entity: script.media_source
        action: service
        show_icon: false
        styles:
          card:
            - height: 60px
            - letter-spacing: .15em
            - text-transform: uppercase
            - font-size: .9em
            - font-weight: 600
        service:
          domain: shell_command
          action: samsungtv_brightness_low

- type: horizontal-stack
  cards:
    - type: custom:button-card
      name: Viasat
      icon: mdi:television-box
      entity: binary_sensor.avr_source_viasat
      color_type: card
      color: rgba(255, 255, 255, .5)
      styles:
        card:
          - padding: 1em .5em
          - letter-spacing: .15em
          - text-transform: uppercase
          - font-size: .9em
          - font-weight: 600
        name:
          - padding-top: .4em
      tap_action:
        action: call-service
        service: script.media_source
        service_data:
          entity: 'avr_tv'
          source: 'VIASAT    OUT1'

    - type: custom:button-card
      name: Vinyl
      icon: mdi:album
      entity: binary_sensor.avr_source_vinyl
      color_type: card
      color: rgba(255, 255, 255, .5)
      styles:
        card:
          - padding: 1em .5em
          - letter-spacing: .15em
          - text-transform: uppercase
          - font-size: .9em
          - font-weight: 600
        name:
          - padding-top: .4em
      tap_action:
        action: call-service
        service: script.media_source
        service_data:
          entity: 'avr_tv'
          source: 'DVD/CD/LP'

    - type: custom:button-card
      name: Cast
      icon: mdi:cast-connected
      entity: binary_sensor.avr_source_cc
      color_type: card
      color: rgba(255, 255, 255, .5)
      styles:
        card:
          - padding: 1em .5em
          - letter-spacing: .15em
          - text-transform: uppercase
          - font-size: .9em
          - font-weight: 600
        name:
          - padding-top: .4em
      tap_action:
        action: call-service
        service: script.media_source
        service_data:
          entity: 'avr_tv'
          source: 'CHROMECAST'

    - type: custom:button-card
      name: TV
      icon: mdi:apple
      entity: binary_sensor.avr_source_apple
      color_type: card
      color: rgba(255, 255, 255, .5)
      styles:
        card:
          - padding: 1em .5em
          - letter-spacing: .15em
          - text-transform: uppercase
          - font-size: .9em
          - font-weight: 600
        name:
          - padding-top: .4em
      tap_action:
        action: call-service
        service: script.media_source
        service_data:
          entity: 'avr_tv'
          source: 'APPLE TV HDMI2'

- type: conditional
  conditions:
    - entity: media_player.avr_tv
      state_not: 'off'
  card:
    type: horizontal-stack
    cards:
      - entity: media_player.avr_tv
        type: custom:mini-media-player
        max_volume: 72
        hide:
          controls: true
          name: true
          icon: true
          info: true
          power: true
          source: true
          mute: true

- type: conditional
  conditions:
    - entity: media_player.media_tv_uni
      state: 'playing'
  card:
    type: horizontal-stack
    cards:
      - type: custom:mini-media-player
        entity: media_player.media_tv_uni
        name: NOW PLAYING
        hide:
          power: true
          volume: true
          icon: true
          progress: true
        info: scroll
        idle_view:
          when_paused: true
          when_idle: true
- type: horizontal-stack
  cards:
    - entity: media_player.samsung_tv
      type: custom:mini-media-player
      artwork: cover
      name: TV
      source: icon
      hide:
        volume: true
        controls: true
        icon: true
        power_state: false

    - entity: media_player.avr_tv
      type: custom:mini-media-player
      artwork: cover
      source: icon
      name: AVR
      hide:
        volume: true
        controls: true
        icon: true
        power_state: false

- type: horizontal-stack
  cards:
    - entity: media_player.chromecast_vardagsrum
      type: custom:mini-media-player
      name: Chromecast
      info: short
      hide:
        power_state: false
        icon: true
        mute: true
      idle_view:
        when_paused: true

    - entity: media_player.google_home
      type: custom:mini-media-player
      info: short
      hide:
        power_state: false
        icon: true
        mute: true
      idle_view:
        when_paused: true

Thanks @kalkih! I got what I needed out of that :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GuyKh picture GuyKh  Â·  4Comments

hulkhaugen picture hulkhaugen  Â·  3Comments

rpitera picture rpitera  Â·  3Comments

darkkatarsis picture darkkatarsis  Â·  4Comments

cweakland picture cweakland  Â·  6Comments