Intent_script and data from rhasspy

Hi all,

I’m using rhasspy to handle voice control with homeassistant. Where I’m struggling is:
I want to build an intent_script that starts music on a certain media_player.

Through rhasspy slots/sentences configuration I can see that rhasspy reliably puts correct entity_id from slots in the output json under entiteis → value.

But how can I access this value in the intent script ?
Can I “watch” intent events in ha to debug more ?

Hope you all can help me.

intent_script:
  StartPlayer:
    speech:
      text: Wiedergabe auf {{ entity }} gestartet
    action:
      - service: notify.notify
        data:
          message: Entity {{ entities.name }} Name {{ text }}
      - service: media_player.media_play
        data_template:
          entity_id: {{ WHATDOINEEDTOPUTHERE }}

JSON Rhasspy

{
    "intent": {
        "name": "StartPlayer",
        "confidence": 1
    },
    "entities": [
        {
            "entity": "name",
            "value": "media_player.wohnzimmer",
            "value_details": {
                "kind": "Unknown",
                "value": "media_player.wohnzimmer"
            },
            "raw_value": "sonos media_player.wohnzimmer",
            "start": 18,
            "end": 41,
            "raw_start": 18,
            "raw_end": 47
        }
    ],
    "slots": {
        "name": "media_player.wohnzimmer"
    },
    "text": "starte wiedergabe media_player.wohnzimmer",
    "raw_text": "starte wiedergabe sonos media_player.wohnzimmer",
    "tokens": [
        "starte",
        "wiedergabe",
        "media_player.wohnzimmer"
    ],
    "raw_tokens": [
        "starte",
        "wiedergabe",
        "sonos",
        "media_player.wohnzimmer"
    ],
    "wakeword_id": "jarvis_raspberry-pi",
    "siteId": "default",
    "sessionId": "default-jarvis_raspberry-pi-a61148da-8b17-40fc-a2aa-357533f33559",
    "customData": "jarvis_raspberry-pi",
    "wakewordId": "jarvis_raspberry-pi",
    "lang": null
}

mediaplayer slots:

sonos: media_player.wohnzimmer
mopi: media_player.mopi_local

sentences.ini

[StartPlayer]
players = $hass/entities,media_player
entities = $mediaplayers
play [(wiedergabe | auf )] (<entities>){name}
starte [(wiedergabe | auf )] (<entities>){name}

Hi @srsbaca

Did you find out how to do that ? Same point as you with Rhasspy :wink:

Thanks

Vincèn

I am still trying to work this out myself for more complex intents :frowning:

It appears that only 2 pieces of data are being passed from Rhasspy to Home Assistant … The Intent name “StartPlayer”, and a variable named “name” with the value of “media_player.wohnzimmer”.

Your intent_script corrently has the name “StartPlayer:”, and I believe “WHATDOINEEDTOPUTHERE” should be “name” (being the name of the variable you want to use in the script) … giving

     - service: media_player.media_play
        data_template:
          entity_id: {{ name }}

I don’t see where the entity, entities.name or text variables come from, and they could be causing the problems if HA doesn’t recognise them.

this is a simple workflow for a rhasspy 2 HA workflow to start a TV on a specific channel using the intent_script integration. The start script itself is lauchned by ssh remote script call. rhasspy delivers the Channel (KanalNummer) which is used as parameter data for the script to start the TV.

configuration.yaml (HA):

shell_command:
[email protected] scripts/start_TVkodi.sh {{meinkanal}}
# rhasspy Integration
intent:
intent_script:
  SchalteTVEin:
    action:
      - service: shell_command.wz_start_tvkodi
        data:
          meinkanal: "{{KanalNummer}}"
    async_action: true
    speech:
       text: schalte TV auf Kanal {{KanalNummer}} ein

the basic configuration of rhasspy and HA is described by Thorsten-Voice in his video.