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

:thinking: That should not be the case. Gmusicproxy is it’s own thing, Can you test that it works stand alone? Are you using @miikkajo addon for gmusicproxy? There are other people using this as well. I am not aware of any breaking changes between miikkajo addon and this gmusic player.

getting the gmusicproxy to work outside gmusic player is a seperate thing. Solving that is needed to fix song advance but I don’t think gmusicproxy will solve the playlist issue.

Well that seems like there are no songs in the playlist…

Can you go to the Google music web page and make a new playlist with exactly 3 songs and then restart Home Assistant – Does the new playlist show up – Can you play any of the songs in the new playlist?

I see there are other things I must do to activate/authorise gmusicproxy, in terms of Playlist I created a new one with three songs, still get same errors, I might have to reinstall everything it seems

Im sorry your having problems with this. I hope a reinstalling gets it sorted. I haven’t given up on this project but I also have not had the time to put toward properly learning python. This really needs to be re-written from the ground up by someone who actually knows what they are doing! :laughing:

Thank you for your efforts. I managed to install and oauth the gmusicproxy and I can see it on the ui, however I am still unsure of the ip to use

Sorted gmusic proxy, will fight the Playlist issue another time.

Update Available in HACS

I’ve pushed a small update for gmusic_player.

Updating From a Previous Version


Changes to gmusic_config.yaml

  • speakers are now configured under the gmusic_player platform settings

You’ll need to (re)configure your speakers ( and gmusicproxy, if applicable )


Changes to gmusic_player.yaml

  • added two scripts that will fire events to gmusic_player

gmusic_player.yaml should be used as it is provided. There is no need to edit this file.

script.gmusic_sync_media

  • Update playlist and stations without restarting Home Assistant
    image

script.gmusic_play_media

  • Easier way to start play black. You can use this in automations
  • This will also set the corresponding input_selects

Example using the new scripts to create shortcut buttons in mini-media player

image

entity: media_player.gmusic_player
type: 'custom:mini-media-player'
artwork: cover
source: icon
volume_stateless: true
shortcuts:
  columns: 3
  buttons:
    - name: Feeling Lucky
      id: script.gmusic_play_media
      type: script
      data:
        name: I'm Feeling Lucky
        source: station
        speakers: bedroom_stereo
    - name: Tool Playlist
      id: script.gmusic_play_media
      type: script
      data:
        name: Tool
        source: playlist
        speakers: bedroom_stereo
    - name: Shinedown Radio
      id: script.gmusic_play_media
      type: script
      data:
        name: Shinedown
        source: station
        speakers: bedroom_stereo
    - name: Sync Music
      icon: 'mdi:sync'
      id: script.gmusic_sync_media
      type: script
1 Like

Hi,

Just updated to 0.2 and there’s an error referring to gmusic_authtoken:

FileNotFoundError: [Errno 2] No such file or directory: '/root/.homeassistant/.gmusic_authtoken'

The issue is that DEFAULT_TOKEN_PATH = get_default_config_dir() + '/.' in media_player.py doesn’t get the correct path on my install (formerly known :slight_smile: as Hassio) so I changed it to DEFAULT_TOKEN_PATH ='/config/.'

Hi @Petrica
Sorry about that. There doesn’t seem to be a good way I can get the actually configuration directory. ( At least I haven’t figured it out yet. ) There is an optional setting though :slightly_smiling_face:

You can change the path by setting token_path in the gmusic_config.yaml package file.

Example

## Google Music Media Player
## gmusic_config.yaml

media_player:
  - platform: gmusic_player
    device_id: !secret gmusic_device_id
    username: !secret gmusic_username
    password: !secret gmusic_password
    speakers: # media_players
      - bedroom_stereo
      - workshop_stereo
    gmusicproxy: !secret gmusic_proxy
    token_path: /config/.

:man_facepalming: haven’t got to that section of the instructions as the previous version just worked without it.

Thanks!

1 Like

The previous versions used DEFAULT_TOKEN_PATH = "./."

I’m surprised to hear that actually worked :rofl:

It did seem to work in the FreeNAS plugin as well - I’m just gonna revert that change.
I reverted this change in v0.2.1 It should work again without setting token_path

Thanks for letting me know about this!

Hi There,

The media player seems to be broken, I reinstalled the player to no avail, it gives me the screen below:

my config is as follows:

## Google Music Media Player
## Use this 'package.yaml' file to configure "gmusic_player"
media_player:
  - platform: gmusic_player
    username: !secret gmusic_username
    password: !secret gmusic_password
    device_id: !secret gmusic_device_id
    gmusicproxy: http://192.168.68.134:9999

input_select:
  gmusic_player_speakers:
    name: Speakers
    icon: mdi:speaker
    ## Add your media_players below
    options: # Example media_players
    - mainbedroom_tv
    - mainbedroom_speaker

