Automation on Alexa

I created an automation on HA to work with Alexa. To explain what I want to do, I want to tell alexa to put my LG TV (with LG WebOS already integrated on HA) on Netflix app.

So my automation code is:

- id: '1586370818016'
  alias: TV Pedro Netflix
  description: ''
  trigger: []
  condition: []
  - data:
      Source: Netflix
    entity_id: media_player.lgwebostv_pedro
    service: media_player.select_source

If I trigger this automation on HA, it works.

And on Alexa APP, I created a Routine

  • When I say “Alexa, netflix”
  • Action: Smart Home > All devices > and find “TV Pedro Netflix”
    Then save

But when I say “Alex, Netflix”, she answer “OK” and nothing happened.

Does anyone have this problem or know how to solve it?


Make it a script, not an automation since there’s no trigger. You would also want to name it what you want to ask Alexa to do. For Alexa, start Netflix use alias: Netflix

- alias: Netflix
    -  service: media_player.select_source
          source: Netflix
          entity_id: media_player.lgwebostv_pedro

But are the scripts seen by Alexa automatically?

You might have to expose them in your configuration.yaml. Here’s mine.

Found the url:

    client_id: !secret alexa_client_id
    client_secret: !secret alexa_client_secret
        - switch
        - light
        - scene
        - input_boolean
        - script

I have the HA Cloud, and I had to force sync to expose the new script to Alexa.
But on Alexa, it appears like a Scene.
And I still need to create a Routine but now I look fot the scene. And it worked like a charm.
Thanks @popboxgun

Hi, i have some troubles with that, can you insert all the code, i mean, script and config.yaml, please?

Above was my configuration.yaml and an example script. What exactly are you looking for?

Here’s the setup doc for Alexa.

Hi, i mean only script.yaml, sorry about that, because i follow your idea and i have a trouble about the dictionary, like the script don´t recognise my media player. I´ll put the code:

  name: tv_juanjo
    service: wake_on_lan.send_magic_packet
      - youtube
      - spotify
      - netflix

I quit the mac for obvious reason, but i implemented

- alias: Netflix
    -  service: media_player.select_source
          source: Netflix
          entity_id: media_player.tv_juanjo

I have this error

Invalid config for [script]: expected dictionary for dictionary value @ data['script']. Got [OrderedDict([('alias', 'Netflix'), ('sequence', [OrderedDict([('service', 'media_player.select_source'), ('data', OrderedDict([('source', 'Netflix'), ('entity_id', 'media_player.tv_juanjo')]))])])])]. (See /config/configuration.yaml, line 45). 

Your syntax is wrong and you also had extra spaces.

Try this

    - service: media_player.select_source
         source: Netflix
         entity_id: media_player.tv_juanjo

Thank you men, its works without errors, but i have a question, I said to alexa to turn on the tv, and done, but i don´t how to invocate the script in Alexa, i read before the u say Alexa, start Netflix and execute the script, but in my case, it said that i don´t have a skill to deploy that invocation, can you tell me how to invocate?

I am not familiar with the webostv, it looks like it uses WOL to power on so you probably need your MAC back in there.

So you can try creating a switch for the WOL.

Then add the following in your script, you probably want a delay for the TV to power on before trying to switch source.

    - service: homeassistant.turn_on
        entity_id: switch.tv_switch
    - delay: 00:00:05
    - service: media_player.select_source
         source: Netflix
         entity_id: media_player.tv_juanjo

Or check your services until developer tools -> services and see if there’s a service to turn it on with the integration.

Sorry for have done incorrectly the question, i mean, the process of turn on the tv actually works, but the next step will be invocate the script(i guess), so, how i should say to alexa to execute the script that we develop? Because when i said Alexa, start or turn on netflix, doesn´t work Alexa, it said that i don´t have a skill to do that invocation. Are you understand what i mean?

Whatever you name the script (in my example netflix) is what you would use.

For mine, I say “Alexa turn on Netflix”.

You do have to add scripts to include_domain as mentioned above then refresh your Echos so they see the new skill. There’s a time period before Amazon searched for new skills, but there’s also something you can say that will have it refresh and look for new smart devices, but I can’t remember what it is.

okey, this was what i mean before, thank you very much for your help