kalkih / mini-media-player

Minimalistic media card for Home Assistant Lovelace UI
MIT License
1.47k stars 206 forks source link

Power Button not functioning correctly with Alexa Media Player #753

Open Scoff123 opened 1 year ago

Scoff123 commented 1 year ago

Since implementing the mini-media-player a few days ago, I've noticed that when using voice commands on either of our 2 Echo Dot devices, and requesting to play music, Alexa responds saying "Playing X on Spotify" for example, but then nothing happens. I went into the Developer tools in HA to check the status of the Echo media player entity and could see that instead of displaying a status of 'Standby' as expected, it showed a status of 'Paused'.

The steps to recreate the issue are: 1) Click shortcut button on mini-media-card which runs a script.media_play_absolute_classic_rock_on_lounge_echo. The script I run is as follows:

alias: "Media : Play Absolute Classic Rock on Lounge Echo"
sequence:
  - service: media_player.play_media
    data:
      media_content_type: TUNEIN
      media_content_id: Absolute Classic Rock on Lounge Echo
    target:
      entity_id: media_player.lounge_echo_dot
mode: single
icon: mdi:play

2) Music starts playing and radio station logo displays as the background as expected. The media_player attributes are now:

source_list:
  - Local Speaker
volume_level: 0.11
is_volume_muted: false
media_content_type: music
media_position_updated_at: '2023-04-13T09:56:27.924604+00:00'
source: Local Speaker
shuffle: false
available: true
last_called: true
last_called_timestamp: 1681379768367
last_called_summary: play absolute classic rock on lounge echo on tunein
connected_bluetooth: null
bluetooth_list: []
friendly_name: Lounge Echo Dot
supported_features: 56253
media_duration: 0
media_position: 3
media_title: Jeremy - Pearl Jam
media_artist: Absolute Classic Rock
entity_picture_local: >-
  /api/media_player_proxy/media_player.lounge_echo_dot?token=37750c48fd642ff5737723cf7d579b9a74a83f7f04968c009b828efdd976316e&cache=1237da54fc0b24a8
entity_picture: https://cdn-profiles.tunein.com/s49815/images/logoq.jpg?t=638005026890000000
media_album_name: The biggest guitar anthems in the world

3) Click the 'power' toggle button on the Mini-Media-Card 4) The music stops, and the card changes back to the standby/idle background image that I have set - but only for 2 seconds. The image then reverts back to the radio station image of the station that was being listened to. No music is played, however the song title still scrolls and the volume slider is present as if music is still playing. Checking the state of the media_player shows as:

source_list:
  - Local Speaker
volume_level: 0.11
is_volume_muted: false
media_content_type: music
media_position_updated_at: '2023-04-13T09:57:55.858258+00:00'
source: Local Speaker
shuffle: false
available: true
last_called: true
last_called_timestamp: 1681379768367
last_called_summary: play absolute classic rock on lounge echo on tunein
connected_bluetooth: null
bluetooth_list: []
friendly_name: Lounge Echo Dot
supported_features: 56253
media_duration: 0
media_position: 90
media_title: Jeremy - Pearl Jam
media_artist: Absolute Classic Rock
media_album_name: The biggest guitar anthems in the world
entity_picture_local: >-
  /api/media_player_proxy/media_player.lounge_echo_dot?token=37750c48fd642ff5737723cf7d579b9a74a83f7f04968c009b828efdd976316e&cache=1237da54fc0b24a8
entity_picture: https://cdn-profiles.tunein.com/s49815/images/logoq.jpg?t=638005026890000000

and the status shows as 'Paused' instead of 'Standby'.

I have found a workaround in the meantime. If you then press the mini-media_player power button a second time, and then adjust the volume slider either up or down, this actually puts the Echo device back into standby mode and the card reverts to the standby /idle background image.

Doing this, when you press the power button a second time, it changes NOTHING in the state or attributes of the media_player, but subsequently adjusting the volume either up or down on the slider then does the trick. This DOESN'T work if you adjust the volume slider first and then press the power button.