Snips and Home assistant : can't run python script

#1

Hello,
this is my intent_scripts.yaml:

AccendiLuci:
  action:
  service: python_script.action_boggiano_accendiluci_boggiano_luciha.py

this is my python_scripts/python.script.action_boggiano_accendiluci_boggiano_luciha.py :

logger.error("START")
'''
stanza = data.get('stanza')
numero = data.get('numero')

logger.info('AccendiLuciSnips')

if stanza is not None:
# Attento che in sala hai anche la luce.strip_sala
  if stanza == 'sala'
    entity_id = 'light.luce_{}'.format(stanza)
    logger.info('AccendiLuciSnips1 ' + entity_id)
    if numero is not Nome:
      entity_id = 'light.{}'.format(stanza) + '_' + numero
      logger.info('AccendiLuciSnips2 ' + entity_id)
  else:
    entity_id = 'light.{}'.format(stanza)
    logger.info('AccendiLuciSnips3 ' + entity_id)

logger.error(stanza)
'''

entity_id = "light.luce_sala_1"
service_data = {'entity_id': entity_id }
hass.services.call('light', 'turn_on', service_data, False)

(I know it’ s all comment right now becuse I am debugging it!)

Within mosquitto (.68 is HA)

mosquitto_sub -h 192.168.188.68 -t hermes/intent/boggiano:AccendiLuci

I see:
{"sessionId":"1ae7cb1b-86b2-437f-92f1-885468dbdab9","customData":null,"siteId":"default","input":"accendi luce sala","asrTokens":[[{"value":"accendi","confidence":1.0,"rangeStart":0,"rangeEnd":7,"time":{"start":0.0,"end":1.14}},{"value":"luce","confidence":1.0,"rangeStart":8,"rangeEnd":12,"time":{"start":1.14,"end":1.8299999}},{"value":"sala","confidence":1.0,"rangeStart":13,"rangeEnd":17,"time":{"start":1.8299999,"end":2.52}}]],"asrConfidence":1.0,"intent":{"intentName":"boggiano:AccendiLuci","confidenceScore":1.0},"slots":[{"rawValue":"sala","value":{"kind":"Custom","value":"Sala"},"range":{"start":13,"end":17},"entity":"Stanza","slotName":"stanza","confidenceScore":1.0}]}

But I dont’ see any log in HA (of course the light remains off!)

If I manually lunch the script from the HA service page I see the logger lines and the light goes on.

Moreover I dont’ see any log line telling me:

[homeassistant.components.snips] Received unknown intent boggiano:AccendiLuci

So i think that the intent is triggered but the script doesn’t run.

Any idea ?

#2

Answer to myself:
the problem was the indentation into the file intent_script.yaml.

This is correct:

AccendiLuci:
  action:
    service: python_script.action_boggiano_accendiluci_boggiano_luciha
    data_template:
      stanza: "{{stanza}}"
#3

Glad you got it! The ‘Dialogue ended’ is because it didn’t get an endsession msg as you thought. You can add a speech section to your intent script. If you don’t want it to say anything you can safely ignore the error and keep it like you have it.