Not a valid value for dictionary value @ data['action'][0]['entity_id']. Got '{{ trigger.event.data.entity }}'

Hi

I have installed and got Rhasspy working via events for simple straightforward intent’s [AllumeLumiere] where i am not using the json content as references then the following automation works:

- id: rhasspy AllumeLumiere
  alias: rhasspy AllumeLumiere
  description: ''
  trigger:
  - event_data: {}
    platform: event
    event_type: rhasspy_AllumeLumiere
  condition: []
  action:
  - service: light.turn_on
    entity_id: light.lumiere_plafond
   mode: single

As soon as i try to use the JSON entity then I see the not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got ‘{{ trigger.event.data.entity }}’ message appearing in the log as sson as I reload the configuration.yaml .

Here is the JSON extracted from the MQTT message:

{
  "input": "Allume lumière light.lumiere_plafond",
  "intent": {
    "intentName": "AllumeLumiere",
    "confidenceScore": 1
  },
  "siteId": "roulotte",
  "id": "329c6ac7-7aee-4be8-a2c3-2cad2eb81baa",
  "slots": [
    {
      "entity": "entity",
      "value": {
        "kind": "Unknown",
        "value": "light.lumiere_plafond"
      },
      "slotName": "entity",
      "rawValue": "plafond",
      "confidence": 1,
      "range": {
        "start": 15,
        "end": 36,
        "rawStart": 15,
        "rawEnd": 22
      }
    }
  ],
  "sessionId": "329c6ac7-7aee-4be8-a2c3-2cad2eb81baa",
  "customData": null,
  "asrTokens": [
    [
      {
        "value": "Allume",
        "confidence": 1,
        "rangeStart": 0,
        "rangeEnd": 6,
        "time": null
      },
      {
        "value": "lumière",
        "confidence": 1,
        "rangeStart": 7,
        "rangeEnd": 14,
        "time": null
      },
      {
        "value": "light.lumiere_plafond",
        "confidence": 1,
        "rangeStart": 15,
        "rangeEnd": 36,
        "time": null
      }
    ]
  ],
  "asrConfidence": null,
  "rawInput": "allume lumière plafond",
  "wakewordId": null,
  "lang": null
}

Here is the automation with the JSON reference:

- id: rhasspy AllumeLumiere
  alias: rhasspy AllumeLumiere
  description: ''
  trigger:
  - event_data: {}
    platform: event
    event_type: rhasspy_AllumeLumiere
  condition: []
  action:
  - service: light.turn_on
    entity_id: "{{ trigger.event.data.entity }}"
    mode: single

Can anyone point me wher Is my issue, I already check my automation code in a YAML checker, there are no issues pointed out.

thanks for any help

  action:
  - service: light.turn_on
    target:
      entity_id: "{{ trigger.event.data..slots[0].value.value }}"

You can use this tool to find json paths: https://jsonpathfinder.com/

Also to use a template the key (key: value) must be under either service:, data: or target:.

Thanks Tom, as you probably have figured out, I am not a expert at coding…
I tried replacing with your suggestion and replaced:

entity_id: "{{ trigger.event.data.entity }}"

with:

entity_id: "{{ trigger.event.data..slots[0].value.value }}"

and still have the same message when reloading configuration.yaml

I am sorry I don’t understand what you mean by : Also to use a template the key (key: value ) must be under either service: , data: or target: . where do I get this key value ?

I followed that guide word to word but it seems we might have something different on our systems:

You already have the key value pair: entity_id: something. To be able to put a template in that “something” the whole lot must go under target: as in my example.

The other places you can put templates are under data: or service:.

I see what you mean now but:

action:
  - service: light.turn_on
    target:
      entity_id: "{{ trigger.event.data..slots[0].value.value }}"

did not worked, i had to put the following to get it to work, THANK A LOT

action:
  - service: light.turn_on
    target:
      entity_id: "{{ trigger.event.data.entity }}"