Connecting snips to openhab

Thank you for sharing your setup. Great idea. I will try to build it like this.
Is there a reason why you use mqtt and not the REST API?

I am already using mqtt in openhab for other connections and snips is using mqtt, too.
For me that was by far the easiest way to connect both systems without any programming.

Thank you for sharing, I’m trying to move from Alexa to snips and making my first steps, with your example I get the snips output in the openhab log.

But, I can’t get the “ScriptServiceUtil” to work.
Have I something to import?

Great work, go on

My fault… I forgot the very first line.
Yes, you need to import the ScriptServiceUtils

import org.eclipse.smarthome.model.script.ScriptServiceUtil

I modified the initial post.
Thanks for that hint.


Thank you for fast replay,
I’ll try this afternoon.

Have a nice day

Matthias :wink:


I use snips with openhab too. But i did it in different way.
I added mqtt bind (client) to openhab. And create a bridge with a channel by intent :

Bridge mqtt:broker:mymqttsnips "MQTT Snips Broker" [ host="snips-master" ] 
    Thing topic thsnips "Generic MQTT Snips" 
            Type string : light_off "Light off"  [ stateTopic="hermes/intent/cedcox:eteindreLumiere", commandTopic="", formatBeforePublish="" ]
            Type string : light_dim_down "Light DIM down"  [ stateTopic="hermes/intent/cedcox:varierBasLumiere", commandTopic="", formatBeforePublish="" ]
        [....... and so on ....]


and after, i create one rule by intent :

