kalkih / mini-media-player

Minimalistic media card for Home Assistant Lovelace UI
MIT License
1.53k stars 207 forks source link

Problem interacting with Universal Media Player #493

Open tcs2tx opened 3 years ago

tcs2tx commented 3 years ago

I have set up a universal media player to have combined control of zones from two (2) Monoprice 6-Zone Amplifiers, which are working using the Monoprice integration. Everything works as expected using the default universal media player entity. The problem occurs when trying to use the mini-media-player card to turn ON or OFF the universal media player using the mini-media player card - everything else appears to work (e.g., change volume and change source).

The current behavior is that the Power On does not work. If all the zones are on, however, Power Off turns off one zone for each push in the same order that they are listed as child entities.

The problem appears to be something that happened in between core_2021.1.4 and core_2021.3.4. I was able to restore an old snapshot (core_2021.1.4) and everything worked as it should. After updating to the current version (core_2021.3.4), I get the behavior described above.

uSpike commented 3 years ago

I'm experiencing this issue as well and can corroborate @tcs2tx bisection.

uSpike commented 3 years ago

Nevermind, I found https://github.com/kalkih/mini-media-player/issues/490 and after adding toggle_power: false my cards work.

kalkih commented 3 years ago

Thanks @uSpike , @tcs2tx Please try the toggle power option, hopefully solves your issue as well.

markdstjohn commented 3 years ago

I'm experiencing this same exact behavior with a Universal Media Player that is used to control a Chromecast and a Denon receiver, and it started happening around the same timeframe that was identified by @tcs2tx. Adding toggle_power: false does not fix the issue for me (I get the same behavior regardless of whether this is set to true or false).

If the receiver is off and the Chromecast isn't playing music, nothing happens when I press the power button in the mini media player. The expected behavior (which does happen with the regular media player widget) is that the receiver should turn on.

If the receiver is on and the Chromecast is playing music, the music stops playing on the Chromecast when I press the power button. The expected behavior (which does happen with the regular media player widget) is that the receiver should turn off.

If the receiver is on and the Chromecast is not playing music, the receiver turns off. This matches the expected behavior.

I've also noticed that I'm not getting expected behavior when power_state: true is set. The color of the power button doesn't ever change.

Here's the definition of mini media player from ui-lovelace.yaml:

views:
  - title: Music
    cards:
      - type: entities
        title: Main Speakers
        show_header_toggle: false
        entities:
        - type: custom:mini-media-player
          entity: media_player.kitchen_music
          name: Kitchen
          hide:
            controls: false
            mute: false
            power_state: true
            source: true
            volume: false
            toggle_power: false
          group: true

Here's the definition of my Universal Media Player from config.yaml (kitchen_speakers is a Chromecast Audio and kitchen_receiver is a Denon receiver):

media_player:
  - platform: universal
    name: Kitchen Music
    children:
      - media_player.kitchen_speakers
      - media_player.kitchen_receiver
    commands:
      turn_on:
        service: media_player.turn_on
        data:
          entity_id: media_player.kitchen_receiver
      turn_off:
        service: media_player.turn_off
        data:
          entity_id: media_player.kitchen_receiver
      volume_up:
        service: media_player.volume_up
        data:
          entity_id: media_player.kitchen_receiver
      volume_down:
        service: media_player.volume_down
        data:
          entity_id: media_player.kitchen_receiver
      volume_mute:
        service: media_player.volume_mute
        data_template:
          entity_id: media_player.kitchen_receiver
          is_volume_muted: '{{ is_volume_muted }}'
      volume_set:
        service: media_player.volume_set
        data_template:
          entity_id: media_player.kitchen_receiver
          volume_level: '{{ volume_level }}'
    attributes:
      is_volume_muted: media_player.kitchen_receiver|is_volume_muted
      volume_level: media_player.kitchen_receiver|volume_level
      state: media_player.kitchen_receiver
markdstjohn commented 3 years ago

My issue was that I had toggle_power: false in the wrong place. Once I put it in the right place, this resolved the issue for me as well. Thanks!