Trying to play video from Youtube as part of an automation and i'm lost

hi all,

as the title suggests, i’m trying to create an automation to play a youtube video on my tv.

ive added

media_extractor:

to my configuration.yaml, i did look at setting it to play only the best video/audio then noticed that’s set by default.

in my automation I have

- id: '1544197797055'
  alias: testing playing youtube video on lounge tv
  trigger:
  - at: '21:30'
    platform: time
  action:
  - service: media_extractor.play_media
    entity_id: media_player.tv
    data:
      media_content_id: "https://www.youtube.com/watch?v=bmGsQkLb4yg"
      media_content_type: video/youtube

but nothing happens… i do get the following error

Log Details (ERROR)
Tue Jan 08 2019 20:26:53 GMT+0000 (Greenwich Mean Time)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/automation/__init__.py", line 294, in async_trigger
    await self._async_action(self.entity_id, variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/automation/__init__.py", line 378, in action
    await script_obj.async_run(variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 130, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 172, in _handle_action
    action, variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 261, in _async_call_service
    context=context
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 81, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1098, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: (ServiceNotFound(...), 'Service media_extractor.play_media not found')

any help?

EDIT:

the end aim is to have a video played on the tv when ever i ask alexa to play music.

The docs say media content type

The type of the content to play. Must be one of MUSIC, TVSHOW, VIDEO, EPISODE, CHANNEL or PLAYLIST MUSIC.

i tried that at first and it didn’t work… so then found several other threads on here that said they used “video/youtube” though as you can see that’s not working for me.

this is working for me :

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

I’ve tried to copy and paste your code above (editing the player ID) and I get the same error

Service media_extractor.play_media not found

that’s the same error i got for all my attempts so i’m guessing i’m missing something stupid somewhere… i just can’t find it

strange, that code is working perfecty for me, just tried it again

ow, btw, i also have this in my config/yaml file, probably thats your issue

media_extractor:

yeah, everything i can find says that’s the issue… put media_extractor: into the config.yaml but i have it in there, that was the first thing i done before trying to make it work…

EDIT:

felt a bit paranoid that i was being really stupid and had a capital letter or spelling error but nope…

then i dont know :frowning:

no worries… thank you for trying, i greatly appreciate it :smile:

maybe your tv just cant handle it? i think its used for casting to a chromecast in my case

just to be 100% i copied and pasted the ‘media_extractor:’ from your post and put it into my config.yaml, after a restart and a test everything works , except your video it just doesn’t play.

but thank you for your help. sometimes i spend too much time on the problem and miss the easy solution.

is your tv equiped with a cast function? i use chromecast, it works on that device

yeah its a sony bravia smart tv with built in chrome cast, when it was found by HA it was just named TV so i stuck with that.

now to work out how to call a scrpit into an automation lol

easy, like this :

  action:
    service: script.volume_down_zone3
2 Likes

you’re a true Gent

thank you

just a thought, do you know if the video can be looped?

Don’t know, I always use screensavers :wink:
Maybe link to a playlist? Instead of a video?

How does that work? Not something I’ve thought of before… I’ll look into what options there are for that…

Any chance of sharing the code?

have not tried it , was just an idea :slight_smile: