Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume Reporting of individual echo not as expected when playing in a multiroom group #444

Closed
almostserious opened this issue Oct 19, 2019 · 13 comments

Comments

@almostserious
Copy link

Describe the bug
When i check the state in NodeRed of any Alexa Media Player entitiy , the volume reporting does not work as expected anymore. Namely when changing the volume manually, the new_state does not report any volume change anymore, but the old_state does have the update value. However, sometimes this behaviour changes around and only the new_state reports a volume change and the old_state doesnt even have the volume attribute.

This only happens when playing media in a multiroom group. If playing on just one specific echo the volume always reports in both old & new state

I am on the latest HASSIO 100.2 and the latest version of alexa_media_player in the HACS: v2.3.3

@alandtse
Copy link
Owner

alandtse commented Oct 20, 2019

I'm not sure what the issue is. What states are you querying? What entities? What do the logs say?

@almostserious
Copy link
Author

Im querying the state of the individual media_player entities. i.e.: Echo Spot:

When playing music on just this Echo Media Player:

media_player.alexa_spot : msg : Object
object
topic: "media_player.alexa_spot"
payload: "playing"
data: object
entity_id: "media_player.alexa_spot"
old_state: object
entity_id: "media_player.alexa_spot"
state: "playing"
attributes: object
volume_level: 0.2
is_volume_muted: false
media_content_type: "music"
media_duration: 180
media_position: 1
media_position_updated_at: "2019-10-20T07:53:15.539342+00:00"
media_title: "Nicht genug"
media_artist: "Tim Bendzko"
media_album_name: "Release Radar"
source_list: array[0]
shuffle: false
available: true
last_called: false
friendly_name: "Alexa Spot"
entity_picture: "https://i.scdn.co/image/204e3cf3edcddf457aebb230edad0bff13e8b7a3"
supported_features: 56253
last_changed: "2019-10-20T07:53:12.988568+00:00"
last_updated: "2019-10-20T07:53:15.540812+00:00"
context: object
new_state: object
entity_id: "media_player.alexa_spot"
state: "playing"
attributes: object
volume_level: 0.2
is_volume_muted: false
media_content_type: "music"
media_duration: 180
media_position: 3
media_position_updated_at: "2019-10-20T07:53:16.091606+00:00"
media_title: "Nicht genug"
media_artist: "Tim Bendzko"
media_album_name: "Release Radar"
source_list: array[0]
shuffle: false
available: true
last_called: false
friendly_name: "Alexa Spot"
entity_picture: "https://i.scdn.co/image/204e3cf3edcddf457aebb230edad0bff13e8b7a3"
supported_features: 56253
last_changed: "2019-10-20T07:53:12.988568+00:00"
last_updated: "2019-10-20T07:53:16.091962+00:00"
context: object
timeSinceChangedMs: 3111
_msgid: "c916906c.ff00f"

The Volume is reported in both new_state and old_state object.

When playing on my Alexa Multiroom Group however:

10/20/2019, 9:57:00 AMnode: 4c56d334.a1c57c
media_player.alexa_spot : msg : Object
object
topic: "media_player.alexa_spot"
payload: "standby"
data: object
entity_id: "media_player.alexa_spot"
old_state: object
entity_id: "media_player.alexa_spot"
state: "standby"
attributes: object
volume_level: 0.1
is_volume_muted: false
media_content_type: "standby"
media_position_updated_at: "2019-10-20T07:56:52.334309+00:00"
source_list: array[0]
shuffle: false
available: true
last_called: false
friendly_name: "Alexa Spot"
supported_features: 56253
last_changed: "2019-10-20T07:56:52.336152+00:00"
last_updated: "2019-10-20T07:56:59.374329+00:00"
context: object
new_state: object
entity_id: "media_player.alexa_spot"
state: "standby"
attributes: object
is_volume_muted: false
media_content_type: "standby"
media_position_updated_at: "2019-10-20T07:56:59.970327+00:00"
source_list: array[0]
shuffle: false
available: true
last_called: false
friendly_name: "Alexa Spot"
supported_features: 56253
last_changed: "2019-10-20T07:56:52.336152+00:00"
last_updated: "2019-10-20T07:56:59.970666+00:00"
context: object
timeSinceChangedMs: 7640
_msgid: "b29e8456.9c7198"

The new state does not report any volume anymore. In the past, this worked fine and the volume was shown for the new_state even though the player itself was shown as being in standby.
However, sometimes this behaviour changes around and the volume is only reported in the new_state instead of the old_state (I do not know yet when exactly this happens. Seems random but could be related to significant volume changes)

@alandtse
Copy link
Owner