rule "light off"
        Item Snips_Intent_light_off received update 
        confidence = transform("JSONPATH", "$.intent.probability", Snips_Intent_light_off.state.toString)
        logInfo("rule light off", "confidence : " + confidence.toString)  

    if (Double::parseDouble(confidence) > 0.8) {
        // Get variables

        siteId = transform("JSONPATH", "$.siteId", Snips_Intent_light_off.state.toString)
        logInfo("rule light off", "siteId : " + siteId.toString)  

        sessionId = transform("JSONPATH", "$.sessionId", Snips_Intent_light_off.state.toString)
        logInfo("rule light off", "sessionId : " + sessionId.toString)  

        entity_room = transform("JSONPATH", "$.slots.[?(@.slotName== 'house_room')].value.value", Snips_Intent_light_off.state.toString)
        entity_room = entity_room.replace("-","_")
        entity_room = entity_room.replace(" le ","")
        entity_room = entity_room.replace(" la ","")
        entity_room = entity_room.replace(" du ","")
        entity_room = entity_room.replace(" d'","")
        entity_room = entity_room.replace(" l'","")
        entity_room = entity_room.replace(" ","_")
        entity_room = entity_room.replace("'","_")
        entity_room = entity_room.replace("é","e")
        entity_room = entity_room.replace("à","a")
        entity_room = entity_room.replace("ê","e")
        entity_room = entity_room.replace("î","i")
        logInfo("rule light off", "entity_room : " + entity_room)  

    [.... blablablabla ...]

An alternative solution that does not need a mqtt srever on openhab (if you did not need it before :wink: )
Does not manage multislot of house_room, but i have already an idea to implement… I just need time :slight_smile:


Thank you for that alternative.
I like the idea to check for the confidence, will implement that, too. :grin:

Hi all,

I use Openhab with Snips too, but I’ve a problem with the mqtt connection. With one Snips-Master everything works fine but when I add a satellite the communication between openhab and snips is broken. When i deconnect the sattelite all things works fine.
Anybody have an idea?
Thanks a lot.

I do not have experience with using satellites, but I recommend to use and checking what is going on in mqtt.

1 Like

Edit: Working now

Following this I ran into this problem:

Any idea what’s wrong?

1 Like

Hello everybody! this is my first time on forum, I have a working openhab installation with mqtt running and I want to test Snips!
I am trying to configure basic command configurations for controlling music, like pause, play, next song and up/down volume… could you please better explain how to configure in snips console side (for send datas via mqtt to my broker)? I mean… i create some intents for different commands… and then? what do I have to do in action types?
thank you very much for your help and sharing!


Hi @dntr,

maybe just tell us a bit more about your setup so we can give you a good answer. :slight_smile:
Which hardware do you use and which items did you define in OpenHAB?

It is possible to connect Snips and OpenHAB without defining any actions, just intents. Have a look at this post: Connecting snips to openhab

Hi @dntr,

do you use standard rules or Next-Gen-Rules via JSR223? If you use the latter, do you use JavaScript? If so, then I can provide you a mini howto.

Have a nice weekend!

Hello everybody! thanks for your answers!

I use some sonoff with tasmota firmware and I would like to use snips mainly for controlling music (for now)… play, pause, next track and volume.
I have chromecast audio (with binding installed in openhab) with multiroom configuration and my main source is spotify premium… (or some web radio)
Openhab run on raspberry pi 2 with mosquitto and now I have set up a new raspberry pi3 only for snips (and would like to add some snips satellite in future if they are working good!).
I prefer to use the openhab broker, not the snips one because it is already working!
I use standard rules, I am not up-to-date with next-gen-rules but if they are easier… why not?! :slight_smile:

thanks everybody for your help!


I tried Mathias solution but it is not working, I think there is a problem with mqtt because I cant see anything on openhab broker about the hermes topic…
I added the code in the /etc/mosquitto/mosquitto.conf file on snips server (and reboot) but still no updates… how can I make snips talking to openhab (easy way) :slight_smile:


Could you past your mosquitto.conf of your snips Raspi.
Maybe we can figure out what is wrong.

It Works! I receive update on openhab mosquitto now!

I have also created the rule as in Matthias post:
rule “Snips”
Item Snips_Intent received update
//logInfo(“Snips Intent”, Snips_Intent.toString)

var String intentName = transform("JSONPATH", "$.intent.intentName", Snips_Intent.state.toString) 
var String snipsIntent  = intentName.split(":").get(1);
var String snipsSlot1RawValue = transform("JSONPATH", "$.slots[0].rawValue", Snips_Intent.state.toString)
var String snipsSlot1Value    = transform("JSONPATH", "$.slots[0].value.value", Snips_Intent.state.toString)

logInfo("snips.rule", "intent: " + snipsIntent)
logInfo("snips.rule", "raw value: " + snipsSlot1RawValue)
logInfo("snips.rule", "slot: " + snipsSlot1Value)


but when I use 2 slot I am not able to grab the content…

So I have added:
var String snipsSlot2Value = transform(“JSONPATH”, “$.slots[1].value.value”, Snips_Intent.state.toString)

but doesn’t work… any suggestion?

I am also trying to control a chromecast stream with snips but I am only able to pause it!

in .item:
Player Music (gAudio) { channel=“chromecast:audiogroup:c2bad9e1-5203-421c-b7b3-7051b8d25681:control” }

in .rules:
if (snipsIntent == ‘pause’) {

how can i send a webstream instead?!

Thank you everybody!

Hey, great to hear. Could you post the JSON that you get via MQTT?

As an example I show you one of my rules:

rule "Device ON"
    Item SnipsIntentDeviceOn received update
    var intent = transform("JSONPATH", "$.intent.intentName", SnipsIntentDeviceOn.state.toString)
    logInfo("rule device on", "Intent : " + intent.toString)  

    var confidence = transform("JSONPATH", "$.intent.confidenceScore", SnipsIntentDeviceOn.state.toString)
    logInfo("rule device on", "confidence : " + confidence.toString)  

    if (Double::parseDouble(confidence) > 0.7) {

        var siteId = transform("JSONPATH", "$.siteId", SnipsIntentDeviceOn.state.toString)
        logInfo("rule device on", "siteId : " + siteId.toString)  

        var sessionId = transform("JSONPATH", "$.sessionId", SnipsIntentDeviceOn.state.toString)
        logInfo("rule device on", "sessionId : " + sessionId.toString)  

        var slotDevice = transform("JSONPATH", "$.slots.[0].value.value", SnipsIntentDeviceOn.state.toString)
        logInfo("rule device on", "slotDevice : " + slotDevice)

        var slotRoom = transform("JSONPATH", "$.slots.[1].value.value", SnipsIntentDeviceOn.state.toString)
        logInfo("rule device on", "slotRoom : " + slotRoom)

    val testItem = ScriptServiceUtil.getItemRegistry.getItem(slotDevice)



This rule is connected to my “Device on” intent within Snips. This intent consists of two slots:

  1. The device that I want to turn on
  2. The room in which the device is located (optional)

thank you, I’ll try your configuration soon!
I can’t understand the last part:

val testItem = ScriptServiceUtil.getItemRegistry.getItem(slotDevice)


anyway in my configuration I receive this json string:

{“sessionId”:“f71e9d3f-100d-496c-ad15-602448dcc8b6”,“customData”:null,“siteId”:“default”,“input”:“accendi la luce in sala”,“asrTokens”:[[{“value”:“accendi”,“confidence”:1.0,“rangeStart”:0,“rangeEnd”:7,“time”:{“start”:0.0,“end”:0.26999998}},{“value”:“la”,“confidence”:0.98170763,“rangeStart”:8,“rangeEnd”:10,“time”:{“start”:0.26999998,“end”:0.5056098}},{“value”:“luce”,“confidence”:1.0,“rangeStart”:11,“rangeEnd”:15,“time”:{“start”:0.5056098,“end”:0.75}},{“value”:“in”,“confidence”:1.0,“rangeStart”:16,“rangeEnd”:18,“time”:{“start”:0.75,“end”:0.75}},{“value”:“sala”,“confidence”:0.9643355,“rangeStart”:19,“rangeEnd”:23,“time”:{“start”:0.75320977,“end”:0.94279736}}]],“asrConfidence”:0.9891042,“intent”:{“intentName”:“dntr:TurnOn”,“confidenceScore”:0.7114572},“slots”:[{“rawValue”:“luce”,“value”:{“kind”:“Custom”,“value”:“luce”},“range”:{“start”:11,“end”:15},“entity”:“snips/default–house_device”,“slotName”:“house_device”,“confidenceScore”:1.0},{“rawValue”:“sala”,“value”:{“kind”:“Custom”,“value”:“sala”},“range”:{“start”:19,“end”:23},“entity”:“house_room”,“slotName”:“house_room”,“confidenceScore”:0.9643355}]}

I use one slot for house_device and one for house_room, now I will play with the code! will let you know! :slight_smile:

This grabs the item that you want to do something out of the item registry and sends a command to it. So in your example it will send the command “ON” to your item “luce”.