From A to Snips - HA on Hass.io + external Snips guide

Cool to hear that! I got two satellites running now and one base and I am really happy with it. Wife loves it, too!

Always planned to share some of my intent scripts and the app but it’s all a mess and needs cleanup, don’t find time for that right now.

Viele Grüße :slight_smile:

Just to finish this thread off :frowning:

I switched to rhasspy: :slight_smile:


http://rhasspy.readthedocs.io/

Installation and configuration is very easy and after playing around for a few days, I find it even better than Snips as it is easier to manage but still easier to individualise, performance is the same or better.

Posting my experiences and setups in the rhasspy forum for those who are interested.

In case someone is unsure about it: you still need to add snips: to your configuration.yaml
Without it you dont get any answers from rhasspy.

This is not completely true, only if you want to use rhasppys direct HA integration (Intent Handling → Home Assistant) in rhasspy.

If you select “Remote HTTP” because you are doing your automations with Node-RED, the snips: is not necessary in configuration.yaml.

No you don’t.

You can use this (both)

intent:
intent_script:

In intent script you can create intents, also with text responses.
Check here for examples https://community.rhasspy.org/

1 Like

I am new to this. Thought i dont need it anymore for all this snips is dead info. You never know if an example may be outdated for this.
In my case rhasspy (base / sat setup on hassio) didnt say any word without snips: using this rest command

rhasspy_speak:
  url: 'http://192.168.1.222:12101/api/text-to-speech?siteId={{ siteid }}'
  method: 'POST'
  content_type: text/plain
  payload: '{{payload}}'

and this intent

GetTime:
  speech:
    text: '{{ now().strftime("%H uhr %M") }}'
  action:
    service: notify.notify
    data:
      message: "say time"

is there an better/new way for doing it?

Currently im trying to consume a product from grocy but there are too much things to learn at once. Are automations better then intents? Should i learn node red rather then using HA intents?

I am using Node-Red for my automations. I set rhasspy to Remote HTTP and put a webhook in Node-Red and handle my intents there. So I dont need snips: or intent:and dont really know the best way to handle it in HA. Were using intent scripts back then when I was using Snips but I never liked YAML scripts for automations so much because they lack the possibility to create real loops and always come to limits for more complex stuff. So I moved mostofmy automation stuff to Node-Red.

Can you clarify what you mean by “real loops”? The ability to “loop” was introduced a year ago in version 0.113 (13 versions ago) using the repeat action.

snips seems to be a dead project after it get aquired by Sonos?

Yes, because you do not end the Rhasspy session that way
Something like this should work:

intent:
intent_script:
  GetTime:
    action:
      - service: mqtt.publish
        data:
          payload_template: '{"sessionId": "{{_intent.sessionId}}", "text": "{{ now().strftime("%H uhr %M") }}"}'
          topic: hermes/dialogueManager/endSession

However, I personally use events and not intents.
They can be used in automations more easily and you do not have to restart HA every time you change or add an intent.

This is an automation example for lights (dutch)

- id: '1581372525473'
  alias: EventLampen
  trigger:
  - event_data: {}
    event_type: rhasspy_Lights
    platform: event
  condition: []
  action:
  - data_template:
      entity_id: light.{{ trigger.event.data.location }}
    service_template: light.turn_{{ trigger.event.data.action }}
  - service: mqtt.publish
    data:
      topic: hermes/dialogueManager/endSession
      payload_template: '{"sessionId": "{{trigger.event.data._intent.sessionId}}",
        "text": "Okee, {{ trigger.event.data.location }} {% if trigger.event.data.action
        == "on" %}aan{% else %}uit{%  endif %}"}'
  mode: single

If i ask the time, it blinks in several modes, then it blinks waiting for answer and after speaking it the light is immediately off. But i do not know much about it.

Maybe something else is wrong. In rhasspy settings / intent handling i always have an red [save and restart] button.
Do i need snips because its not working like expected?
No matter if i select send events or send intents, always happening the same.
In both cases my getTime and similar intents are working and notification defined in intent is sent.

In case of grocyConsume at least the notification is send. No notification and no speech and i get an Error rendering data template: UndefinedError: 'sensor' is undefined
how can i access this sensor? If i put the text in develeper tools/template it is working.
without the action part it answers, but i want to consume this item :-).

