Google music in HA

Same here. Got it working again by editing the python file and removing the entry MEDIA_TYPE_MUSIC from line 20. But please bear in mind that I’m meddling with something I don’t understand, so a backleash may be possible. It works for me, but I get a new warning in the log saying:

Your configuration contains extra keys that the platform does not support.
Please remove [user], [password], [device_id], [media_player], [playlist].

The line the refers to is the one where I integrated my gmusic-switch.

1 Like

It works - so for now, my showers with music are saved!
So sad that Danielhiversen gave up the development of this awesomeness

Did someone get it working with 0.89 ?

I just did the renaming as suggested here:

So my component strucuture looks like this now:

custom_compontents
└── gmusic
    ├── __init__.py
    └── switch.py

However I never can see the gmusic switch as before.

1 Like

So did .89 kill this? If so, what a bummer

At least I could not figure out how to get it working on 0.89

Since I already have the NFC cards I will have a look how to pass the playlist to my Google homes.
I saw a add on which could pass TTS to the Google home.
Maybe I can get it to work that way around.

This would be more native than writing a custom component.

The Hassio addon has a limitation that any cast commands are ignored, however this docker container works great: Google Assistant Webserver in a Docker container

1 Like

I made it work in 0.90. Your folder setting is correct. But you should also update the switch.py

Great news! I’m way behind on my updates, but I like the new Stream update (would like to see unifi though), but I can’t lose my precious google music!

@MomoB Could you show me your relevant config?

My switch.py: https://hastebin.com/osadalejuq.py
My media_players.yaml: https://hastebin.com/oxejikerev.cs

I am still getting an error in home assistant:

Unable to find platform gmusic.

Thank you for the hint.

Got it working and it behaves perfect for this usecase.
I can successfully call my playlists.

Now I need to think about how I want do the mapping between the RFID cards and the playlist.

I could simply use the same service and just do a curl to the specific playlist.

Will hopefully have time tomorrow for testing.

Your files are similar to mine, only difference is that i did not put my credidential in !secret .

But did you also copied the __pycache__ file that was in the previous custom_components/media_player folder ?

I’m my homeassistant/custom_components/gmusic i have

__pycache__
__init__.py
switch.py

Confusing.

The pycache folder should not be important in that case. There is only python bytecode which is created after the first start normally.

Is your configuration available at github or something?
I need to commit my latest changes and would like to have a look to a working config.

@claytonjn Thanks again for the hint.
I think I will go this route:

I have setup Google Assistant Webserver in a Docker container.

I then can create my notify service:

notify:
  - name: ga_broadcast
    platform: rest
    resource: !secret google_assistant_webserver_broadcast_message
  - name: ga_command
    platform: rest
    resource: !secret google_assistant_webserver_command

Now I can create automation to use these commands:
The reset playlist automation will always get the input_text to back to “BootValue”.

For every playlist I would have an automation.

input_text:
  playlist:
    name: playlist
    initial: BootValue

automations:
- alias: Reset playlist value
  initial_state: True
  trigger:
  - entity_id: input_text.playlist
    from: BootValue
    platform: state
  action:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.playlist
        value: "BootValue"

- alias: Play linkin park
  initial_state: True
  trigger:
    - platform: state
      entity_id: input_text.playlist
      to: '0011205436'
  action:
    - service: notify.ga_command
      data:
        message: "Play the playlist LinkinParkMeteora on uberall"

- alias: Play Motivation
  initial_state: True
  trigger:
    - platform: state
      entity_id: input_text.playlist
      to: '0016042153'
  action:
    - service: notify.ga_command
      data:
        message: "Play the playlist Motivation on uberall"

This works so war via the home assistant webinterface.

Now I try to figure out how to pass only the RFIF Card ID to the home assistant input_text.

I know how to do this via curl, but I do not know how I get the RFID Card ID from the reader right now.

Hopefully I can figure that out.

Great work!

You can use my code to grab the RFID cards from the reader to do the curl command.

I’m trying to reset mine back up after all the HA updates and sifting through this thread.

I got mine playing again, but they are always playing shuffled. lol

I figured it out… smh…

I have 2 components, one is gmusic and one is gmusic_shuffle. By default the gmusic.py listed in the original post shuffles the songs. I renamed that to gmusic_shuffle and then commented out a line to play track after track in a duplicated gmusic. At the bottom of gmusic.py (now switch.py) I commented out this line.

# random.shuffle(self._tracks)

Now my albums play straight through.

Phew!

Actually i was using your setup before 0.89.0 thanks a lot for the inspiration!

I wanted to just remove the parts I do not need anymore, like the cardList.csv.
So that the logic is only in home assistant and the rasperry pi is only sending the tag to home assistant.

Great Idea! Please post back if you get that working. I’d love to check that out and possibly make the switch as well!

I am just struggeling to understand how I would get the card ID.

I can get some basic ipython3 terminal running and I can listen in a loop to get some card information:

Import librarys and setting up the reader:

import evdev
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in devices:
...    print(device.path, device.name, device.phys)
device = evdev.InputDevice('/dev/input/event0')

Looping until the card will be near the RFID reader:

for event in device.read_loop():
    ...: ...     if event.type == evdev.ecodes.EV_KEY:
    ...: ...         print(evdev.categorize(event))
    ...: ... # pressing 'a' and holding 'space'

Result when card is near the reader:

key event at 1553636173.066585, 11 (KEY_0), down
key event at 1553636173.074576, 11 (KEY_0), up
key event at 1553636173.082591, 11 (KEY_0), down
key event at 1553636173.090593, 11 (KEY_0), up
key event at 1553636173.090593, 2 (KEY_1), down
key event at 1553636173.098581, 2 (KEY_1), up
key event at 1553636173.106586, 2 (KEY_1), down
key event at 1553636173.114597, 2 (KEY_1), up
key event at 1553636173.114597, 4 (KEY_3), down
key event at 1553636173.122592, 4 (KEY_3), up
key event at 1553636173.122592, 5 (KEY_4), down
key event at 1553636173.130603, 5 (KEY_4), up
key event at 1553636173.130603, 4 (KEY_3), down
key event at 1553636173.138604, 4 (KEY_3), up
key event at 1553636173.138604, 11 (KEY_0), down
key event at 1553636173.146608, 11 (KEY_0), up
key event at 1553636173.146608, 7 (KEY_6), down
key event at 1553636173.154604, 7 (KEY_6), up
key event at 1553636173.154604, 4 (KEY_3), down
key event at 1553636173.162608, 4 (KEY_3), up
key event at 1553636173.162608, 28 (KEY_ENTER), down
key event at 1553636173.170609, 28 (KEY_ENTER), up

I am not sure how to convert that into the card ID.
I think I still do not understand the code in your repository.

EDIT:

Got it working.
Need to document this the next days!

Ok, it kind of works.

So the problem is, when you crate a voice command to a google assistant you can not play a palylist.
There is no official way of that doing that right now.

You can for sure play an album are some genre music, but not a playlist:
https://support.google.com/googlehome/answer/7211943?hl=en

That means this could be quite difficult to solve.

Thank you for all useful informations in this thread. Got mine working fine and am compiling all those entities in a simpler card (see screenshot below). I’m then asking myself if there’s any way to get GMusic song metadatas as I got it working with radio streams, any idea?

1 Like