HA + MA no voice integration working, throws error

FWIW here is my current setup, I’ll update it whenever I make some progress.

What is working

  • Play by track (Spiele Song Fly me to the moon) - (Play song fly me to the moon)
  • Play by artist (Spiele etwas vom Künstler Frank Sinatra) - (Play something from the artist Frank Sinatra)
  • Play by radio station (Spiele Radio WDR1) - (Play radio WDR1)

What is not

  • handling the parameter radio_mode is giving me headaches and does not work
  • the combination track + artist somehow isn’t parsed correctly, it will include artist in the track name
  • still need better error handling and feedback
  • play by playlist not implemented yet
  • play by album not implemented yet
  • playing on different media devices not implemented yet

Other

  • There is an interesting thing that when I omit “Song” from “Play song XY”, it will still play a song, but it’s always UB40 - Kingston Town for me. Not sure what’s going on here.
  • I found out stopping playback can be issued with OK Nabu stop playback, only stop does not work.
  • Again, note that I’ve used german “de” for the folder structure and german commands. Replace them with “en” and english commands (probably use the ones from MA), if you’re an english speaker.

Intent code

/homeassistant/configuration.yaml

language: "de"
intents:
  MassPlayMediaAssist:
    data:
      # CONTEXT AWARNESS
        - sentences:
            - "<play> <track> {track}[ von {artist}]"
            - "<play> <artist> {artist} [(mit|im) {radio_mode}]"
            - "<play> <radio_station> {radio}"
          expansion_rules:
              play: "(spiel|spiele)"
              artist: "[[etwas ][(von|vom) ][(der|dem)] (artist|künstler|band|gruppe)]"
              track: "[(das|den) ](track|song|lied|titel)"
              album: "[(der|die|das) ](album|ep|platte|sammlung|single)"
              playlist: "[der ]playlist"
              radio_station: "[((den)|(das)|(die)) ]((radio sender)|(radio)|(sender))"
              radio_mode: "(radiomodus|radio modus)"
lists:
  artist:
    wildcard: true
  album:
    wildcard: true
  track:
    wildcard: true
  playlist:
    wildcard: true
  radio:
    wildcard: true
  query:
    wildcard: true
  radio_mode:
    values:
      - "Radiomodus"
      - "Radio modus"
       
skip_words:
  - "bitte"
  - "kannst du"

Intent script code

/homeassistant/custom_sentences/de/music_assistant_PlayMediaOnMediaPlayer.yaml

intent_script:
  MassPlayMediaAssist:
    action:
      - choose:
          # Case 1: Only track
          - conditions:
              - condition: template
                value_template: >
                  {{ track is defined and track != '' and 
                     (artist is not defined or artist == '') }}
            sequence:
              - service: music_assistant.play_media
                target:
                  entity_id: media_player.home_assistant_voice_091d31_media_player_2
                data:
                  enqueue: replace
                  media_id: "{{ track }}"
                  media_type: track
                  radio_mode: false # "{{ radio_mode | default(false) }}"

          # Case 2: Only artist
          - conditions:
              - condition: template
                value_template: >
                  {{ artist is defined and artist != '' and 
                     (track is not defined or track == '') }}
            sequence:
              - service: music_assistant.play_media
                target:
                  entity_id: media_player.home_assistant_voice_091d31_media_player_2
                data:
                  enqueue: replace
                  media_id: "{{ artist }}"
                  media_type: artist
                  radio_mode: false # "{{ radio_mode | default(false) }}"

          # Case 3: Track and artist
          - conditions:
              - condition: template
                value_template: >
                  {{ track is defined and track != '' and 
                     artist is defined and artist != '' }}
            sequence:
              - service: music_assistant.play_media
                target:
                  entity_id: media_player.home_assistant_voice_091d31_media_player_2
                data:
                  enqueue: replace
                  media_id: "{{ track }} - {{ artist }}"
                  media_type: track
                  radio_mode: false # "{{ radio_mode | default(false) }}"
                  
          # Case 4: Radio
          - conditions:
              - condition: template
                value_template: >
                  {{ radio is defined and radio != '' }}
            sequence:
              - service: music_assistant.play_media
                target:
                  entity_id: media_player.home_assistant_voice_091d31_media_player_2
                data:
                  enqueue: replace
                  media_id: "{{ radio }}"
                  media_type: radio
                  radio_mode: false # "{{ radio_mode | default(false) }}"

Response code

/homeassistant/custom_sentences/de/responses.yaml

language: "de"
responses:
   intents:
     MassPlayMediaAssist:
       default: "Okay"
1 Like