We recently made it so devices will update more aggressively if any websocket event is detected for that device, including equalizer events which we used to ignore. These events happen frequently across different devices. What I think may be happening is it's doing a volume update check for individual players that used to not happen and thus it's giving you a strange new state. Can you please pull the volume info from the API when this is happening for you?

It should be basically going to a webaddress like:
https://alexa.amazon.com/api/np/player?deviceSerialNumber=REPLACE&deviceType=A3S5BH2HU6VAYF&screenWidth=2560

Please replace with your device serial number for the Echo Spot that is showing this issue.

@alandtse
Copy link
Owner

When you have the volume value, please also let me know what you expect it to be. Please also pull it from the multiroom group.

@almostserious
Copy link
Author

If i add my device serialnumber and open the page i only get:

{"message":"user not authorized"}

Happens for both alexa.amazon.com and alexa.amazon.de

@alandtse
Copy link
Owner

Please try logging in to the webapp based on your region first. That's the base domain by itself.

If you have alexapy debugging on you can see the exact url for media checking which is where I pulled the example.

@almostserious
Copy link
Author

almostserious commented Oct 20, 2019

After turning on Alexapy debug log i was able to get the correct URLs.

Playing on the device directly gives the correct volume information on the end:

{"playerInfo":{"hint":null,"infoText":{"multiLineMode":false,"subText1":"Pennywise","subText2":"Sonst","title":"Bro Hymn"},"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://i.scdn.co/image/ab67616d0000b273a9435f8b2d7bf5ea2ff8a9ab"},"mediaId":"spotify:track:1ybhXkz4S8k9fdBZNBan7L","miniArt":{"altText":"spotify-logo","artType":"IconArtSource","iconId":"salmon","iconStyles":null},"miniInfoText":{"multiLineMode":false,"subText1":"Pennywise","subText2":"Sonst","title":"Bro Hymn"},"playbackSource":null,"playingInLemurId":null,"progress":{"allowScrubbing":true,"locationInfo":null,"mediaLength":180,"mediaProgress":16,"showTiming":true,"visible":true},"provider":{"artOverlay":null,"fallbackMainArt":null,"providerDisplayName":"Spotify","providerLogo":{"altText":"spotify-logo","artType":"IconArtSource","iconId":"salmon","iconStyles":null},"providerName":"Spotify"},"quality":null,"queueId":"spotify:artist:6i0KVTOvm96T55mbp742ks","state":"PLAYING","template":null,"transport":{"closedCaptions":null,"layoutType":"MusicTransportLayout","lyrics":null,"next":"ENABLED","playPause":"ENABLED","previous":"ENABLED","repeat":"ENABLED","shuffle":"ENABLED"},"upNextItems":null,"volume":{"muted":false,"volume":37}}}

However, if playing on in a group the individual device outputs always:

{"playerInfo":{"hint":null,"infoText":null,"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":null,"mediaId":null,"miniArt":null,"miniInfoText":null,"playbackSource":null,"playingInLemurId":null,"progress":null,"provider":null,"quality":null,"queueId":null,"state":null,"template":null,"transport":null,"upNextItems":null,"volume":null}}

I do not know how to pull this data from the Multroom Group as this doesnt have a device serial number.

@alandtse
Copy link
Owner

The multiroom group should also have a refresh url in the logs. Alternatively, it should appear on this page. (fix your region). Look for something with deviceFamily WHA.

The fact your'e seeing null is probably the problem. The players are basically reporting all the data is null so the individual entities will be null. Is that what your'e basically seeing in nodered?

@almostserious
Copy link
Author

almostserious commented Oct 25, 2019

So finally found the Multiroom group.
The output of the Multiroom Group:

