LG webOS Smart TV play YouTube video by URL doesn't work

Hello guys,
I connected Lg TV to home assistant.
I can turn on/off, change source to YouTube for example, control the sound, but can’t put exact video by url.
I’m trying to do it using script:

fish:
  alias: Aquarium
  sequence:
  - service: media_extractor.play_media
    data:
      entity_id: media_player.tv_715
      media_content_type: video/mp4
      media_content_id: https://www.youtube.com/watch?v=7Y7QaIQET0E&t=37s

Also tried:

fish:
  alias: Aquarium
  sequence:
  - service: media_extractor.play_media
    entity_id: media_player.tv_715
    data:
      media_content_type: video/mp4
      media_content_id: https://www.youtube.com/watch?v=7Y7QaIQET0E&t=37s

And of course tested such media_content_type: video, video/youtube, audio/youtube

It doesn’t work; Logs show that script is called, but nothing.

I’m trying to call service media_extractor.play_media with this:

{
  "entity_id": "media_player.tv_715",
"media_content_type": "video/mp4", 
"media_content_id": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
}

Also tested with different media_content_type.
It doesn’t work.

No errors in any case. Just that everything is called fine, but in result no video is played on the TV.
Could not find solution on forums.

Did you solve this?

I’m also trying to get this to work. Anyone got a solution?

1 Like

I would also be interested if someone find a solution / develpment

1 Like

anyone found a solution / development for this? I am interesting too

1 Like

I’m having better luck controlling the LG with the Node Red nodes for it than i did with Home Assistant directly. I haven’t tried Youtube, but I never could get the browser to show a URL in HA directly but it worked easily in Node Red.

Which NodeRed integration are you using?

They look like forks of each other so which is best is a good question, but I am using node-red-contrib-lgtv 1.1.0.

They are relatively unsophisticated in node-red items, for example as best I can tell you cannot choose the TV with a payload, so you have to hard code a separate node for each action for each TV, though you can feed in a URL for the web browser. For youtube it wants the video id.

But for web browsing it works fine.

Looking for this as well anyone have anything on this?

I’m trying wto get the desired outcome via the PY code developer otions https://github.com/TheRealLink/pylgtv

it mentions soething like :
Allow launch Youtube App with startup params of video id.

lgtv/endpoints.py


but I’m not able to launch Youtube with specidif URL as paramenter

any suggestion or sucess ?

Responded to a similar question elsewhere, but replying here as well since it maybe relevant.

service: webostv.command
data:
  entity_id: media_player.jtv
  command: "system.launcher/launch"
  payload:
    id: "youtube.leanback.v4"
    contentId: "dQw4w9WgXcQ"

The commit that’s necessary to do this was just merged a few days ago by @PotatoDrug. I was able to confirm it works by using homeassistant/home-assistant:0.111.0.dev20200530

2 Likes

Ohhh I fell for it :joy:
But thanks, this yaml is what I needed!

1 Like

It’s not working for me. It opens the YouTube app, but it doesn’t start playing the requested video.
Is there anything else I need to do?

I see this error message in the logs:

2020-09-24 09:02:30 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140271226917600] extra keys not allowed @ data['contentId']
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 137, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1269, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['contentId']
1 Like

well this worked for me. just i do still have to press play this video. maybe try a diferent youtube link?

Hi,

Very new user here, apologies for any confusion/frustration caused, im on a very steep learning curve:

i also can not get this to work, i can only get my TV to open the youtube app, on a OLED55CX6LA running 03.21.18 - youtube app version web_20210411_10_RC00.

i have tried this code and all the code on:

but all i can get is the TV app to open

please help??
thanks

for me this working:


service: webostv.command
data:
  command: system.launcher/launch
  payload:
    id: youtube.leanback.v4
    contentId: https://www.youtube.com/watch?v=6fHASeSrH8w
  entity_id: media_player.tv

but it opens in small window on tv… like this:

Is anyone familiar with this issue?

Hey. For anyone seeing this, I got it working with modifying the contentId: from “url” to “v=6fHASeSrH8w” auto play and all.

service: webostv.command
data:
  command: system.launcher/launch
  payload:
    id: youtube.leanback.v4
    contentId: v=6fHASeSrH8w
  entity_id: media_player.tv
3 Likes

Works perfect! Thanks!

Confirming changing msg.payload to include ‘v=’ before the video id also works for the node-red-contrib-lgtv Youtube node.

[{"id":"891ef7dc6c406244","type":"inject","z":"2d7e99c6.357436","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":920,"y":1120,"wires":[["2637fb5c992fa137"]]},{"id":"2637fb5c992fa137","type":"change","z":"2d7e99c6.357436","name":"RickRoll","rules":[{"t":"set","p":"payload","pt":"msg","to":"v=dQw4w9WgXcQ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":1120,"wires":[["1f811536274f76fe"]]},{"id":"1f811536274f76fe","type":"lgtv-youtube","z":"2d7e99c6.357436","tv":"b6e780cfd7a33784","name":"","x":1240,"y":1120,"wires":[]},{"id":"b6e780cfd7a33784","type":"lgtv-config","host":"192.168.0.XXX"}]