Hi All,
I have to admit it’s a bit frustrating.
I’m trying for the last past months to build my home automation with a minor, but encouraging, seccesses.
I managed to build hass.io on a rpi 3b+ with a simple automation
I managed to build snips on a different rpi 3b+ with the built in time app
Now I want to control hass.io with snips with no luck
I read a lot, but it doesnt work
First, how do I know if they try to talk each other using mqtt?
Second, how to I add a simple voice command that triggers my automation?
There are a few different approaches to making snips and hassio work with each other. Each approach requires different amounts of setup.
First approach (the default suggested by snips documentation):
This one assumes you’ll create an “app” on the snips console that uses “HA Snippets” “actions”. Setting this up properly can be challenging, because you are very limited in what an HA snippet can do, and there’s a lot of work for it. The first thing to set up is to make sure you’re running mosquitto on the same system as snips (in theory you don’t have to do that, but as of today, at least, you do). This installation must not be running TLS (it doesn’t work – despite having options to do it, snips simply won’t connect to MQTT over TLS). Then make sure you have mosquitto (via the MQTT add-on is a good idea) running on the hassio system (this one is OK to use TLS). Then configure mosquitto on snips to bridge to your HA MQTT server. You’ll use a config something like this:
connection hassio-mqtt
address <IP address or hostname of your hassio>:<external port you set for MQTT>
cleansession false
clientid <hostname of your snips system>
start_type automatic
username <username for MQTT on hassio>
password <password for MQTT on hassio>
notification false
try_private false
topic hermes/intent/# out
topic hermes/dialogueManager/# in
You don’t need to bridge other topics. Those two will get intents from snips to HA, and let you send text from HA to snips to be spoken. If you’re using TLS, you’ll need to add a few more options to the bridging section.
Next, you have to set up HA to pay attention to intents from snips. Add the “snips”, “python_script”, and and “intent_script” components to your configuration.yaml. For intent_script, you should probably set it to include another file. Follow the “Triggering Actions” section of https://www.home-assistant.io/components/snips/ to understand how to set up intent_script (but ignore everything above that section on that page; it will not be helpful). After you install your snips assistant, you need to copy the python files it created into your <config>/python_scripts directory on the hassio system. You need to do this every time you update your snips assistant (well, there are some exceptions to that, but just do it anyway; it’ll be easier ). And don’t forget that any time you change something in intent_script, you’ll need to restart HA.
Second approach
For this one, you create your snips app using a “git” “action”. Then you write your code to invoke the HA REST API. This one requires only a little setup between HA and snips – namely, you need to generate a long-lived token for HA, and place that token in your snips skill’s configuration for each skill that needs to integrate with HA. You can do pretty much anything you want this way – the REST API in HA has full access to everything that your HA installation can do, and by using a “git action” in snips, you’re writing your own code, and can do pretty much whatever you want with it on the snips side. If you look at the snips forums, search for posts from the user s710. He’s got an excellent example of this approach (he’s on here, too, but I can’t remember his username here).
Third approach
Use the snips add-on for hassio on your rpi 3b+, and turn the second one into a snips bridge. This is essentially the same as the first approach, only it’ll do some of the setup for you. However, you’ll need to do some of the intent_script and python_script setup on your own if you go outside the default assistant for this add-on. And forget about doing anything in snips that doesn’t go through HA.
Fourth approach (note this one uses software from me)
Ditch hassio and snips on the two rpi’s, and instead configure them both as snips satellites. Install hassio on an x86 VM (or real hardware if you prefer), and then install my snips add-on (see https://github.com/franc6/snips-hassio-addon). My add-on automates all of the setup for communication between snips and hassio for the first approach, and if you’re careful with how you craft your skill for the second approach (see s710’s project), it’ll automate that, too (no generating a long-lived token necessary). This way lets you run stuff on snips with or without going through HA.
Which approach you take will determine how to add a voice command to trigger something in HA. I think the fourth approach is the most flexible, but I’m obviously biased. Once you decide which way you want to go, you’ll probably find more help on the snips forums for creating the voice commands (intents and utterances) and how to write the actions for snips. But you’ll probably get more help here for the specific mechanics of using the REST API or invoking automations for HA.