Alexa media_player.play_media to run routines

I have been told that you can use the play_media command to run an Alexa routine, but I can’t get it to work.

I have a routine called “Set lights for cooking”. When I say “Alexa, set lights for cooking” a dozen lights change. I want to do this with Home Assistant. Some of the light switches are not supported by Home Assistant, so I’m trying to get Alexa to do it. If I run the automation manually in HA, Alexa responds, but not correctly. Here is the HA Automation:

  • id: ‘1631463603596’
    alias: Set lights for cooking
    description: ‘’
    trigger:
    • type: opened
      platform: device
      device_id: e6c1eafc991f6541636fe436160c795c
      entity_id: binary_sensor.shelly_shdw_2_e8db84d3d0c4_door_window
      domain: binary_sensor
      condition: []
      action:
    • service: media_player.play_media
      target:
      device_id: 4913de717a9eaf24e90cf79fd768378c
      data:
      media_content_id: Alexa, Set lights for cooking
      media_content_type: custom
      mode: single

In the Automation, I’m trying to use a Shelly Door/Window sensor, but that is not important. If I run it manually, I get the same result. The device_id is for an Echo Flex, but I tried different Echo devices.

In my cell phone Alexa App under → Activity → Voice History I see the following:

This is the same message that Alexa gives me if I make a mistake on the command. For example, if I make a mistake and add the word kitchen and say Set kitchen lights for cooking, it replies You have Smart Life enabled…

I think I am close to correct, or what I am trying to do is impossible.

Any help would be appreciated. I searched through the posts but could not find the answer, although I suspect this question has been answered.

Cheers

Hello,

I posted this question on the Facebook group, and I received a response that fixed the problem.

  1. Remove the word Alexa in the media_content_id:
  2. Change the word custom to routine in the media_content_type:
  3. I changed the automation from a device_id: to an entity_id: kitchen_echo_flex to see if that would make a difference. It worked with both the device_id method and the entity_id method.

Many thanks to Drew Johnson for replying to my Facebook message.