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

Something went wrong: Action script.play_music not found #50

Open
richi1805 opened this issue Sep 11, 2024 · 2 comments
Open

Something went wrong: Action script.play_music not found #50

richi1805 opened this issue Sep 11, 2024 · 2 comments

Comments

@richi1805
Copy link

richi1805 commented Sep 11, 2024

Hi,

when I'm trying to play music I get this error message.

grafik

I'm using the promt, the specs and the play_music script from this repo. I allready double checked the entity ID from the sript and exposed the script to assist. Still the same result.

grafik

grafik

What am I doing wrong?

@debdalerichard
Copy link

Hi, I think a lot of things have changed since the normal function.
here is a copy of mine also make sure you change the entity id (music player id) in this function to match yours...i hope it helps?

  • spec:
    name: search_music
    description: >
    Searches for music.
    parameters:
    type: object
    properties:
    query:
    type: string
    description: search query
    media_type:
    type: array
    optional: true
    items:
    type: string
    enum: ["artist", "album", "playlist", "track", "radio"]
    description: Types of media to search
    artist:
    type: string
    optional: true
    description: Specify this when you search from a specific artist
    album:
    type: string
    optional: true
    description: Specify this when you search from a specific album
    required:
    - query
    function:
    type: script
    sequence:
    • service: mass.search
      data: >
      {
      "name": "{{ query }}",
      {% if media_type is defined and media_type %}
      "media_type": {{ media_type | tojson }},
      {% else %}
      "media_type": ["artist", "album", "playlist", "track", "radio"],
      {% endif %}
      {% if artist is defined and artist %}
      "artist": "{{ artist }}",
      {% endif %}
      {% if album is defined and album %}
      "album": "{{ album }}",
      {% endif %}
      "limit": 1
      }
      response_variable: _function_result
  • spec:
    name: music_assistant_play
    description: >
    Plays a spotify URI after searching for it
    using search_music. If a device is not defined,
    use media_player.roomsatellite
    parameters:
    type: object
    properties:
    media_player_id:
    type: array
    items:
    type: string
    description: List of media player Entity IDs to play.
    media_id:
    type: string
    description: Media identifier (URI)
    enqueue:
    type: string
    enum: ["play", "replace", "next", "replace_next", "add"]
    description: >
    How to enqueue the media.
    If the user says to play a song next, then use next.
    If the user says to play a song at the end of the playlist, then use add.
    If the user says to start a new playlist, then use replace.
    If you are unsure, just use play.
    required:
    - media_player_id
    - media_id
    - enqueue
    function:
    type: script
    sequence:
    - service: mass.play_media
    target:
    entity_id: "{{ media_player_id }}"
    data:
    media_id: "{{ media_id }}"
    enqueue: "{{ enqueue }}"

@MatthewGCampbell
Copy link

MatthewGCampbell commented Dec 20, 2024

Hi, I think a lot of things have changed since the normal function. here is a copy of mine also make sure you change the entity id (music player id) in this function to match yours...i hope it helps?

  • spec:
    name: search_music
    description: >
    Searches for music.
    parameters:
    type: object
    properties:
    query:
    type: string
    description: search query
    media_type:
    type: array
    optional: true
    items:
    type: string
    enum: ["artist", "album", "playlist", "track", "radio"]
    description: Types of media to search
    artist:
    type: string
    optional: true
    description: Specify this when you search from a specific artist
    album:
    type: string
    optional: true
    description: Specify this when you search from a specific album
    required:

    • query
      function:
      type: script
      sequence:
    • service: mass.search
      data: >
      {
      "name": "{{ query }}",
      {% if media_type is defined and media_type %}
      "media_type": {{ media_type | tojson }},
      {% else %}
      "media_type": ["artist", "album", "playlist", "track", "radio"],
      {% endif %}
      {% if artist is defined and artist %}
      "artist": "{{ artist }}",
      {% endif %}
      {% if album is defined and album %}
      "album": "{{ album }}",
      {% endif %}
      "limit": 1
      }
      response_variable: _function_result
  • spec:
    name: music_assistant_play
    description: >
    Plays a spotify URI after searching for it
    using search_music. If a device is not defined,
    use media_player.roomsatellite
    parameters:
    type: object
    properties:
    media_player_id:
    type: array
    items:
    type: string
    description: List of media player Entity IDs to play.
    media_id:
    type: string
    description: Media identifier (URI)
    enqueue:
    type: string
    enum: ["play", "replace", "next", "replace_next", "add"]
    description: >
    How to enqueue the media.
    If the user says to play a song next, then use next.
    If the user says to play a song at the end of the playlist, then use add.
    If the user says to start a new playlist, then use replace.
    If you are unsure, just use play.
    required:

    • media_player_id
    • media_id
    • enqueue
      function:
      type: script
      sequence:
    • service: mass.play_media
      target:
      entity_id: "{{ media_player_id }}"
      data:
      media_id: "{{ media_id }}"
      enqueue: "{{ enqueue }}"

Hello, @debdalerichard I've been trying to get this working but all It says back is "Something went wrong: failed to load functions. Verify functions are valid in a yaml format" I've formatted it correctly too I believe so I'm not sure what I've done wrong.

- spec:
    name: search_music
    description: Searches for music.
    parameters:
      type: object
      properties:
        query:
          type: string
          description: The search query for music (e.g., artist, album, track).
        media_type:
          type: array
          optional: true
          items:
            type: string
            enum: ["artist", "album", "playlist", "track", "radio"]
          description: Types of media to search. Default is all media types.
        artist:
          type: string
          optional: true
          description: Specify an artist for a more focused search.
        album:
          type: string
          optional: true
          description: Specify an album for a more focused search.
      required:
      - query
    function:
      type: script
      sequence:
      - service: mass.search
        data:
          name: '{{ query }}'
          media_type: >
            {% if media_type is defined and media_type %}
            {{ media_type | tojson }}
            {% else %}
            ["artist", "album", "playlist", "track", "radio"]
            {% endif %}
          {% if artist is defined and artist %}
          artist: '{{ artist }}'
          {% endif %}
          {% if album is defined and album %}
          album: '{{ album }}'
          {% endif %}
          limit: 1
- spec:
    name: music_assistant_play
    description: >
      Plays a Spotify URI after searching for it
      using search_music. If a device is not defined,
      use media_player.roomsatellite.
    parameters:
      type: object
      properties:
        media_player_id:
          type: array
          items:
            type: string
          description: List of media player Entity IDs to play.
        media_id:
          type: string
          description: Media identifier (URI)
        enqueue:
          type: string
          enum: ["play", "replace", "next", "replace_next", "add"]
          description: >
            How to enqueue the media.
            If the user says to play a song next, then use next.
            If the user says to play a song at the end of the playlist, then use add.
            If the user says to start a new playlist, then use replace.
            If you are unsure, just use play.
      required:
      - media_player_id
      - media_id
      - enqueue
    function:
      type: script
      sequence:
        - service: mass.play_media
          target:
            entity_id: "{{ media_player_id }}"
          data:
            media_id: "{{ media_id }}"
            enqueue: "{{ enqueue }}"

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

3 participants