Hi Folks,
SnipsAI is a nice solution to talk to your Openhab. Other than Alexa or Google etc. it uses offline service and isn’t connected to any cloud service to manage ASR/TTS. But you can use an external TTS cloud service if the built in voice isn’t good enough for your purposes.
My Snips is installed on a raspberry pi. I connect it via LAN to my openhab server.
And here is how to manually configure a MQTT broker and thing for Snips:
First you need to add a snips.things file
Bridge mqtt:broker:SnipsAI "MQTT - SnipsAI Broker" @ "MQTT" [
host="<IP of your Snips service>",
secure=false,
port=1883,
qos=0,
retainMessages=false,
clientID="Openhab2",
keep_alive_time=30000,
reconnect_time=60000,
username="<username if you added one in Snips config>",
password="<password if you added one in Snips config>"
]
{
Thing mqtt:topic:SnipsAI "MQTT - SnipsAI Thing" @ "MQTT" {
Channels:
Type string : Snips_Intent "Snips Intent" [
stateTopic="hermes/intent/#:state:default",
commandTopic="hermes/intent/#:state:default"
]
}
}
now you should be able to receive mqtt messages from Snips
You also have to create a snips.items file
String Snips_Intent "Snips Intent" (gSnips) { channel="mqtt:topic:SnipsAI:Snips_Intent" }
Now you can use this Item to add rules to your openhab. create snips.rules file like this
rule "Snips"
when
Item Snips_Intent received update
then
var String intentName = transform("JSONPATH", "$.intent.intentName", Snips_Intent.state.toString)
var String onlyIntent = intentName.split(":").get(1);
var String device_val = transform("JSONPATH", "$.slots[0].value.value", Snips_Intent.state.toString)
logInfo ("Snips Intent: ", Snips_Intent.state.toString)
logInfo ("Snips Gerät: ", device_val)
onlyIntent = onlyIntent.toLowerCase
logInfo ("Snips device value: ", onlyIntent)
logInfo("Snips device value: ", device_val)
Now you can add intents to your Snips installation and expand your rule with something like this
if (onlyIntent == 'LampsOn') {
SwitchOnOff = "ON"
}
else if (onlyIntent == 'LampsOff') {
SwitchOnOff = "OFF"
}
if (device_val == 'Livingroom') {
sendCommand(<mylightItem>, SwitchOnOff)
}
How you can configure your Snips is not part of this tutorial but you can use this explaination video to get started.
Hope this will help… Have fun