{"playerInfo":{"hint":null,"infoText":{"multiLineMode":false,"subText1":"Katy Perry","subText2":" Road trip singalongs!","title":"Teenage Dream"},"isPlayingInLemur":true,"lemurVolume":null,"lyrics":null,"mainArt":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://i.scdn.co/image/bc200d3297fd526d0567aa9b606281837cec81ac"},"mediaId":"spotify:track:235LXPXfi0SmOaS9TaCh3c","miniArt":{"altText":"externalMediaPlayer-logo","artType":"IconArtSource","iconId":"salmon","iconStyles":null},"miniInfoText":{"multiLineMode":false,"subText1":"Katy Perry","subText2":" Road trip singalongs!","title":"Teenage Dream"},"playbackSource":null,"playingInLemurId":"79e29440284948a8a8c832f087fb7118","progress":{"allowScrubbing":true,"locationInfo":null,"mediaLength":227,"mediaProgress":117,"showTiming":true,"visible":true},"provider":{"artOverlay":null,"fallbackMainArt":null,"providerDisplayName":"Spotify","providerLogo":{"altText":"externalMediaPlayer-logo","artType":"IconArtSource","iconId":"salmon","iconStyles":null},"providerName":"Spotify"},"quality":null,"queueId":"spotify:artist:6jJ0s89eD6GaHleKKya26X","state":"PLAYING","template":null,"transport":{"closedCaptions":null,"layoutType":"MusicTransportLayout","lyrics":null,"next":"ENABLED","playPause":"ENABLED","previous":"ENABLED","repeat":"ENABLED","shuffle":"ENABLED"},"upNextItems":null,"volume":null}}

Well its not exactly how i see it in Node Red... The Volume gets reported but in the wrong place and in the past it worked correct. In Node Red i can see 2 states (old & new). Usually when changing the volume from 10 to 20 on one device, i would expect to see the volume of the "old_state" @ 10 and the "new_state" @ 20.

Now, there is only 1 state reported (sometimes "Old", sometimes "New") but its always the value "20" in my above example.

FYI: Same weird behavior also with mini-media-player. If i change the volume of one device, it shortly shows the correct volume, and then immediately reports 0 again. Is this because Amazon Echo API is not reporting current volume, but only when there is a change?

@alandtse
Copy link
Owner

Ok, so I've had some time to look at this recently. It looks like Amazon has changed some info. This is the output from a WHA.

{"playerInfo":
{"hint":null,"infoText":{"multiLineMode":false,"subText1":"Michael Bublé","subText2":"Pop Christmas Station","title":"Christmas (Baby Please Come Home)"},
"isPlayingInLemur":true,
"lemurVolume":{"compositeVolume":{"muted":false,"volume":37},
"memberVolume":
{"1":{"muted":false,"volume":24},
"2":{"muted":false,"volume":67},
"3":{"muted":false,"volume":33},
"5":{"muted":false,"volume":43},
"4":{"muted":false,"volume":20},
"6":{"muted":false,"volume":40}}},
"lyrics":null,"mainArt":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://m.media-amazon.com/images/I/71n3rg8+l+L._UL600_.jpg"},"mediaId":"7dbbe5b2-6de9-44e8-9307-a02292529d45:3","miniArt":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://m.media-amazon.com/images/I/51pRxvpIfhL._UL256_.jpg"},"miniInfoText":{"multiLineMode":false,"subText1":"Michael Bublé","subText2":"Amazon Music","title":"Christmas (Baby Please Come Home)"},"playbackSource":null,"playingInLemurId":"x","progress":{"allowScrubbing":true,"locationInfo":null,"mediaLength":187,"mediaProgress":47,"showTiming":true,"visible":true},"provider":{"artOverlay":"PRIME_SASH","fallbackMainArt":{"altText":null,"artType":"IconArtSource","iconId":"music-no-art","iconStyles":null},"providerDisplayName":null,"providerLogo":{"altText":"Amazon Music","artType":"IconArtSource","iconId":"amazon-music","iconStyles":null},"providerName":"Amazon Music"},"quality":null,"queueId":"7dbbe5b2-6de9-44e8-9307-a02292529d45","state":"PLAYING","template":{"art":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://m.media-amazon.com/images/I/71n3rg8+l+L._UL600_.jpg"},"backgroundImageUrl":"https://images-na.ssl-images-amazon.com/images/I/A154fbUCwiL._SL1024_CR0,0,1024,600_SCLZZZZZZZ_.png","templateType":"MainArtTemplate"},"transport":{"closedCaptions":null,"layoutType":"MusicStationTransportLayout","lyrics":"ENABLED","next":"ENABLED","playPause":"ENABLED","previous":"ENABLED","rateContentAction":{"mediaOwnerCustomerId":"A318X6SEHCD3EG","rating":null,"type":"RateContentAction"},"thumbsDown":"ENABLED","thumbsUp":"ENABLED"},"upNextItems":null,
"volume":{"muted":false,"volume":0}}}

The key point is the WHA is reporting a volume of 0 and the actual volume is being reported in lemurVolume.

@alandtse
Copy link
Owner

@almostserious Let me know if this works for you.

@almostserious
Copy link
Author

Appears to work fine. Thanks!

@alandtse
Copy link
Owner

@almostserious found a bug today related to certain services not reporting a volume causing an exception. Just pushed a new version into the PR in case you want to update manually. Still one more bug I want to try to address before this will end up in a live version.

alandtse added a commit that referenced this issue Dec 31, 2019
fix(media_player): fix propagation of whole audio groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants