Google Music in HA -- Now as a media player!

Hi @sparkydave – The debug output you are seeing is from gmusicapi and this is normal (I’m surprised you have not seen this before) I’m running HA from a virtualenv and this debug output has been in my logs since day 1 of using this component.

I’m running 0.113.1 myself and have not had issues with gmusic player. The code base I started with is from years ago. I would not be surprised to hear this if this is causing a slow start-up.

It’s my understanding, that if this ( or other custom components ) are blocking HA from starting, there should be some indication of this in the HA logfile. I saw a mention of this on Discord but I’m not sure the details of how this works

I’ve not been able to get this working yet.
I’ve setup an app password & the plugin loads as far as I can see. (Also In about 3 days experienced with home assistant, so I’m a bit of a novice with this, but I am a software engineer though, so I’m not too scared to tinker if needs be)

I’m currently getting this issue, but I’m not too sure if its caused by a misconfiguration from my side, or this plugin not working currently etc?

Any help will be appreciated.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/gmusic_player/media_player.py", line 405, in _update_sources
    self._update_playlists()
  File "/config/custom_components/gmusic_player/media_player.py", line 430, in _update_playlists
    self.hass.services.call(input_select.DOMAIN, input_select.SERVICE_SET_OPTIONS, data)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1193, in call
    return asyncio.run_coroutine_threadsafe(
  File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 208, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 287, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 283, in _exec
    v = func(v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: length of value must be at least 1 for dictionary value @ data['options']

I saw another comment on here to check if the script.gmusic_sync_media has been loaded… but as far as I can see it is not (when checking inside /developer-tools/service), how can I get this to load? (I saw there are configs for them inside the gmusic_player.yaml file… but again… noo idea how this works)
2020-08-02 at 10.23

@rohan-buchner – Please try the following

Edit -> homeassistant/packages/gmusic_player.yaml

Go through the file and find all 3 lines containing

    - " "

Change each of these lines to something like

    - "loading"

You’ll need to restart homeassistant for these changes to take effect

Thank you for that… but I think that somehow just updated the default values to loading :stuck_out_tongue:

I think somehow the plugin isn’t connecting to Google Music. I had a look at the connection values for the app login. Just to confirm this is the right format?

gmusic_username: [email protected]
gmusic_password: werfrandomcrapewld
gmusic_device_id: some:11222111-2222-1111-2222-112211122211

2020-08-02 at 19.05

You need to use an android device id

gmusic_device_id: some:11222111-2222-1111-2222-112211122211

should look something like

gmusic_device_id: "3d123400daee56ff"

you can use the following to get a list of all your valid device ids, but only the 16-digit android one will work with gmusic player – You should see the device ids in the logs, they are printed in an error message

gmusic_device_id: "00"
1 Like

AHA! Ok. I did do that check to get my original device ID… BUUUT. I’m one of those Mac fanboys when it comes to mobile phones… haha. I ended up logging into my google acct on my fiances android phone & then tried to setup an app password from there… but I only get the options below… google also doesn’t seem to have a lot of context on how to get an android app password.

That being said, thank you for help so far.

Update
I looked at the plugin code you wrote & saw this lib linked in the comments.
https://unofficial-google-music-api.readthedocs.io/en/latest/reference/mobileclient.html

I think the only option I have is to setup oauth :stuck_out_tongue: since the other 2 login methods also use the device_id

Update 2
Any advice on how to setup google oauth? My google fu isn’t returning any decent results, so I’m stuck in the dark yet again.

Update 3
Found it… Installed this python package.

and then ran. google-music-auth ./oauth

Time of death…

gmusicapi.exceptions.CallFailure: GetDeviceManagementInfo: 403 Client Error: Forbidden for url: https...

Seems to do with the internals of the auth mechanic When not supplying an actual device ID… the lib uses something called the FROM_MAC_ADDRESS value, which doesn’t seem to be reliable.

Ok I learned a bit from this… but I don’t think its worth pursuing this route much further. I believe the easiest would be to get a throw away android device that can sleep in my cupboard :stuck_out_tongue:

you can try https://github.com/miikkajo/gmusicproxy to generate token with,
it has working oauth login in it

3 Likes

Gmusic works very well in HA with your proxy and Troy’s component (no timeouts or track skipping).

Sole worry is what will happen once support for Gmusic ends :frowning:

1 Like

Offtopic, does anyone intend to make a custom component for TIDAL?

It’s not the easiest approach - but I’m using a device id from an Amazon Fire 7 tablet. For some added value, you can also install Fully-Kiosk or WallPanel to make further use of the tablet.

:frowning: The end is near

Can anybody make a suggestion for a beginner based, on-line Python course? I can’t make any promises but there are several possibilities to revive this in the future.

1 Like

I’m trying to play a playlist in an automation without shuffle but it always shuffles. How can I get it to play from track 1 onwards?

I’ve tried with the shuffle: false as data for the play script.

@OptimusGREEN – I don’t think I ever got the shuffle mode working the way I intended

From the services page, please try media_player.shuffle_set

entity_id: media_player.gmusic_player
shuffle: false

I think because it’s buggy, you might need to reload the playlist after you set shuffle: false

ideal, thats it working. thanks very much

expected a dictionary for dictionary value @ data['packages']['media_player']

can someone help ;/

just a thought that hit me… anyone have an contingency plan when gmusic finally hits the grave?

just found: Youtube Music - Media Browser

resp. https://github.com/sigma67/ytmusicapi

lets hope for the best…

1 Like

There’s also a drop of hope here (but there hasn’t been any activity yet): gmusicproxy - Migrate to YouTube Music - If that happened, I might be able to make this work, since we can already play from gmusicproxy.

Honestly though, with every new release of Home Assistant, I think the more this needs this refactored from the ground up. I’d still hope someone who actually knows python will write a new integration for YouTube Music, that can also take advantage of the new media browser capabilities in Home Assistant

1 Like

It’s happening…

I have received the first report, this has stopped working due to the Google Music shutdown :sob:

I’m no help as I can’t code but I have glanced over these:
https://ytmusicapi.readthedocs.io/en/latest/

Any way they can help with a migration from Gmusic to YTM? (now seeing one has been linked already)

Hi all,

I keep getting the “Failed legacy log in, check http://unofficial-google-music-api.readthedocs.io/en/latest/reference/mobileclient.html#gmusicapi.clients.Mobileclient.login” when I login. I have created an App-password for 2FA, but still it fails.
I also tried the properties for username and password with and without ‘quotes’. No change

Can you point me in the right direction?

What can I be missing?

I installed via HACS and changed the config file:

gmusic_player.yaml:

media_player:
  - platform: gmusic_player
    device_id: 00
    username: my_google_music_account_name
    password: app_password_provided_by_google

:warning: Do not install this component

Google Music will be completely shutdown by December 2020
This component will stop working at that time.

UPDATE: 12/05/2020