Closed almostserious closed 4 years ago
I'm not sure what the issue is. What states are you querying? What entities? What do the logs say?
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)
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.
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.
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
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.
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.
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?
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?
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
.
@almostserious Let me know if this works for you.
Appears to work fine. Thanks!
@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.
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