Youtube Music - Media Browser

FYI: Kodi is working now as well … maybe another option for you @Pirol62
JKW

1 Like

Sorry, but all my music at the moment on the youtube music site was imported from my old google music account, and it’s all in mp3

If its all in mp3 I might suggest you put them into the /media folder on HA you will get built in support for playing music on many more devices.

Yes I already have the files on the NUC, but I wanted to help and if you could do something similar to GMusic! So if I have to do some tests should I download public videos or mp3s?..
…Ok I tried to create a public playlist, with only 1 song and on my google home it works both individually and in pairs!

So the new release will Auto load all Mediaplayer into the list when the configuration of speakers isn’t given.

If one mediaplayer is given then the list is still loaded but the given Mediaplayer will be preselected.

If two or more player are given only those will be shown.
Jkw

1 Like

hi
is there any way to initiate playing specific album or track in youtube music on goolge home devices from home assistnt?

Yes, create a playlist and use this component.

other ways like searching for an album of a song aren’t currently implemented and would certainly blow the scope of THIS component. But it is possible with the api.

Jkw

Hey
that’s awesome!! Just followed your guide and installed it and it is working! Woohoo!
Thanks so much!

I was wondering how can i automate this? Ie i want to play specific playlist on a specific device when a motion triggers. What shall i pass into automation action for this to work?
Looked through docs and here and didnt find anything related.

Btw is there a way to play different music on different devices and what is playlist radio??

I had some Automations in place for the gmusic player, something in appdaemon like
self.set_state(“input_select.gmusic_player_source”,state=“Station”)
Followed by the turn_on of the media player. That should work here as well, same mechanics. Post your results here and I’ll copy that in the docu

Multiple player … Hmm … Try! I could imagine that it works, but didn’t test.

Playlist radio: pick one random song of the choose playlist and start a radio based on that song

Jkw

I have managed to install and configure this. The component loads my playlists, etc. However, I am finding that most of the songs don’t play. All of them error with the “Failed to get URL for track” exception.

I don’t believe these are songs I uploaded. I searched and added random songs to the playlists but no luck.

Some example tracks:

  • Hx4nWW9z0ig
  • 1LPNuFkteI8

This one works

  • -ldeCgy2ado

Edit: I want to add that even the song that works throws the exception but plays correctly. I am really confused now.

Edit: I think the one that works falls back to the Youtube stack and picks a url.

@r4nd0mbr1ck strang because Hx4nWW9z0ig worked fine for me.

Are you a youtube premium subscriber? I wonder if there is something weird with your cookie.

Can you paste some more of the error logs.

Yeah worked!
In case anyone else needs similar, here is nodered automation that turns on youtube music playlist on specific google home device after input boolean set to on:

[{"id":"b996d556.efe6b8","type":"ha-api","z":"cbaf2713.743e38","name":"Playlist","server":"532aa922.484e68","debugenabled":false,"protocol":"http","method":"post","path":"states/input_select.ytube_music_player_playlist","data":"{\"state\":\"Tranquil Spa Day\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":620,"y":860,"wires":[["53a92c65.c659c4"]]},{"id":"d8b2c8ea.d68e78","type":"api-call-service","z":"cbaf2713.743e38","name":"Play","server":"532aa922.484e68","version":1,"debugenabled":false,"service_domain":"media_player","service":"media_play","entityId":"media_player.ytube_music_player_speakers","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1090,"y":940,"wires":[[]]},{"id":"53a92c65.c659c4","type":"ha-api","z":"cbaf2713.743e38","name":"Playmode - Random","server":"532aa922.484e68","debugenabled":false,"protocol":"http","method":"post","path":"states/input_select.ytube_music_player_playmode","data":"{\"state\":\"Random\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":840,"y":860,"wires":[["f97860e4.ce0b8"]]},{"id":"f97860e4.ce0b8","type":"ha-api","z":"cbaf2713.743e38","name":"Source - Playlist","server":"532aa922.484e68","debugenabled":false,"protocol":"http","method":"post","path":"states/input_select.ytube_music_player_source","data":"{\"state\":\"Playlist\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":640,"y":940,"wires":[["e943a087.3c2f"]]},{"id":"e943a087.3c2f","type":"ha-api","z":"cbaf2713.743e38","name":"Speaker - bedroom_speaker","server":"532aa922.484e68","debugenabled":false,"protocol":"http","method":"post","path":"states/input_select.ytube_music_player_speakers","data":"{\"state\":\"bedroom_speaker\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":880,"y":940,"wires":[["d8b2c8ea.d68e78"]]},{"id":"e194d5e3.7ca668","type":"api-current-state","z":"cbaf2713.743e38","name":"Is paused","server":"532aa922.484e68","version":1,"outputs":2,"halt_if":"paused|idle","halt_if_type":"re","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.bedroom_speaker","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":440,"y":800,"wires":[["427c0296.146b3c"],["b996d556.efe6b8"]]},{"id":"427c0296.146b3c","type":"api-call-service","z":"cbaf2713.743e38","name":"Resume speaker","server":"532aa922.484e68","version":1,"debugenabled":false,"service_domain":"media_player","service":"media_play","entityId":"media_player.bedroom_speaker","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":800,"wires":[[]]},{"id":"e929dd65.09047","type":"server-state-changed","z":"cbaf2713.743e38","name":"Bedroom Routine Started","server":"532aa922.484e68","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.bedtime_routine","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":110,"y":820,"wires":[["9ccf68f.c79ab98"]]},{"id":"9ccf68f.c79ab98","type":"switch","z":"cbaf2713.743e38","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":820,"wires":[["e194d5e3.7ca668"],["30e8ed0e.ab8482"]]},{"id":"30e8ed0e.ab8482","type":"api-call-service","z":"cbaf2713.743e38","name":"Pause speaker","server":"532aa922.484e68","version":1,"debugenabled":false,"service_domain":"media_player","service":"media_pause","entityId":"media_player.bedroom_speaker","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":440,"y":1000,"wires":[[]]},{"id":"532aa922.484e68","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

:dancing_women: :dancing_men:

Hi guys, I got it to play after struggling a bit with the token, I am now trying to incorporate it is my aitomations but not winning, gmusic player had a script in the yaml and that was used to trigger the automation. With ytube_music_player, I tried:

  - service: media_player.turn_on
    entity_id: media_player.ytube_music_player
    data:
      speakers: mainbedroom_speaker
      source: playlist
      name: Good Morning Coronas 

when I trigger the automation, it does not turn the media player on.

please assist :blush:

Hi @alexbell, thanks for the advise, where do you put this code, and where do you get the parameters for each variable :blush: I already have the trigger set up.

hi @Caswell1000 i use this automation in Nodered: Home Assistant Community Add-on: Node-RED

In nodered just click hamburger icon at top-right cornet and then Import, there you can copy paste this code (please update the playlist and speaker nodes accordingly).

Also i jut updated the code in original post a little.

You need a sequence … first input.select speaker, second input.select the playlist third, input.select source, forth: Mediaplayer turn on
Jkw

alias: Start_radio
sequence:
  - service: input_select.select_option
    data:
      option: Your Likes
    entity_id: input_select.ytube_music_player_playlist
  - service: input_select.select_option
    data:
      option: jkw_cast2
    entity_id: input_select.ytube_music_player_speakers
  - service: input_select.select_option
    data:
      option: Playlist Radio
    entity_id: input_select.ytube_music_player_source
  - service: media_player.turn_on
    data: {}
    entity_id: media_player.ytube_music_player
mode: single

actually something that you can very comfortably click together in the GUI (never used before but works really great)

HA! post withdrawn See above…

Although yours looked nicer :wink: but I’m not sure if that would still work … Will try later

Maybe you can add it back, if it doesn’t work. I think I can at least point out in the previous mess of code, how that worked.

Thanks, I have not used a sequence before, so I am not sure where to put it, I am busy reading up though :roll_eyes: