How to build a working german profile with hass.io on a Raspberry Pi 3B+

Basically hassos is the supervisor that automatically starts and maintains quite a few docker containers for hass. One of them is a sound container and that one started hogging the audio devices after an update around 2 months ago. So basically rhasspy running on the same pi always reported that the audio device is busy. There are workarounds to that and apparently some seem to work long term for most ppl but I tried and tried but it always undid my workaround. There is a addon for hassos that is supposed to undo the change in the audio container but even that one stopped working for me after around a week and rhasspy did not get any input.

If you use two physical devices for rhasspy and hassos then you should be fine, but on the same device it might be a bit of a problem.

Here is the thread I first talked about that issue with the sound, it also contains the link to the github issue where you can find the workarounds and the link to the addon.

Thank you for the explanation, @Daenara :slight_smile:
I think I will try it with two separate Pis for the first try and report about the results.

Thanks for waiting, @Daenara.

I set up HassOS on a second Pi (just booted it and made a HA account that is logged in).
For connecting to Rhasspy, I did the following:

After that, I saved the settings, restarted Rhasspy, trained it, went to the home screen, checked the box for handling behind the recognize field and asked for the time. Rhasspy recognized the intent GetTime, but nothing else happened. It might be a complete beginner question, but this is the point, where Rhasspy should tell me the time, isn’t it?

Do I need to set some things in HA to get intents from Rhasspy working?
Are my Rhasspy setting for intent handling faulty?
I thought the access token is filled in automatically (like described), but it wasn’t. Do I have to enter something?

EDIT:
I found the point in HA settings where you can create long-lived access tokens and created one. I copied it and pasted it in the token field in Rhasspy’s HA settings. After restarting and training, nothing changed.

You need to actually configure hass to do something when the intent is detected but I never got that far because I keep getting distracted by other things. Basically rhasspy sends a json to hass when you set it up correctly but hass needs to know what to do with the intent and send an answer back. I think there is an intent component for hass (I used it with snips ages ago) that you can use to set interaction up but you might just need to read the documentation on it.

I read the HA docs about intents but I’m not sure what to do with the given information. There are some code samples but I could not find out where they have to be stored inside HA’s file system and what to do, to get them working.

Last point of the intent docs are HA’s built-in intents. I wanted to try HassShoppingListAddItem and HassShoppingListLastItems, so I set up some sentences in Rhasspy:

grafik

When trying them out (with handle check box active), Rhasspy recognizes the right intent and item (see picture below), but I get no response. I tried sending events to HA and sending intents to HA.

grafik

How are you using HA and what for, @Daenara? Are you getting responses of your voice assistant?
I think I understood something wrong in how Rhasspy and HA work together. Would be great, if I could get an explanation on that.

Perhaps @synesthesiam or @ulno can tell me how to get one of the pre-set sentences / intents in Rhasspy to work as expected. A big goal would be, to get Rhasspy to tell me the time after recognizing the GetTime intent. Is HA even needed for this? I was trying to get it working after reading the Rhasspy docs on intent handling, but had no success.

As I tried telling you in my last post, my rhasspy and homeassistant don’t work together yet. I use homeassistant via the app and rhasspy just for testing so far.

For the shopping list. Did you install/activate the shopping list in homeassistant? Before you try to control it with rhasspy always make sure it works from homeassistant itself.

As for the intents. They go in configuration.yaml like every other bit of homeassistant configuration.

My homeassistant is used to control my media center as well as a few lamps and the ceiling fan,but like I said, no voice activation yet because I keep getting distracted by other projects.

I’m sorry, I misunderstood.

I could not find out yet, how to activate the ShoppingList intents in HA. I thought they were a good choice for a test and might work without an activation, because they are built-in. At the moment, my main goal is to connect Rhasspy to voice control a simple intent in HA. Sadly, I don’t own any smart plugs or something similar yet, so I need to test it with an intent, that gives me a respond with an information like the current time or my shopping list items. Any hints and help on this are much appreciated.

I found this tutorial on how to set up Rhasspy and connect it to HA:

Because I got a running Rhasspy Setup, I started with the point “Hass Integration”. I created an access token and filled the Rhasspy Settings for intent handling with HA with the local Hass URL, the token and the password of my user account on my HassOS (second Pi) (see picture below).

After that, I tested if the HA API is running with Windows console and the following command:

curl -X GET -H "Authorization: Bearer MY_CENSORED_ACCESS_TOKEN" -H "Content-Type: application/json" http://homeassistant.local:8123/api/

It returned:

{"message": "API running."}

