armdan
(armdan)
March 8, 2018, 12:24am
1
#-------------------------------------------
# Music from youtube playlist sent to Google Chromecast Audio
#
#-------------------------------------------
homeassistant:
customize:
input_boolean.music:
friendly_name: 'Music'
icon: mdi:music
hidden: False
#-------------------------------------------
input_boolean:
music:
name: Music
initial: off
#-------------------------------------------
automation:
- alias: 'Turn on Music'
trigger:
- platform: state
entity_id: input_boolean.music
to: 'on'
action:
# - service: media_player.turn_on
# entity_id: media_player.chrome1
- service: media_extractor.play_media
data_template:
entity_id: media_player.chrome1
media_content_id: "https://play_List_URL"
media_content_type: "video/mp4"
- alias: 'Turn off Music'
trigger:
- platform: state
entity_id:
- input_boolean.music
to: 'off'
action:
- service: media_extractor.media_stop
entity_id: media_player.chrome1
- service: media_player.turn_on
entity_id: media_player.chrome1
I am not a programer , just learing from great examples here on this site .
If it is, I haven’t been able to figure it out either. I ended up implementing the radio station that someone posted as a shared project.
The ability to play a random song off a youtube playlist to a chrome cast would super simplify things.
Petrica
(PetricaM)
March 16, 2018, 2:39pm
3
Hi
Are you able to get the playlist URL? Below is an example with a single video sent to CCA but for playlists should work the same way.
test:
sequence:
- service: media_extractor.play_media
entity_id: media_player.home
data_template:
media_content_id: "https://www.youtube.com/watch?v=wzjWIxXBs_s"
media_content_type: "audio/youtube"
1 Like
RobDYI
March 16, 2018, 3:50pm
4
Just in case anyone cares for Alexa, I use this one which works and I haven’t been charged anything.
https://github.com/Fenton-Fenton-Fenton/alexa-tube
armdan
(armdan)
March 16, 2018, 6:24pm
5
this code plays only first video from the playlist. It does take good 5 min for media to start playing some how.
Petrica
(PetricaM)
March 16, 2018, 6:33pm
6
Unfortunately it is a limitation of the Media Extractor platform.
As an alternative you could try sending Google Music playlists to HA (this one works )
or finding really long Youtube videos with Media Extractor.
PS: the time it takes for the Youtube video to start depends on the internet connection.
armdan
(armdan)
March 16, 2018, 6:40pm
7
Thanks but my idea was to go to youtube add some music videos to youtube playlist then play that list using HA automation . Like this
Hey Google , Play my music >>> IFTTT>> HOME ASSISTANT>>media_player.chrome>> all speakers in the house.
One can only wish lol.
Petrica
(PetricaM)
March 16, 2018, 6:58pm
8
armdan:
One can only wish lol.
Not really.
I think that the link I mentioned already does it (you can start either a playlist already saved or a radio based on a playlist in Google Music) so it is only a mater of time someone with the appropriate skills manages to do it with Youtube (if not already done).
armdan
(armdan)
March 17, 2018, 6:37am
9
Thank you very much but your link is great for people who what to setup Google music . I am interested in youtube. I searched all over the net and could not find code for youtube. I do hope somebody with appropriate skills will make one for youtube.
It would be nice to play a livestream or playlist from Youtube. Any progress on this?
slackdance
(Harald Hveem)
June 13, 2019, 2:45pm
11
Also looking for this, have not found a solution!
I imagine the easiest way of doing this would be to automate the Chrome Browser somehow and output your audio to the chromecast
armdan
(armdan)
June 16, 2019, 6:42am
13
I am not a programmer to achieve that.
I am able to play videos this way. Any idea how can I share the link directly from my phone using some kid of sharing service?
Petrica
(PetricaM)
April 15, 2020, 2:21pm
15
I don’t understand why not playing directly from YT Music app on the phone to Chromecast Audio.
Cause I want to play in other devices. Like panel tablets. Moreover I do not own a chromecast device.
Petrica
(PetricaM)
April 15, 2020, 6:45pm
17
My guess initially was that you wanted to send the link to Youtube video from mobile device to HA, but it would have been easier to just use the mobile device to cast to Chromecast devices.
I think that browser mod might be what you are looking for in order to be able to play on the browser running HA on tablet/pc.
Ok… so here’s my first ever custom component
It does what my lovelace plugins lovelace-player and browser-commander used to do, but with backend support.
From the readme:
Make the camera feed from your front door pop up on the tablett in your kitchen when someone rings the doorbell.
Have a message pop up on every screen in the house when it’s bedtime.
Make the browser on your workstation switch to a specific tab when the kitchen light is on after midnight
Play a TTS message on your work c…
Yeah you are right. I am using it and it is working fine.
I would like now to speed up the link sharing between youtube on mobile (for example) to HA so i can easilly call the service which plays youtube audio on the browser mod
Hi.
Is it possible to play a youtube playlist?
Thanks
Mike
1 Like
thor_c
(Thor)
December 18, 2021, 8:21pm
20
I have this worknig with a script, that calls the media_player service like this:
alias: Play on chromecast
sequence:
- service: media_player.play_media
target:
entity_id: media_player.tv_tv
data:
media_content_id: >-
{% set msg
={'app_name':'youtube','media_id':'dQw4w9WgXcQ'}%}{{
msg|to_json }}
media_content_type: cast
mode: single
icon: mdi:youtube
changing the ‘media_id’ to ‘playlist_id’, as mentioned here , would let you play a playlist instead.
also adding:
,'enqueue':'true'
in there would let you enque a video, or a playlist.
i have a short explanation, with examples here .