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

:warning: Do not install this component

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


14 Likes

From the appdaemon thread but on this the topic here

I do have the instructions for oauth in the appdaemon version, need to get that transferred. I’m not sure how you go about it on hass.io though. It’s the only reason I set legacy as the default login and included those instructions. I figured it’s easier for most people since hass.io has taken over.
If you are using the legacy login you can sign in using App Passwords to avoid exposing you actual password. I think it’s a decent middle ground if you are unable to create the oauth credentials file.
You are correct though, oauth login is very much prefered.

A custom component card would be awesome and I would certainly appreciate some help and advice in the code department! I’ve wrote some simple bash scripts before but otherwise only have a whole 2 months experience with python or any other programming for that matter.

To get rid of the input selects I do already the list of both available playlists and stations in the gmsuic_player attributes. I was thinking to take shortcut and just use media_player.select_source to set the speakers but I just don’t like the term source here. To me the source is either a playlist or station. I was thinking to try and add a custom service to select_receiver or select_speakers.

I haven’t heard of the app “qcast” but what you describe would be awesome!

Its also possible to generate an Oauth token on your personal PC and transfer it to your HA instance

@troy, thanks so much for this! I’ve toyed with integrating this into my instance of home-assistant for a year or more without much success. All three of your methods have worked fantastically, with this iteration being the simplest/cleanest to throw into my config.

Although this works, I’m presented with the following error when validating my configuration:

Invalid config for [media_player]: required key not provided @ data['platform']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/media_player/

I’ve looked for typos, extra or not enough spaces in the yaml formatting, but can’t seem to determine the issue. I’ve even re-downloaded the files hosted on your Github account thinking that was the issue. What’s puzzling is even with configuration error, it works with my playlists, stations, and Google cast devices.

The version of home-assistant I’m running is: 0.94.3

@wvdeadhead
Welcome to the forums :grinning:

I’ve just downloaded the files myself to be sure but I am unable to reproduce your error.

Would you mind sharing your package.yaml file? If your not using a secrets file be sure to remove your username, password, device_ id first though!

I actually just found the error… not in you package, but coincidentally was due to my

media_player: !include media_player.yaml

configuration which is now blank due to removing my Google Music MPD server config. I commented out the media_player line in my configuration file to fix.

Thanks for your hard work on getting Google Music in HA and sorry for the false alarm.

No worries! Glad you got it sorted.

And Thank You for trying this out! :grinning:

@troy

I just wanted to thank you for your great efforts on this. I have used this to integrate Google Music onto my NuVo system (including browsing playlists and stations from the keypad) and it has been working flawlessly!

While I’m not sure the feasibility, I have come across a couple things that would make it even better. Those would be access to the ratings (thumbs up/down) and the ability to refresh stations / playlists without restarting HA.

1 Like

Is this awesome component likely to make it into the HACS repository?

@smccoy
Refreshing playlist and stations should be an easy add since I had something for that in the appdaemon version already, but that did require another input boolean to trigger. I was hoping to add that back in here using a custom service instead.

I’ve been wanting to do something for ratings as well. Again something I was hoping to use a custom services for. Aside from using a custom service, It’s definitely on my plate but I haven’t spent any time with time with the ratings yet so I’m not sure how difficult it will be integrate but I sure it’s possible

@sparkydave
Definitely something I would like to do in the future. I don’t think I need too much for this to work but I will need to make some new git repos. A requirement is for HACS is only ONE custom component per repo so I need to split some things up on my side.


I’ll admit I’ve been slacking on this (and everything else involving sitting at a computer) for a few week though, Works been busier than expected and summertime hobbies are fighting for attention as well. I will get back soon.

Thanks for all your hard work on this Troy! I’ve just got it working in my own installation and am very pleased with it. :smile:

1 Like

I’m happy to hear that these are in the potential pipeline. I look forward to adding these features when that time comes! I understand the busy thing well. Hence the (extended) delay in my response. There are so many things to occupy time when the weather is nice.

This component is still working great for me. I have noticed that after restarting HA, I cna often only play 1 song from a station (and sometimes playlist) and it stops. It takes some combination of power cycling the media player or switching to playlist to restore playback at which point it works great again. Has anyone else seen similar behavior?

1 Like

Thanks for this. Not directly related but I’m trying use my MiBox3 (as “speakers”) which is setup as a media player using the cast platform, but whenever I try to play content I get an error saying it is not a valid media player and the gmusicplayer wont turn on. Any ideas?

2019-07-24 21:41:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.139909208805456] Received {'type': 'call_service', 'domain': 'media_player', 'service': 'play_media', 'service_data': {'entity_id': 'media_player.gmusic_player', 'media_content_type': 'station', 'media_content_id': "'90s Alternative Rock"}, 'id': 20}
2019-07-24 21:41:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=play_media, service_data=entity_id=media_player.gmusic_player, media_content_type=station, media_content_id='90s Alternative Rock>
2019-07-24 21:41:27 ERROR (SyncWorker_5) [custom_components.gmusic_player.media_player] (media_player.mibox3) is not a valid media player.

This looks awesome, thanks for your work. Would love to see it in hacs. Two questions:

Will this work with Google’s two factor authentication?

How do I get a device ID?

Thanks for your help.

If your using two factor auth you need to use an App Password.
To be clear, it’s a Google thing: Instructions can be found here

To get a valid device id is pretty simple trick. Just try to log in without one!
Your username and password (use app password you just created) must be correct. Enter something like 00 as you device id then restart HA. Google Music will fail login with id 00 but in the logs you will find your valid device ids.

Look for this error in HA logs and click on it to view more information.

If your username and password are valid for Google Music, it will give you a list of your valid device ids. You may have more or less device ids in your list but any of them should work.

I’ve tried this now with a Gen3 Chromecast and still get the same error

[custom_components.gmusic_player.media_player] (media_player.chromecast6209) is not a valid media player.

@slipx06 I’m so sorry I missed your first post.

In the package file where you have configured your media_players or “speakers” did you happen to add the media_play. prefix to your speakers? media_player. should not be added to names in this list.

I’m taking a guess here, but I feel like your config might for example look like this:

input_select:
  gmusic_player_speakers:
    name: Speakers
    icon: mdi:speaker
    options: ## ONLY HERE - Replace with entity_ids of your own media_players
    - media_player.mibox3
    - media_player.chromecast6209

Please try removing media_player. so it looks like this:

input_select:
  gmusic_player_speakers:
    name: Speakers
    icon: mdi:speaker
    options: ## ONLY HERE - Replace with entity_ids of your own media_players
    - mibox3
    - chromecast6209
1 Like

Yes that was the problem. Thank you for the help. It’s working now. Great job

1 Like

I finally got this up and running properly, and it’s nice to be able to automate with my harmony for difference scenes. I was curious though, since I’m casting this to a TV, and it only just shows “Default Media Receiver” instead of the song data, is there any way/plan to be able to mirror the song data from the gmusic_player instance to the playing chromecast?

@spcedrgn Welcome!

I’m sorry, off the top of my head I can not provide something as simple to just copy and paste but I think you could use an automation to set the state of these “Default Media Receiver” attributes.

 media_artist
 media_album_name
 media_title
 entity_picture

I can look more into providing a copy and paste solution for this case but it will be a while before I have time to return to working on this project.