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

I finally tried to set this up, but I am getting a blank playlist input_select. Have you run into this? I am using the legacy login and wondering if it is actually connecting. Is the RW access to the token required?

Hi @tc23

Yes the location for the access token needs to be RW. With the legacy login it will create the temporary token for you. It will need RW access to create the token.

Any error message in the logs related to gmusic?

OK, so I gave the file google.token RW access but I am still getting empty values for the playlist. The only error that I am getting is this

Could not render template gmusic_receiver, the state is unknown.

Is .google.token the right name of the file I should be giving RW access too? Any chance the Google calendar component is conflicting with this?

I think for the legacy login the token will be gmusic_authtoken or .gmusic_authtoken

If there is a . at the beginning, that makes the file hidden on a Linux system. When you configure the legacy login you can not change the name of the access token. It will always be gmusic_authtoken and this file will be created for you. You should not try to create the file on your own.

In the configuration file packages/gmusic_player.yaml the token_path on Line 23 should point to a directory, not to a file.

## Optional for legacy-login - Directory with RW access for "gmusic_authtoken"
    token_path: '/config/.'

A little trick here. In the lines above I have token_path: '/config/.' Notice how I have . at the end of '/config/.' This will create and access token /config/.gmusic_authtoken so the file will be hidden.

Conversely, if I instead used token_path: '/config/' (with no . at the end) I would instead end up the access token /config/gmusic_authtoken and the file would be visible.

So in other words you can use a . to control if the file is hidden or not but you can not change the name itself. The name will always be gmusic_authtoken. I hope that helps make some sense.

regardless the place to configure the directory to store the access token is set on Line 23 packages/gmusic_player.yaml This must be a directory and the directory must have RW access. If your still having troubles please share what you have configured on Line 23 so I can see an idea of what your trying to do.

I have gone back to the check the code. Look like I did put an error ff the legacy login fails. It should be something like "Failed legacy log in, check http://unofficial-google..."

Hi @troy, thanks for the welcome! While it’d be nice if there was a simple copy/paste solution, I wasn’t expecting there to be. :slight_smile: I only just got this up and running, and haven’t had time to dig into the internals too much due to life being life. I was hoping you’d at least be able to point me in a direction to look, which you have, so thank you! I will look into setting up an automation that writes the data from the gmusic_player when it’s active to the default media receiver instance. Even if it’s not easily possible, thanks for work on this plugin. It’s super handy (and fun to watch people’s reactions when you say “Alexa, it’s time to chill” and the mood lighting sets while some background music starts automatically)

1 Like

Glad you’re liking this. I couldn’t remember before but there is a _player_id: attribute for media_player.gmusic_player that will have the name of the connected “Default Media Receiver”.

I’m not good with templating in HA. Back using the gmusic_switch and I really struggled to figure out how to detect which media_player google music was connected to. Eventually I just gave up and hard-coded the media_player I used most into my automations. I added the _player_id: attribute just in case there ever was a need to easily know which media_player you’re connected to.

I think that should make things much easier for you :grinning:

I think I have to try the oauth option, because I have tried 6 ways to sunday to get legacy to work, but to no avail. I’m thinking its the original auth_token which is causing the problem.

The original auth_token file is named .homeassistantgmusic_authtoken. And this new version doesn’t seem to create a new file (is it supposed too?). I tried to rename it to .gmusic_authtoken and insert my dir per the above, but nothing I tried seemed to work. For some clarity, here is the last version I tried:

media_player:
  - platform: gmusic_player
    device_id: 1234
    login_type: legacy
    user: [email protected]
    password: my_pw
    token_path: '/home/homeassistant/.homeassistant/.'

Maybe a stupid question but are you sure you have a directory /home/homeassistant/.homeassistant/
If you go to the developer tool > info what does it say your configuration directory is? Just to be sure

For example, here is a screenshot of mine.

So I would use token_path: '/home/hass/homeassistant/.'

But yes this should create the new file for you. I have tried renaming the old file but that will not work.

The only other thing I can think right now is do you use two factor authentication with you google account? – If so, you need to be using an App Password, not your regular password.

Yep, I confirmed that is the proper path via dev tools. Is the token/oauth file supposed to create itself automatically or is there something that I need to do? Because I tried the oauth login in type as well and that didn’t work either, and no file was created.

Edit: You can forget prior comments haha. I scrapped everything and went back to the beginning and redownload everything from GitHub. Everything is showing up as it should be. Thanks! Sorry for the fire drill!

1 Like

Hey no worrie. Glad it’s working now :grinning:

Um just one thing I am new so this may be a stuped question but can you give me the basic ui-lovelace.yaml card markup. no idea what to add

thx in advance

I can see this in my unused entities and seems to be working just like to add to my lovelace

I’m happy to share mine but it will require the mini-media-player

cards:
  - entities:
      - artwork: cover
        entity: media_player.gmusic_player
        group: true
        hide:
          progress: true
        replace_mute: stop
        source: icon
        type: 'custom:mini-media-player'
        volume_stateless: true
      - entity: input_select.gmusic_player_source
      - entity: input_select.gmusic_player_speakers
      - entity: input_select.gmusic_player_playlist
      - entity: input_select.gmusic_player_station
    type: entities
type: vertical-stack

Here’s how that looks. OFF and ON



You can make your own simple card view using an entities card


Just start typing gmusic and it will give you a list of thing to add related to gmusic


These are the 5 entities you will likely want.
The others things don’t really need displayed but no harm adding them if you want

1 Like

thx this looks perfect

So got mine done and some style to it and boom !!!

Here is my GMusic Tab thx @troy

gmusic

3 Likes

Is there a way to change the ‘speakers’ value thru some code or something, instead of thru the interface?

I have gmusic currently running now (and it’s great, thanks!!!), but I’m used to the node red side of things, and am not sure if this is possible or not.

Perhaps some function or service call?

(I took a look for some previous answers, and didn’t see anything come up)

Hello @phreaq

Currently there is nothing built into the GM media player to select speakers but that is something I hope to add when I have time to continue work on this project.

Sorry I can not share anything off the top of my head but I would imagine any type of automation to select values from an input_select would work.

Thanks Troy,

I don’t have much experience in changing the entitie’s properties, I tried the below service node, but had no luck.

Anyone have any pointers? I’m sure it’s something simple.

tia

I don’t use Node Red so I’m not sure if this will help in any way but for example to select the speakers using the services in HA this should work.

Edit: Just a guess but in your Node Red screenshot, maybe try changing set_options to select_option

perfect! that gave me what I needed (and yes, I needed the “select_option”, among other tweaks)

again, thanks for your help, and your work on this. I used gmusic many moons ago in Kodi, until the 2 step verification broke my build. I’m glad I’m reunited with it again.

for the benefit of others, below is what worked for me.

1 Like

very welcome addition to my setup, thank you very much.

so far i got it up and running. but i understand how to refresh my stations? i have only 2 from which i can choose “feeling lukcy” and some random other one. If i call the service with a different station, the log only shows me that I could select from that two. any hints?

edit: nevermind, I didn’t get that these are the stations out of my musiclib and not the one the subsciption provides.