sgaluf
(sasa)
July 6, 2019, 5:32am
1
I have Snips running along HA. When I talk to Snips, he publishes the slot over various topics, e.g.
topic: ‘hermes/intent/greetings’
topic: ‘hermes/intent/musicplayer’
topic: ‘hermes/intent/calendar’
topic: ‘hermes/intent/volume’
etc. I made the following automations, which is triggered every time I speak to Snips
- alias: snips_mqtt
trigger:
platform: mqtt
topic: 'hermes/intent/#'
action:
service: persistent_notification.create
data:
message: "Your message goes here"
title: "Snips"
How can I capture the topic and the slot values?
tom_l
July 6, 2019, 5:43am
2
A complete guess (probably won’t work):
{{ trigger.to_state.state_topic }}
sgaluf
(sasa)
July 8, 2019, 4:32pm
3
Unfortunately doesn’t work.
123
(Taras)
July 8, 2019, 5:16pm
4
According to the documentation for MQTT template variables :
{{ trigger.topic }}
{{ trigger.payload }}
sgaluf
(sasa)
July 12, 2019, 6:38pm
5
Thanks, this is working now. When I speak to Snips, something like this comes as payload:
{"sessionId":"92ae64c2-be5b-4e90-8e8d-2f6997277737",
"customData":null,
"siteId":"default",
"input":"are you happy",
"asrTokens":[[{"value":"are","confidence":1.0,"rangeStart":0,"rangeEnd":3,"time":{"start":0.0,"end":0.42}},{"value":"you","confidence":1.0,"rangeStart":4,"rangeEnd":7,"time":{"start":0.42,"end":0.59999996}},{"value":"happy","confidence":1.0,"rangeStart":8,"rangeEnd":13,"time":{"start":0.59999996,"end":1.68}}]],
"asrConfidence":1.0,"intent":{"intentName":"feeling","confidenceScore":1.0},
"slots":[{"rawValue":"happy","value":{"kind":"Custom","value":"happy"},"range":{"start":8,"end":13},
"entity":"state","slotName":"feeling","confidenceScore":1.0}]}
How can I parse the captured voice command, e.g. “are you happy”
123
(Taras)
July 12, 2019, 7:12pm
6
{{ trigger.payload.input }}
sgaluf
(sasa)
July 12, 2019, 8:05pm
7
Unfortunately it doesn’t work, the notification message is now empty:
- alias: snips_mqtt
trigger:
platform: mqtt
topic: 'hermes/intent/#'
action:
service: persistent_notification.create
data_template:
title: "{{ trigger.topic }}"
message: "{{ trigger.payload.input }}"
123
(Taras)
July 12, 2019, 8:13pm
8
My mistake. It’s should be this:
data_template:
title: "{{ trigger.topic }}"
message: "{{ trigger.payload_json.input }}"
sgaluf
(sasa)
July 12, 2019, 8:50pm
9
yes yes, it’s working now. I’ve also trimmed the topic, so that the notification title doesn’t begin with “hermes/intent/…”
- alias: snips_mqtt
trigger:
platform: mqtt
topic: 'hermes/intent/#'
action:
- service: persistent_notification.create
data_template:
title: "{{ trigger.topic[19:] }}"
message: "{{ trigger.payload_json.input }}"