Google music in HA

Sorry, no. I posted here because I was looking for some support myself. I still don’t know what the issue is.

I think I have fixed your bug, so try update to the latest version of the component.

@Danielhiversen Latest version errors (truncated because there were many more of the same):

17-02-17 17:18:36 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=EQnWXmwre0IlSZns1AIEF9F_ml8&songid=5891a4dd-d933-303e-b64d-fc578dbad0ea&slt=1487351916230&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'EQnWXmwre0IlSZns1AIEF9F_ml8', 'songid': '5891a4dd-d933-303e-b64d-fc578dbad0ea', 'slt': '1487351916230', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:37 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=1mg-sB9S9m-xVQeRtBv0Mk6TmxM&songid=39fcfeff-8f3a-31c3-84fe-3f28d8e55c10&slt=1487351916875&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'1mg-sB9S9m-xVQeRtBv0Mk6TmxM', 'songid': '39fcfeff-8f3a-31c3-84fe-3f28d8e55c10', 'slt': '1487351916875', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:37 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=7OXsreXfRyIyu5CUZQAo1SglJAk&songid=3033949d-86d1-3671-8569-9748ad687524&slt=1487351917380&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'7OXsreXfRyIyu5CUZQAo1SglJAk', 'songid': '3033949d-86d1-3671-8569-9748ad687524', 'slt': '1487351917380', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:38 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=dfg06XubpLO1rLLYFOFGDZ2u7GQ&songid=87cabba9-7eea-3ff8-8cb8-213e609f598f&slt=1487351917873&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'dfg06XubpLO1rLLYFOFGDZ2u7GQ', 'songid': '87cabba9-7eea-3ff8-8cb8-213e609f598f', 'slt': '1487351917873', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:39 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=jBdKyGq-2EDF14e_XaUn-j2uq3E&songid=859abe2c-517a-373e-ba6c-eea8a153e752&slt=1487351918467&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'jBdKyGq-2EDF14e_XaUn-j2uq3E', 'songid': '859abe2c-517a-373e-ba6c-eea8a153e752', 'slt': '1487351918467', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:39 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=s1IRrRMO0SGOMFb92EM_0aKX5WQ&songid=cf6cf7b9-685c-33d2-b1f2-44d3864eca21&slt=1487351919075&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b's1IRrRMO0SGOMFb92EM_0aKX5WQ', 'songid': 'cf6cf7b9-685c-33d2-b1f2-44d3864eca21', 'slt': '1487351919075', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:39 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=Q7H0AdrsrI0cHO0HDajtIjIPOaQ&songid=497c830d-83e3-3a85-8b4b-d80f129942e8&slt=1487351919554&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'Q7H0AdrsrI0cHO0HDajtIjIPOaQ', 'songid': '497c830d-83e3-3a85-8b4b-d80f129942e8', 'slt': '1487351919554', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:40 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=8Ak13L2aOxfsLI_Ggh4jitZdvAU&songid=3f8461ea-5949-3457-92f4-fa1d7183b57b&slt=1487351920026&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'8Ak13L2aOxfsLI_Ggh4jitZdvAU', 'songid': '3f8461ea-5949-3457-92f4-fa1d7183b57b', 'slt': '1487351920026', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))
17-02-17 17:18:40 ERROR (Thread-11) [custom_components.switch.gmusic] Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?tier=fr&opt=hi&dv=0&hl=en_US&net=mob&sig=Tgvpm7lVmUiSn3pqXLWK0icfvBU&songid=8bbc686f-1097-3967-a897-0984c1dd8e29&slt=1487351920380&pt=e
(requests kwargs: {'method': 'GET', 'headers': {'Authorization': '<omitted>', 'X-Device-ID': '10247041828371776762'}, 'url': 'https://mclients.googleapis.com/music/mplay', 'params': {'tier': 'fr', 'opt': 'hi', 'dv': 0, 'hl': 'en_US', 'net': 'mob', 'sig': b'Tgvpm7lVmUiSn3pqXLWK0icfvBU', 'songid': '8bbc686f-1097-3967-a897-0984c1dd8e29', 'slt': '1487351920380', 'pt': 'e'}, 'allow_redirects': False})
(response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n'))

I have exactly the same ones, over and over…
It even crashes the PI after some time, if I do a tail -f to the log file, the file is growing massively every with loads of errors each second.
I can see the playlists I have available though.

Thanks @Danielhiversen

I can confirm the newest version eventually crashes HA.

I have fixed some bugs in the code, so hope it works better now.

1 Like

Is this component’s purpose to stream a google playlist to any media player? Can it stream to multiple media players in sync? Can I pick a specific song and play it to one / all? Sorry for the confusion.

@danielhiversen Still similar issues.
@geman220 Yes, No, No.
You can only have sync if you play to Chromecast audio, and your Chromecast audio devices are already grouped in the Google Home app.

1 Like

@Danielhiversen still the same :frowning:

@DavidSpivey @joaoasilva
What error message are you getting?

@Danielhiversen exactly the same one @DavidSpivey mentioned before.
Thanks

Ok, could you try to use the gmusicapi library to get a url, and try to play that directly?

@Danielhiversen Could you provide some ipython code to try that? I would like to attempt it, but python is not familiar to me.

1 Like

@Danielhiversen can you give us a quick how to?
thanks

Just what I wrote in the first post. That works perfectly here.

If you want to solve your issue, I would recommend read up on the gmusicapi library and try the library outside of HA.
You can use my python code as an example of how to use the gmusicapi library.

@Danielhiversen the fact me and @DavidSpivey are using HASSBIAN, can that be a problem?
I’ve installed in the virtual env, does it need to be outside?

It should work with hassbian too. It has to be installed inside the virtual env.

Are you sure the device_id is correct?
You should use this function to get the id: http://unofficial-google-music-api.readthedocs.io/en/latest/reference/mobileclient.html#gmusicapi.clients.Mobileclient.get_registered_devices

2 Likes

@Danielhiversen oh… maybe you’re right! I got it wrong, don’t know why as I just copy-pasted it, unless I’ve generated a new id for some reason.
I went on my google play account on the browser -> Settings and did inspect the devices button “Unauthorize” and looked at the device id in there format: 0x34**********a**9. Is this, right?
I’ve just copy-past the new one and will try again later and I’ll let you know if it worked, thanks!

@Danielhiversen It finally worked, thanks to that new piece of information. After getting ipython installed in the venv, I ran the previously mentioned script, adding the new information to get a VALID Android ID.

from gmusicapi import Mobileclient
api = Mobileclient()
api.login(config['user'],config['password'], config['device_id'])
api.get_registered_devices()

@joaoasilva The Device ID is without “0x”, but it is the correct ID that starts with that.

1 Like

I now get this error in log:

17-03-19 10:19:42 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform gmusic
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 153, in _async_setup_platform