Make SNIPS talk to Mosquitto MQTT on HASS.IO

Hi,
I’m having issues connecting snips to my home assistant. I have a raspberry pi 3+ with Hass OS and Hass IO installed from the hass homepage, and the snips add-on on the same machine, as well as the mosquitto and samba addons.

I installed my custom snips assistant.zip and it seems to work (intends recognized properly in the log). MQTT also works (I can manually publish messages and execute actions via the developer tab -> services.)

Only I cannot get snips to send MQTTs :frowning:

https://docs.snips.ai/articles/console/actions/actions/code-your-action/manual-action says that

In our case, users are Snips Platform’s components , like the Hotword , Automatic Speech Recognition or Text To Speech These components are sending and receiving messages to each other on predefined topics. We call it the Hermes Protocol. You can learn more by reading the …

Since the latest update of HASS it appears that mosquitto needs an ACL defined:

So does it mean, I need to register every potential SNIPS intent as a seperate user in the mosquitto settings? Can I just use comma?: Thats gonna be a long list…

user test, homeassistant, TurnOn, TurnOff, Query
topic readwrite #

Is there any other easy way to see if Snips is sending any messages at ALL? Like, describing to all channels there are on MQTT.fx? Or sending something to the public mosquito org server (how do I see if a message arrives there?)

I am also unclear about which IP i have to point snips to, for the mosquitto broker? Is it my localhost, 192.168.0.x or the docker container 127.0.0.1? Snips and Hass are installed on the same pi, but hass runs within the container as far as I understand.

Thanks for your help, it feels I’m very close to full home automation…

You should subscribe to the topic hermes/intent/#. e. g.:
mosquitto_sub [-h IP_OF_YOUR_BROKER] -t hermes/intent/#
This works only if you have installed a snips intent(s) and slot(s). The topic contains JSON-expressions with the intents, slots and values you have programmed and trained.

Hi JoergZ,

thanks for your answer. I subscribe via MQTTfx (just to test) to hermes/intent/#, hermes/# and # and /#, so basically I should be able to see if snips does send anything - it doesn’t.

On the snips website I activated a couple of standard assistants and set them to “Home Assistant compliant”. They all come with intents, slots and values - i guess - but I don’t train them myself. Should I? How? When I installed them on a standalone snips server, i could just activate them and they worked like a charm.

Do I need to change anything in the code snippet text?

With Hass IO I chose “Deploy assistant” and saved the resulting assistant.zip file on the hass share. As said, in the logfile it seems to understand all intents just fine and also the mosquitto broker detects a bridge from snips-core.

So I come to the conclusion that it must be some sort of authentification issue, that for example my mqtt settings don’t allow snips to send anything to the broker? There is a warning "SSL not enabled right in the beginning of the log. Is there a way to test it, e.g. make snips send something to an online test broker?

[23:40:27] INFO: Setup mosquitto configuration
[23:40:27] WARNING: SSL not enabled - No valid certs found!
[23:40:27] INFO: Found local users inside config
[23:40:28] INFO: Initialize Hass.io Add-on services
[23:40:28] INFO: Initialize Home Assistant discovery
[23:40:28] INFO: Start Mosquitto daemon
1568670028: Loading config file /share/mosquitto/acl.conf
1568670028: mosquitto version 1.6.3 starting
1568670028: Config loaded from /etc/mosquitto.conf.
1568670028: Loading plugin: /usr/share/mosquitto/auth-plug.so
1568670028: |-- *** auth-plug: startup
1568670028:  ├── Username/password checking enabled.
1568670028:  ├── TLS-PSK checking enabled.
1568670028:  └── Extended authentication not enabled.
1568670028: Opening ipv4 listen socket on port 1883.
1568670028: Opening ipv6 listen socket on port 1883.
1568670028: Opening websockets listen socket on port 1884.
1568670028: Warning: Mosquitto should not be run as root/administrator.
1568670030: New connection from 192.168.0.19 on port 1883.
1568670031: Socket error on client <unknown>, disconnecting.
1568670031: New connection from 192.168.0.19 on port 1883.
[INFO] found test on local database
1568670032: New client connected from 192.168.0.19 as auto-7760BBD3-66EE-58D2-ACD1-0BF1EF26F734 (p2, c1, k60, u'test').
1568670047: New connection from 192.168.0.47 on port 1883.
1568670047: New client connected from 192.168.0.47 as MQTT_FX_Client (p2, c1, k60, u'test').
1568670050: New connection from 172.30.33.2 on port 1883.
[INFO] found addons on local database
1568670051: New bridge connected from 172.30.33.2 as core-snips.local.hass.io.main-mqtt (p1, c0, k60, u'addons').