That’s why I went to the next step of the tutorial. I opened the Web UI of my HassOS, went to:
Developer Tools > Events > Listen to events
and started listening for “rhasspy_GetTime” (see picture below) as shown in the tutorial.

Now, if I ask my Rhasspy voice assistant for the time, HA should show me some output telling me it detected “rhasspy_GetTime”. Sadly, nothing happened.

Did I set up something wrong?
What could be the next step in trying to fix this?

I found out, that my local network does not send events from Rhasspy to HA, if Hass URL is http://homeassistant.local:8123. After changing it to the full IP of my HA, I was able to “listen” for rhasspy_GetTime and and see the incoming information. I was also able to set up a small test automation, that should send an example text back to Rhasspy’s text-to-speech API. Now, when I ask Rhasspy for the time, I can see, that the test automation gets triggered in HA.

Sadly, I can’t get the part of sending text to Rhasspy to work…

Following the tutorial mentioned above, I added rest_command to my configuration.yaml in HA, so it looks like this:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

rest_command:
  tts:
    url: http://localhost:12101/api/text-to-speech
    method: POST
    payload: ''

After that, I was trying, to send a test message to Rhasspy (via developer tools > services):

grafik

Sadly, I had no luck. I also tried using payload: "hallo" instead of message: "hallo" and using the full IP of my Rhasspy in the configuration.yaml.

Could anyone please describe, how he or she POSTs messages to the text-to-speech API of Rhasspy?
I saw, that @romkabouter is actively using HA with Rhasspy in a video post. Would you please describe, how you do this, Paul?

Sure, my rest command looks like this:

rest_command:
  rhasspy_speak:
    url: 'http://192.168.43.54:12101/api/text-to-speech'
    method: 'POST'
    payload: '{{ payload }}' 
    content_type: text/plain

So a little different that yours, check payload and an extra content_type setting.
Also, the IP address is the IP from Rhasspy, most probably localhost is incorrect.

To call this rest_command, I have an automation listening to the event:

- id: '1581372525473'
  alias: EventLampen
  trigger:
  - event_data: {}
    event_type: rhasspy_Lights
    platform: event
  condition: []
  action:
  - data_template:
      payload: OK, {{ trigger.event.data.location }} {% if trigger.event.data.action
        == "on" %}aan{% else %}uit{%  endif %}
    service: rest_command.rhasspy_speak
  - data_template:
      entity_id: light.{{ trigger.event.data.location }}
    service_template: light.turn_{{ trigger.event.data.action }}

The service rest_command.rhasspy_speak is the one to use.

I think your test call should work as well, with

payload: hello

There is no need for quotes.
When you do not hear anything, this might also be a problem in your Rhasspy config.

1 Like

Thank you so much, @romkabouter. It worked like a charm :smiley:

I was finally able to get the full circle working (with german profile):
wake word > STT > intent recognition > passing the event to HA > Handling the event in HA > passing text to Rhasspy > TTS

Because a lot of people helped me on the way to get this working, this is a summary, that I will mark as solution. Massive thanks go out to the following community members:
@fastjack, @geoffrey, @Jorg_Baumann, @Daenara, @ulno and @romkabouter

This is my working setup:

Hardware:

  • Raspberry Pi 3B+ with Matrix Voice as microphone and cheap speaker connected over audio jack of the Pi (Rhasspy in Docker container on Raspbian Buster, Raspbian audio default set to analog, connected via WiFi)
  • Raspberry Pi 3B (HassOS, connected via WiFi)

Rhasspy Settings:


Home Assistant Settings:

  • add rest_command to configuration.yaml (for example via file editor addon in WebUI):

    rest_command:
      rhasspy_speak:
        url: 'http://ip.of.your.rhasspy:12101/api/text-to-speech'
        method: 'POST'
        payload: '{{ payload }}' 
        content_type: text/plain
    
  • create automation, that listens for event rhasspy_IntentName (for example: rhasspy_GetTime) and starts service rest_command.rhasspy_speak with specific payload (for example: payload: hello)

EDIT: If you want to use a payload with templates to include data like the current time, you need to change data: in your HA automation’s action to data_template:. This is only possible by clicking on the three dots symbol and choosing “edit as YAML” while working on your automation via WebUI or by editing automations.yaml file. Here is an example for sending the current time to Rhasspy (german format):

  data_template:
    payload: 'es ist {{ now().hour }} uhr {{ now().minute }}'
  service: rest_command.rhasspy_speak

I hope this will help someone as much as it helped me.

RaspiManu

4 Likes