grocyConsume:
  speech:
    text: '{{ count }} {{ unit }} {{ item }} wird ausgetragen'
  action:
    - service: notify.notify
      data:
        message: >
          {%- if state_attr(sensor.grocy_stock.products) is iterable -%}
            {%- for product in state_attr('sensor.grocy_stock.products') -%}
              {%- if product.name == item %}
                {{product.id | int}}
              {% endif -%}
            {%- endfor %}"  - {{count | int}} {{product.name}} verbraucht"
          {% else -%}
            in Grocy ist {{item}} nicht vorhanden
          {% endif -%}

Trying to use an automation created from the interface with no real data i get an error about an value not being an string (explicitely changed it in yaml to product_id: 32 but it always changed back to product_id: '32'
Currently i am out of ideas. The plan was to read the id of a named product from the grocy stock sensor and use service: grocy.consume_product_from_stock
Btw, have i to use service or - service?

Enclose the entity_id in quotes.

{%- if state_attr('sensor.grocy_stock.products') is iterable -%}

Without the quotes, it’s handled like a variable name (and since that variable doesn’t actually exist, it causes the “UndefinedError” message).

In addition, that entity_id doesn’t appear to be valid. It can only have one period in it for separating the entity’s domain from its object_id. Your entity_id contains two periods and the second one is not something Home Assistant normally allows.

sensor.grocy_stock.products
      ^           ^
      |           |
This is OK        |
                  |
This is not normally permitted here.

changed it back, now i again get
Error rendering data template: UndefinedError: 'product' is undefined

grocyConsume:
  speech:
    text: '{{ count }} {{ unit }} {{ product }} wird ausgetragen'
  action:
    service: notify.notify
    data:
      message: >
        {% for product in state_attr('sensor.grocy_stock', 'products') -%}
          {%- if product.name == item %}
            {{product.id | int}}
          {% endif -%}
        {%- endfor %}"  - {{count | int}} {{product.name}} verbraucht"

sensorgrocy_stock looks like

products:
  - name: Milch
    id: 3
    ...

What is “it” in this situation? What light are you talking about?

Maybe, but you need to provide details if you want some help

No, you do NOT need snips. Not ever.

So let’s start from the start and start small:
Tell us about your setup: hardware and software.
Is HA running on a Pi? And how are you running Rhasspy?
First focus on the getTime intent, is the the simplest one. If you do not understand how all this works together, there is no way to get complicated stuff working.

Can you post your configuration.yaml with the intent_script?

  • hass.io in an vm on OpenMediaVault with addons grocy + mosqitto + rhasspy (base), no mics, no speakers
  • pi 3b with respeaker 2 mic hut, Raspberry Pi OS Lite with reseaker driver, mosquitto and docker with rhasspy (sat)

First focus on the getTime intent,

rhasspy is telling me the time and temperature and i get an answer (in mixed language) if i try to use inbuild intent HassTurnOn.

Can you post your configuration.yaml with the intent_script?

from configuration.yaml

rest_command: !include rest-commands.yaml 
snips:
intent:
intent_script: !include intent_scripts.yaml

from intent_scripts.yaml

GetTime:
  speech:
    text: '{{ now().strftime("%H uhr %M") }}'
  action:
    service: notify.notify
    data:
      message: "say Zeit"

GetTemperature:
  speech:
    text: "{{state_attr('weather.dwd_weather_xxx_2', 'temperature') | round(0) }} grat"
  action:
    service: notify.notify
    data:
      message: "say Temperatur"

GetDate:
  speech:
    text: '{{now().strftime("%A")}} der {{ now().day }}.' (mixed language speech)
  action:
    service: notify.notify
    data:
      message: "say Datum"

grocyConsume:
  speech:
    text: '{{ count }} {{ unit }} {{ product }} wird ausgetragen'
  action:
    service: notify.notify
    data:
      message: >
        {% for product in state_attr('sensor.grocy_stock', 'products') -%}
          {%- if product.name == item %}
            {{product.id | int}}
          {% endif -%}
        {%- endfor %}"  - {{count | int}} {{product.name}} verbraucht"

You can remove snips and change the intent script like my example to get the TTS answer from Rhasspy.
If you use snips and the speech, you will not use Rhasspy but the Home Assistant TTS. No problem, but you should be aware.

So what you say is the above intents all work and the only problem is the grocery list? Is that correct?

So what you say is the above intents all work and the only problem is the grocery list?
yes.

Your script dont say anything. Is the site id missing?

I dont know how to configure hassio for speaking. Using my methode rhasspy speaks with the voice configured in rhasspy.

Yes, but you are not ending a session. (dialogue)

That is not needed, because the session knows which siteID it is.

How do you call the rhasspy_speak with your intents?

i have no idea, it works since i addded snips, so probably snips send an mqtt message and rhasspy speaks without rhasspy_speak.
I