The SNIPS LOG also looks good to me

[23:38:54] [AudioServer] was asked to play a wav of 93.1 kB with id 'de753fbc-211e-4fce-92f5-e98704d0ad67' on site default
INFO:snips_audio_portaudio      : Playing "de753fbc-211e-4fce-92f5-e98704d0ad67" using output "default", wav spec: WavSpec { channels: 2, sample_rate: 22050, bits_per_sample: 16, sample_format: Int }
INFO:snips_audio_portaudio      : Playing of "de753fbc-211e-4fce-92f5-e98704d0ad67" finished
[23:38:55] [AudioServer] finished playing wav with id 'de753fbc-211e-4fce-92f5-e98704d0ad67'
INFO:snips_tts_hermes: Received a play finished message from audio server with an unknown id 'de753fbc-211e-4fce-92f5-e98704d0ad67'. Ignoring it.
[23:38:55] [Nlu] was asked to parse input "turn on the bedroom light"
[23:38:55] [Nlu] detected intent v_amish:TurnOn with confidence score 1.000 for input "turn on the bedroom light"
              Slots ->
                 Location -> bedroom (confidence: 0.968)
                   Entity -> light (confidence: 0.968)
[23:38:55] [Dialogue] New intent detected v_amish:TurnOn with confidence 1.000
              Slots ->
                 Location -> bedroom (confidence: 0.968)
                   Entity -> light (confidence: 0.968)
INFO:snips_dialogue_lib::coordinator::coordinator: Session [160af0ad-681e-491b-ac20-0985c0363b65]: closing session which was active: Timeout
INFO:snips_dialogue_lib::coordinator::coordinator: Site [default]: reset site -> turn off ASR and turn on Hotword
[23:39:00] [Dialogue] session with id '160af0ad-681e-491b-ac20-0985c0363b65' was ended on site default. The session was ended because one of the component didn't respond in a timely manner
[23:39:00] [Asr] was asked to stop listening on site default
[23:39:00] [Hotword] was asked to toggle itself 'on' on site default
INFO:snips_hotword_lib::audio    : Audio thread for site default started.

In the homeassistant confiiguration.yaml I added these as a test - do I have to do this for all intents? It doesn’t work anyways…

snips:

#  Trying to define intents for snips
intent_script:
  TurnOn:
    action:
      - service: homeassistant.toggle
        data_template:
          entity_id: group.all_switches

  TurnOff:
    action:
      - service: homeassistant.toggle
        data_template:
          entity_id: switch.{{ Location }}

You don’t create a user for every intent. Just create one user, and set your ACL to give permission to read and write any topic. You do need to give snips the username and password, though.

However, IIRC, the snips add-on is set to run its own instance of mosquitto, and it tries to bridge to the MQTT add-on. You want your snips.toml file to have “mqtt = localhost:1883” in order for it to work. This is preferred for now, since many of the snips skills (especially the samples from the snips developers) assume the MQTT server is running on localhost at port 1883 and requires no authentication.

But yes, you do need to define an intent_script entry for every intent. Additionally, if your assistant has any home assistant snippets, you need to be sure to copy the snippets to your /config/python_scripts directory, since, IIRC, the add-on won’t do it for you. :slight_smile:

1 Like

Unfortunately, I haven’t been keeping track of the changes to the snips hassio addon.

It looks like it is connecting properly but that snips is connecting as the user ‘addons’?
Where as the others use a user ‘test’?
What user are you connecting to test with by subscribing to the topics? Just subscribe to all topics with # I think

Ok, I won’t create new users then. I don’t know why snips signs up as user “addons” but apparently the name has been found in the database… my setting for now is to have username and password as “test”.
I changed “mqtt-bridge” to just “mqtt”
Im the new addons im not supposed to work in the toml files anymore I believe… how do I copy the snippets over? And where to? Do I still need to do this with the new addons module? I’d first try to check if my intents specification in the configure.yaml is correct…

Your intents look good. You can try triggering them manually by sending a message via mqtt, do a qiuck search on sending intents directly using mqtt_pub and you should find something.

I don’t know how to copy snippets over with the addon.