Google music in HA

Someone please tell me how to set this up in hassio. I also have another pi laying around, can I somehow install hassbian on that one and interface with my hassio instance?

for those running in hassio or docker try this:

shell_command:
  install_gmusic: pip install gmusic

and an automation to trigger that on home-assistant start to your package and it should work, ( note: it will not work the first time you start hassio or docker after updateing versions, but on subsequent restarts it should function, just make sure to give that command enough time to run before restarting.

3 Likes

Could I just create an input_boolean and have that trigger the shell command? Sorry, haven’t ever used shell command!

A script would be easier, but you can execute it however you want.

Installation was smooth, everything seems to be working… Still getting thiese messages everywhere in my logs:

Mar 28 12:25:23 automation hass[10470]: 2018-03-28 12:25:23 INFO (SyncWorker_19) [gmusicapi.protocol.shared] could not locate client caller in stack:
Mar 28 12:25:23 automation hass[10470]: File “/usr/lib/python3.6/threading.py”, line 884, in _bootstrap
Mar 28 12:25:23 automation hass[10470]: self._bootstrap_inner()
Mar 28 12:25:23 automation hass[10470]: File “/usr/lib/python3.6/threading.py”, line 916, in _bootstrap_inner
Mar 28 12:25:23 automation hass[10470]: self.run()
Mar 28 12:25:23 automation hass[10470]: File “/usr/lib/python3.6/threading.py”, line 864, in run
Mar 28 12:25:23 automation hass[10470]: self._target(*self._args, **self._kwargs)
Mar 28 12:25:23 automation hass[10470]: File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 69, in _worker
Mar 28 12:25:23 automation hass[10470]: work_item.run()
Mar 28 12:25:23 automation hass[10470]: File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
Mar 28 12:25:23 automation hass[10470]: result = self.fn(*self.args, **self.kwargs)
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/custom_components/switch/gmusic.py”, line 120, in turn_on
Mar 28 12:25:23 automation hass[10470]: self._play()
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/custom_components/switch/gmusic.py”, line 209, in _play
Mar 28 12:25:23 automation hass[10470]: self._next_track()
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/custom_components/switch/gmusic.py”, line 174, in _next_track
Mar 28 12:25:23 automation hass[10470]: url = self._api.get_stream_url(track[‘trackId’])
Mar 28 12:25:23 automation hass[10470]: File “”, line 2, in get_stream_url
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/deps/lib/python3.6/site-packages/gmusicapi/utils/utils.py”, line 293, in wrapper
Mar 28 12:25:23 automation hass[10470]: return function(*args, **kw)
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/deps/lib/python3.6/site-packages/gmusicapi/clients/mobileclient.py”, line 388, in get_stream_url
Mar 28 12:25:23 automation hass[10470]: return self._make_call(mobileclient.GetStreamUrl, song_id, device_id, quality)
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/deps/lib/python3.6/site-packages/gmusicapi/clients/shared.py”, line 84, in _make_call
Mar 28 12:25:23 automation hass[10470]: return protocol.perform(self.session, self.validate, *args, **kwargs)
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/deps/lib/python3.6/site-packages/gmusicapi/protocol/shared.py”, line 243, in perform
Mar 28 12:25:23 automation hass[10470]: log.debug(cls.filter_response(parsed_response))
Mar 28 12:25:23 automation hass[10470]: File “/home/netadmin/.homeassistant/deps/lib/python3.6/site-packages/gmusicapi/utils/utils.py”, line 107, in getattr
Mar 28 12:25:23 automation hass[10470]: stack = traceback.extract_stack()

1 Like

@Spartan.II.117 for what it’s worth,

pip3 install gmusicapi

worked for me

Hassio 0.66.1

@hovee, Very impressive your RFID Jukebox.

Did documented your project ?

  • For exemple, what kind of card did you use ?
  • How did made the printout ?
  • What device did you use to detect the rfid card ? (shown in the video)
  • What did you use on the rasberry to talk to this device

You should be able to find all the necessary info on my GitHub page for the project.

Thanks for checking it out!

2 Likes

I used the “pip3 install gmusicapi” command you suggestion for my Hassio.

I got the following error :

Does it matter ?

Are you running hass.io on a raspberry pi?
I had no problems on version 0.66.1.
I never saw anything like what you posted.

I confirm Hassio on raspberry PI 3 Model B.

I’m also running 0.66.1
image

Anyone has ideas ?

This is what I added to my configuration.yaml

shell_command:
  install_gmusic: pip3 install gmusicapi

automation:
  - alias: homeassistant_start
    trigger:
      - platform: homeassistant
        event: start
    action:
      - service: shell_command.install_gmusic
2 Likes

Tx,

I managed to install it.
Now I see my playlists. I also see my media player.

image

image

However, I am unable to play on the media player. The media player I have is an android TV (sony bravia - They have an integrated chromecast)

Is it compatible ? I have plan to buy a Google Home. That would be compatible right ? Or should I buy a chromecast ?
What if I was to pair my soundbar with Bluetooth ?

Should just be mybraviatv (without the media_player and the dot, these are added automatically by the component)

1 Like

I’m running into problems with connecting an RFID reader to my Google Music account, as outlined in the project @hovee linked to above: https://github.com/hoveeman/music-cards

I would appreciate it if anyone is able to point me towards ways to fix the error I’m having.

Specifically, when I run the box.py script file (https://github.com/hoveeman/music-cards/blob/master/box.py):

pi@raspberrypi:/srv/music-cards $ python box.py
Ready: place a card on top of the reader

After I place a card on the RFID reader (the card contains the long playlist string value beginning with ‘AMaBXym0uigH267zE…’), I receive the following error messages:

Read card 0011789235
Playlist AMaBXym0uigH267zE-YLf5B9FSUTcS5aKz64vlbi35I_lz0XnBtE4iWgk9fNN-x0t5BPuFYBcATRARo_bBaT1zEqPUdf6nRO8Q%3D%3D
/bin/sh: 1: ./haplaylist.sh: Permission denied
Traceback (most recent call last):
  File "box.py", line 23, in <module>
    subprocess.check_call( ["./haplaylist.sh %s" % plist], shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['./haplaylist.sh AMaBXym0uigH267zE-YLf5B9FSUTcS5aKz64vlbi35I_lz0XnBtE4iWgk9fNN-x0t5BPuFYBcATRARo_bBaT1zEqPUdf6nRO8Q%3D%3D']' returned non-zero exit status 126

Thank you

First thing you may want to try is make the haplaylist.sh executable. Go to the directory that the shell script is in and run
sudo chmod +x haplaylist.sh

Also when programming the cards you actually want to input the name of the playlist as it shows in Google Play. For instance in my video I pick up Justin Timberlake Man of the Woods. I have a playlist called ManOfTheWoods with those songs in it. ManOfTheWoods is what I typed in when I scanned the card to add. You need it to be the name of the playlist since that is what the gmusic looks up to play. Also, I was having issues with spaces in the playlist names so I just made all my playlist names not have any spaces. Check out the pic of how the playlist looks.

Hope this helps!

Thanks @hovee

That’s helpful. I’ve done the things you’ve suggested. Specifically, after making the file executable I renamed my playlist to match the long string attached to the RFID (I ran out of cards, so instead of naming the album something like ‘ManOfTheWoods’ I renamed it to match the long string of characters, ‘AMaBXymm-3lQo7bwhEnf…’).

Unfortunately there is still something else that’s not quite right. If you or anyone has any ideas about addressing this they’re welcome.

When running box.py, I get the following messages when tapping an RFID card to the reader:

(homeassistant) pi@raspberrypi:/srv/music-cards $ python2.7 box.py
Ready: place a card on top of the reader
Read card 0011805693
Playlist AMaBXymm-3lQo7bwhEnf-CAt9qCATWdkkHUeUfmS8UhI8mXybUqsOTLyELAbYLZxVSLswTPZ3pNTp7sO_1YmQpztP68Uyp9kaA%3D%3D
Traceback (most recent call last):
  File "box.py", line 23, in <module>
    subprocess.check_call( ["./haplaylist.sh %s" % plist], shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['./haplaylist.sh AMaBXymm-3lQo7bwhEnf-CAt9qCATWdkkHUeUfmS8UhI8mXybUqsOTLyELAbYLZxVSLswTPZ3pNTp7sO_1YmQpztP68Uyp9kaA%3D%3D']' returned non-zero exit status 28

…and see this corresponding set of messages in my home assistant log:

2018-04-13 10:37:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_data=entity_id=input_text.playlist, value=AMaBXymm-3lQo7bwhEnf-CAt9qCATWdkkHUeUfmS8UhI8mXybUqsOTLyELAbYLZxVSLswTPZ3pNTp7sO_1YmQpztP68Uyp9kaA%3D%3D, service=set_value, service_call_id=1976218992-2, domain=input_text>
2018-04-13 10:37:54 WARNING (MainThread) [homeassistant.core] Unable to find service input_text/set_value
2018-04-13 10:37:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: exception=, source=core.py, message=Unable to find service input_text/set_value, level=WARNING, timestamp=1523615874.19715>
2018-04-13 10:37:54 INFO (MainThread) [homeassistant.components.http.view] Serving /api/services/input_text/set_value to 192.168.1.10 (auth: True)
2018-04-13 10:37:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_data=entity_id=input_text.playlist, value=AMaBXymm-3lQo7bwhEnf-CAt9qCATWdkkHUeUfmS8UhI8mXybUqsOTLyELAbYLZxVSLswTPZ3pNTp7sO_1YmQpztP68Uyp9kaA%3D%3D, service=set_value, service_call_id=1976218992-3, domain=input_text>
2018-04-13 10:37:54 WARNING (MainThread) [homeassistant.core] Unable to find service input_text/set_value
2018-04-13 10:37:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: exception=, source=core.py, message=Unable to find service input_text/set_value, level=WARNING, timestamp=1523615874.2507396>

Thank you

Weird…

It work for a few days and now it is not working.
Seem like I am missing the ‘gpsoauth’ component.
I tried installing it manually.
When I tries, it say then I miss gcc.
Any idea why it stopped working and why I am missing gpsoauth?

Hi,
sorry for asking, just to be sure: It does not work with the original / 1st gen chromecast?
I got it working with my google home, but when switching to my chromecast, i get “not a vaild media player” in hass’ logfile…

it will only work with ChromeCast Audio or Google Home devices, not ChromeCast Video