As the title says, thanks to a couple of guys from the community (jaruba, Screwdgeh), it’s possible to declare a rest_command to achieve that. The TV always asks for a confirmation which you can hit with jaruba’s send_key command or maybe with a Broadlink.
Payload needs to be the identification number of any youtube video at the end of the url, just the “v=” section with its number
rest_command:
video_youtube_rest:
url: 'http://yoursamsungtvlocalip:8080/ws/apps/YouTube'
method: POST
content_type: 'text/plain'
payload: 'v=RsZDdNDiq7Y'
example script
test_youtube:
alias: test yotube
sequence:
- service: rest_command.video_youtube_rest
- delay: 00:00:01
- service: media_player.play_media
data:
entity_id: media_player.your_samsung_tv
media_content_type: send_key
media_content_id: KEY_ENTER
4 Likes
nickrout
(Nick Rout)
December 26, 2020, 9:13am
2
Wonderful, if you want the same video over and over!
I think nick was more talking about the fact that you need to setup a separate rest command for each youtube video you want to watch,its not dynamic.
1 Like
oh yeah, that’s the best for the moment. It’s better than nothing I guess
gonzotek
(Gonzotek)
December 26, 2020, 10:53pm
6
I don’t think there’s any reason you can’t have payload be a template.
Untested(don’t have this kind of tv), but something like:
rest_command:
video_youtube_rest:
url: 'http://yoursamsungtvlocalip:8080/ws/apps/YouTube'
method: POST
content_type: 'text/plain'
payload: 'v={{ video_id }}'
Then call it as a service via automation, script, or compatible lovelace card:
automation:
- alias: 'Tiny Kittens'
trigger:
...
action:
- service: rest_command.video_youtube_rest
data:
video_id: "RsZDdNDiq7Y"
1 Like
nickrout
(Nick Rout)
December 26, 2020, 10:57pm
7
you could probably incorporate a text input where you could type or paste the video id.
1 Like
nickrout
(Nick Rout)
December 27, 2020, 1:30am
8
Then again, it seems far easier to find the YT video on your phone, then share/cast it to your TV.
gonzotek
(Gonzotek)
December 27, 2020, 1:31am
9
If we wanted to get really clever, we’d regex the v_id, so one could paste just id, or any of the bunch of ‘standard’ youtube urls out there (shortened, playlists, etc.).
It’s usefull if you want to play a youtube video as part of a scene with lights and so on…
2 Likes
nickrout
(Nick Rout)
December 27, 2020, 8:06pm
11
At one stage you could actually buy fireplace and aquarium VHS tapes
1 Like
guys, is this command for pre-tizen models? i have a tv from 2015 i think , H model
thnx in advance
tried it, with code below
rest_command:
video_youtube_fish:
url: 'http://192.168.0.62:8080/ws/apps/YouTube'
method: POST
content_type: 'text/plain'
payload: 'v=7Y7QaIQET0E'
fish:
alias: Aquarium
- service: rest_command.video_youtube_fish
- delay: 00:00:01
- service: media_player.play_media
data:
entity_id: media_player.ue55h6400
media_content_type: send_key
media_content_id: KEY_ENTER
But i receive:
2021-11-10 19:49:36 ERROR (MainThread) [homeassistant.components.samsungtv] Unsupported media type
any idea?
I was using same script as thread starter? It worked for him? What should I use then?
nickrout
(Nick Rout)
November 10, 2021, 9:28pm
16
Read the first post then, you seem to need something called yaruba’s sendkey command, but there is no pointer to what on earth that is.
That send key, is just an enter / ok button command, the error on my tv is already there from the rest command, so it’s already wrong there…
skorpa
November 28, 2021, 11:41am
18
Hi guys, I was trying this script to launch on my Samung TV with Tizen the YouTube video from HomeAssistant.
All the commands are working except the launching of the video
I’m able to launch YouTube app on my TV from HomeAssistant (by sending empty POST to HTTP://myip:8080/ws/apps/YouTube/ )
I’m able to send ENTER key (or any other available key) and TV reacts correctly.
But when I send “v” parameter in body of POST request with ID of some YT video, nothing happens.
Do you have some advice or idea for me? I would be really grateful! Thanks
Same here , on pre-tizen model…
I get “something went wrong” , see some posts above
skorpa
November 28, 2021, 11:59am
20
In my case when I launch the script from the first message, Youtube app launch on my TV and the ENTER key is sent (so the first video I see in Youtube app is launched, because ENTER key launch it).
I tried to remove sending the ENTER key and in this case just Youtube app is launched and that’s it. “v” parameter is ignored and no video is played and I don’t see any message on my TV to approve something or some error.