Intent and slots recognized but wrong action is performed


#1

Hello to snips communitty

I have some difficulties setting up my assisstant to work properly with home assistant.
I am a noob regarding coding, I have being messing arround with many different setups with no luck though.
I am trying to make a simply turnon and turnoff function with just one slot as house_room,
but every time the hole light domain receaves the on or off intent. Never managed to make a slot work properly.
Any help would be extra appriciated!!!
Regards Nikos


#2

Can you test it in the snips console and post the output of the command?


#3
{
  "input": "turn off kitchen lights",
  "intent": {
    "intentName": "nik_poz:turnOff",
    "probability": 0.9500348
  },
  "slots": [
    {
      "rawValue": "kitchen",
      "value": {
        "kind": "Custom",
        "value": "kitchen"
      },
      "range": {
        "start": 9,
        "end": 16
      },
      "entity": "house_room",
      "slotName": "house_room"
    }
  ]
}

#4

I am not quite sure about the code I used in actions, and totaly comfused about HA setup…


#5

That all looks good, can you post your ha config?


#6

intent_script:
NIKOFF:
speech:
type: plain
text: ‘OK, light is off’
action:
service: light.turn_off
entity_id: all
NIKON:
speech:
type: plain
text: ‘OK, light is on’
action:
service: light.turn_on
entity_id: all


#7

intent_script:
NIKOFF:
speech:
type: plain
text: ‘OK, light is off’
action:
service: light.turn_off
entity_id: all
NIKON:
speech:
type: plain
text: ‘OK, light is on’
action:
service: light.turn_on
entity_id: all

this must be totaly wrong ,hhhm??


#8

Yeah that doesn’t look right, something like this. Use ``` around code to preserve formating when pasting configs

intent_script:
  turnOff:
    speech:
      type: plain
      text: 'OK, light is off'
    action:
      service: light.turn_off
      data_template:
        entity_id: {{ house_room }}


#9

If still having trouble use this in your configuration.yaml and look for the lines in the log script

logger:
  default: warning
  logs:
    homeassistant.components.snips: debug

#10

Error loading /config/configuration.yaml: invalid key: “OrderedDict([(‘house_room’, None)])”
in “/config/configuration.yaml”,

I am getting this when I do check config


#11

Try double quotes around it

intent_script:
  turnOff:
    speech:
      type: plain
      text: 'OK, light is off'
    action:
      service: light.turn_off
      data_template:
        entity_id: "{{ house_room }}"

#12

ok, this is done , I have a valid config…
anything else that must be added in my HA??


#13

No, that should do it just test it out


#14

nope… It didn’t. what about the action code in the console? what is should look like there??


#15

not a valid value for dictionary value @ data[‘entity_id’]


#16

What does it say in the ha logs? you dont need anything for action in the snips console


#17

let me try to make an other assistant to the console… cause this one I thing have some action code


#18

new assistant without actio code and these are my logs:

(snips side)
[20:24:18] [Asr] was asked to listen on site default
[20:24:21] [Asr] captured text “turn on test light” in 2.0s with tokens: turn[1.000], on[1.000], test[0.671], light[0.924]
[20:24:21] [Asr] was asked to stop listening on site default
[20:24:22] [Nlu] was asked to parse input “turn on test light”
[20:24:22] [Nlu] detected intent nik_poz:NIKON with probability 0.887 for input “turn on test light”
Slots ->
house_room -> test (confidence: 0.787)
[20:24:22] [Dialogue] New intent detected nik_poz:NIKON with probability 0.887
Slots ->
house_room -> test (confidence: 0.787)
[20:24:28] [Dialogue] session with id ‘0df76841-bf8e-48b1-a0d1-96ddce58b67d’ was ended on site default. The session was ended because one of the component didn’t respond in a timely manner
[20:24:28] [Asr] was asked to stop listening on site default
[20:24:28] [Hotword] was asked to toggle itself ‘on’ on site default

(HA side)

2019-02-17 18:24:22 DEBUG (MainThread) [homeassistant.components.snips] New intent: {“sessionId”:“0df76841-bf8e-48b1-a0d1-96ddce58b67d”,“customData”:null,“siteId”:“default”,“input”:“turn on test light”,“asrTokens”:[[{“value”:“turn”,“confidence”:1.0,“range_start”:0,“range_end”:4,“time”:{“start”:0.0,“end”:0.59999996}},{“value”:“on”,“confidence”:1.0,“range_start”:5,“range_end”:7,“time”:{“start”:0.59999996,“end”:0.87}},{“value”:“test”,“confidence”:0.6706601,“range_start”:8,“range_end”:12,“time”:{“start”:0.8728643,“end”:1.3225715}},{“value”:“light”,“confidence”:0.92400354,“range_start”:13,“range_end”:18,“time”:{“start”:1.3225715,“end”:2.1753762}}]],“intent”:{“intentName”:“nik_poz:NIKON”,“probability”:0.88689965},“slots”:[{“confidence”:0.78720534,“rawValue”:“test light”,“value”:{“kind”:“Custom”,“value”:“test”},“range”:{“start”:8,“end”:18},“entity”:“house_room”,“slotName”:“house_room”}]}
2019-02-17 18:24:22 WARNING (MainThread) [homeassistant.helpers.intent] Received invalid slot info for NIKON: not a valid value for dictionary value @ data[‘entity_id’]
2019-02-17 18:24:22 ERROR (MainThread) [homeassistant.components.snips] Error while handling intent: NIKON.
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/intent.py”, line 64, in async_handle
result = await handler.async_handle(intent)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/intent_script.py”, line 83, in async_handle
await action.async_run(slots)
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py”, line 131, in async_run
await self._handle_action(action, variables, context)
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py”, line 210, in _handle_action
action, variables, context)
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py”, line 299, in _async_call_service
context=context
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py”, line 85, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context)
File “/usr/local/lib/python3.6/site-packages/homeassistant/core.py”, line 1110, in async_call
processed_data = handler.schema(service_data)
File “/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py”, line 267, in call
return self._compiled([], data)
File “/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py”, line 589, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py”, line 427, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: not a valid value for dictionary value @ data[‘entity_id’]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/snips.py”, line 142, in message_received
hass, DOMAIN, intent_type, slots, request[‘input’])
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/intent.py”, line 70, in async_handle
‘Received invalid slot info for {}’.format(intent_type)) from err
homeassistant.helpers.intent.InvalidSlotInfo: Received invalid slot info for NIKON

snips and HA run on seperate devices


#19

Great info there thanks. I think you need to try adding light. to the entity_id

So this should turn on light.test. Is that a valid light in your setup? If it isn’t you can do a couple things, define aliases in the snips assistant or use if statements in data_template to convert them into valid switches.

    action:
      service: light.turn_off
      data_template:
        entity_id: "light.{{ default(house_room, light_that_exists )}}"

#20

No luck at all…! I tried this with a new assistant too, but no luck. entities I use in hass.io are named in the assistant exactly ,but no…