and the player is as follows:

## Google Music Media Player
## Supplemental 'package.yaml' file for "gmusic_player"
input_select:
  gmusic_player_source:
    name: Source
    icon: mdi:library-music
    options:
    - "Playlist"
    - "Station"

  gmusic_player_speakers:
    name: Speakers
    icon: mdi:speaker
    options:  ## Should be empty
    - " "

  gmusic_player_playlist:
    name: Playlist
    icon: mdi:playlist-music
    options: ## Should be empty
    - " "

  gmusic_player_station:
    name: Station
    icon: mdi:playlist-music
    options:  ## Should be empty
    - " "


script:
  gmusic_sync_media:
    alias: gmusic_player.sync_media
    description: 'Update song list from Google Music'
    sequence:
      - event: gmusic_player.sync_media

  gmusic_play_media:
    alias: gmusic_player.play_media
    description: 'Fire event: gmusic_play_media'
    fields:
      speakers:
        description: Name of the speakers to play music on.
        example: bedroom_stereo
      source:
        description: Media Source. Should be 'station' or 'playlist'
        example: station
      name:
        description: Name of the station or playlist.
        example: I'm Feeling Lucky
    sequence:
      - event: gmusic_player.play_media
        event_data_template:
          speakers: "{{ speakers }}"
          source: "{{ source }}"
          name: "{{ name }}"
          shuffle: " {{ shuffle }}"
          shuffle_mode: " {{ shuffle_mode }}"


## Sensor used for auto track advance.
sensor:
  - platform: template
    sensors:
      gmusic_receiver:
        value_template: "{{ states.media_player.gmusic_player.attributes._player_state }}"


automation old:
  - alias: "gmusic_player_auto_advance"
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: 'sensor.gmusic_receiver'
      from: 'playing'
      to: 'idle'
      for:
        seconds: 1
    condition:
      - condition: state
        entity_id: 'media_player.gmusic_player'
        state: 'playing'
    action:
      - service: media_player.media_next_track
        entity_id: 'media_player.gmusic_player'

  - alias: "gmusic_player_auto_play"
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: 'media_player.gmusic_player'
      from: 'off'
      to: 'idle'
    action:
      - service: media_player.media_play
        entity_id: 'media_player.gmusic_player'


homeassistant:
  customize:
    media_player.gmusic_player:
      friendly_name: "Google Music Player"

    sensor.gmusic_receiver:
      friendly_name: "Google Music Receiver"
      hidden: true

    script.gmusic_sync_media:
      friendly_name: "Sync Music"
      icon: mdi:sync
      
    script.gmusic_play_media:
      hidden: true
      
## This group may only be visable when using the "states UI"
group:
  google_music_media_player:
    name: Google Music
    entities:
    - media_player.gmusic_player
    - script.gmusic_sync_media
    - input_select.gmusic_player_speakers
    - input_select.gmusic_player_source
    - input_select.gmusic_player_playlist
    - input_select.gmusic_player_station

I have not changed the files in the custom_components, what could be the problem, I’m running 105.5 and HassOS 3.11. I need help… :flushed: :flushed: :flushed: :flushed:

Ok, just saw the notes on the update, I will have to re-do everything…

You shouldn’t have to redo everything. Just copy the new config files into place. The biggest change is that speakers are configured under g music player instead of as an input select. Then just add your g music proxy back in to the new config and you should be good to go

Hi,

I am already redoing it, I’ve deleted everything now, I am thinking maybe I am doing something wrong by tinkering here and there. I’ll Feedback in ten minutes :slight_smile:

Regards,
CN

Hi, I have no luck at all, music player does not even appear in entities…:frowning:

This custom component works really well for me, thanks @troy :slight_smile:
Is it possible to use friendly names for the speakers?

1 Like

I’ve tried a few times to do this. I haven’t had any luck getting it to work but I’m sure it’s possible.

I’ll have another go it but I can’t make any promises.

Thanks for everything you’ve done on this and how responsive you’ve been to everyone! I appreciate it and I’m sure everyone else does too.

Is it possible to view automatic playlists like my Thumbs Up one?

1 Like

So for automatic – I don’t know about playlist but it is possible for stations. It’s just that its all or nothing. So for example right now I filter the stations to only include what’s in you library – Without that filter the list of stations is over 200 long. I don’t have a better to allow some automatic stations but not others.

But for thumbs up playlist I think I could add this – Assuming I can filter the same way I do for the stations, I can just look for songs with a thumbs up and only add those songs to a dedicated “Thumbs Up” playlist.

I’ll have a look and see what I can do.

Is there a possibility that you’re willing to share your theme (including the background) and the code to implement it. I like it very much. (I’m only a beginner, that’s why I ask for the code too)