Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom Alexa command #2630

Open
mikeaumiller opened this issue Oct 16, 2024 · 4 comments
Open

custom Alexa command #2630

mikeaumiller opened this issue Oct 16, 2024 · 4 comments

Comments

@mikeaumiller
Copy link

NOTE: For a feature to be created it has to be doable in the Amazon app because we are basically replicating the app for HA. If you can't find it in the app, we probably can't create it here.

Is your feature request related to a problem? Please describe.
Possibly? Send a custom Alexa command that has the value of a sensor

Describe the solution you'd like
Within the media_content_id field I would like to use the value of a sensor as part of the command within media_player.play_media Action. Before sending the command the sensor value would be translated.

Describe alternatives you've considered
None

Additional context
Example: Alexa, move music to <sensor.room_name> echo’
would result in sending: Alexa, move music to family room echo

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Oct 20, 2024

I just tried this and it worked fine:

action: media_player.play_media
data: 
  media_content_type: custom
  media_content_id: "move music to {{ state_attr('sensor.last_alexa', 'actual_friendly_name') }}"
target:
  entity_id: media_player.kitchen_echo_dot

My sensor.last_alexa is currently derived from node-red-contrib-alexa-remote2-applestrudel that I'm playing with but you should be able to template your <sensor.room_name> as needed.

image

@mikeaumiller
Copy link
Author

mikeaumiller commented Oct 20, 2024

I haven’t tried using the friendly name from last_alexa. What’s interesting, is in Developer Tools or manually it translates fine, but not in an automation — When enabled my Alexa errors and says that it doesn’t recognize an echo with that name to move music to.

Automation example shown below:

The automation checks to see if the office echo is playing. Then based on the current room location of my phone which it gets from — sensor.galaxy_s24_ultra_ble (via ESPresence BLE tracker), it completes ‘move music to’ sentence.

The purpose of the script is to have music follow me from room to room.


alias: Auto Music
description: Music follows from room to room
triggers:
  - trigger: state
    entity_id:
      - input_select.room_select
    to: Auto
conditions:
  - condition: template
    value_template: {{ state_translated(‘media_player.office_echo’) == ‘Playing’ }}
actions:
  - action: media_player.play_media
    metadata: {}
    data:
      media_content_type: custom
      media_content_id: move music to {{ states('sensor.galaxy_s24_ultra_ble') }} echo
mode: single

@danielbrunt57
Copy link
Collaborator

Your automation action is missing a target entity_id:

  - action: media_player.play_media
    metadata: {}
    data:
      media_content_type: custom
      media_content_id: move music to {{ states('sensor.galaxy_s24_ultra_ble') }} echo

image

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Oct 20, 2024

Another issue, your quotes are wrong:

{{ state_translated(‘media_player.office_echo’) == ‘Playing’ }}
should be:
{{ state_translated('media_player.office_echo') == 'Playing' }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants