404 on home assistants /api/intent/handle

Hi there,

I am trying to setup the home assistant integration, but when I use the
Send **intents** to Home Assistant (/api/intents) option under Settings -> Intent Handling, and I test a sentence under the Speech tab, I get the error:
404 Client Error: Not Found for url: https://path.to.homeassistant:8123/api/intent/handle

When I use the event option, all works fine. I want to use the intent option though because I want HA to respond with some text and I can not find any documentation how to do that with events.

This is the intent_script configuration from HA:

intent_script:
  Test:
    speech:
      text: Hi there from Hass IO
    action:
      service: notify.notifier_telegram
      data_template:
        message: Hello from an intent!

I believe that the HA part is correct but I don’t know how to verify that.

The reason I think it fails on the Rhasspy side, is that the link under the intent option in the settings page to the HA intent integration is dead.

I have Rhasspy running on a RPI 3 in docker.
Hassio is running on a separate ubuntu server also in Docker

I hope someone can help me with having HA responding back to Rhasspy.
Thanks in advance.

-Peter

Hi Peter,
I haven’t managed to make intent works, but here is how I did it with events

In HA add rest_command: !include rest_commands.yaml to your configuration.yaml
Create rest_commands.yaml file and add there the following:

rhasspy_speak:
  url: 'http://***RhasspyIP***/api/text-to-speech'
  method: 'POST'
  payload: '{{payload}}'
  content_type: text/plain

In HA, check config and reboot HA

Now you should have service rest_command.rhasspy_speak

And you can use in automation like this

action:
- data:
  payload: Hello world
  service: rest_command.rhasspy_speak
3 Likes

Hi @petergoes, I may have been a bit premature in adding that feature to Rhasspy. Home Assistant has support for /api/intent/handle in the latest development branch, but it hasn’t been officially released yet.

You can take the approach @frkos suggests using events, or you can sneak your intents in the back door by enabling MQTT and the enabling the snips integration. You shouldn’t actually need to install Snips; the HA integration should pick up the MQTT messages from Rhasspy if you have MQTT enabled in both places (HA and Rhasspy), and connect them to the same broker.

I’m eagerly awaiting the next release of HA so we can finally have native intent handling without such hacks :slight_smile:

3 Likes

Thank you both for such a quick reply!
Tonight I will give the event suggestion a try.

Thanks again!

Thanks again @frkos and @synesthesiam! The rest_command option works awesome.

@synesthesiam any idea which version of HA will include the intent functionality and when they expect it to land in stable?

Does the version 0.104.1 include the new api?

I can confirm it works with version 0.104.2

Hi @adrianofoschi
Just for my understanding, what are the benefits of using intents instead of events? :no_mouth:

@adrianofoschi Can you share your configuration.yaml? I am running 0.104.2 but I still get the 404 error

Imho simply the intent is the natural way to handle a voice assistant command in home-assistant :slight_smile:

1 Like

Sure you can find my configurations on github:

The interesting part for you is:

intent_script: !include intents.yaml
intent:

1 Like

@adrianofoschi Thanks! I needed the extra intent:. That did the trick. Works like a charme

1 Like

@petergoes you’re welcome!
@synesthesiam we should update the doc :slight_smile:

1 Like

btw… there’s absolutely NO mention about intent: in the hass doc :stuck_out_tongue: i just got the intent thing working without errors and now i need asststisnt to make it work :stuck_out_tongue:

2 Likes

So I’m on HA core 0.107.4 and still see 404 errors from Rhasspy:

[ERROR:2020-04-08 13:50:35,458] rhasspyhomeassistant_hermes: handle_home_assistant_intent
Traceback (most recent call last):
  File "/usr/lib/rhasspy-voltron/rhasspy-homeassistant-hermes/rhasspyhomeassistant_hermes/__init__.py", line 162, in handle_home_assistant_intent
    response.raise_for_status()
  File "/usr/lib/rhasspy-voltron/.venv/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://192.168.1.4:8123/api/intent/handle')
[ERROR:2020-04-08 13:50:35,594] rhasspyhomeassistant_hermes: handle_intent
Traceback (most recent call last):
  File "/usr/lib/rhasspy-voltron/rhasspy-homeassistant-hermes/rhasspyhomeassistant_hermes/__init__.py", line 89, in handle_intent
    assert response_dict, f"No response from {self.url}"
AssertionError: No response from https://192.168.1.4:8123

Intents are working, but Rhasspy 2.5-pre still generates that message. Has the intent code made it into HA yet or is it still in dev only?

Also, if I include a speech: directive as with the Snips integration, should I be expecting Rhasspy to speak back to me at this point, or not yet?

The code is there to pick up the speech response and forward it to the TTS. Hope it’s working.

Yep, it’s working great. Thanks @synesthesiam!

1 Like

Hey!
I know this is an old topic, but I have the exact same error message on the current version. Did you do anything to solve this issue?

I’m getting a 401 error using “Home Assistant” Intent Handling on my satellite, with HASS URL of http://192.168.1.98:8123/ and Send intents selected.

I guess 401 is better than a 404, at least :wink:

[DEBUG:2021-05-09 19:02:58,596] rhasspyhomeassistant_hermes: http://192.168.1.98:8123/api/intent/handle
[ERROR:2021-05-09 19:02:58,710] rhasspyhomeassistant_hermes: handle_home_assistant_intent
Traceback (most recent call last):
  File "/usr/lib/rhasspy/rhasspy-homeassistant-hermes/rhasspyhomeassistant_hermes/__init__.py", line 169, in handle_home_assistant_intent
    response.raise_for_status()
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    headers=self.headers,
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('http://192.168.1.98:8123/api/intent/handle')
[ERROR:2021-05-09 19:02:58,717] rhasspyhomeassistant_hermes: handle_intent
Traceback (most recent call last):
  File "/usr/lib/rhasspy/rhasspy-homeassistant-hermes/rhasspyhomeassistant_hermes/__init__.py", line 88, in handle_intent
    assert response_dict, f"No response from {self.url}"
AssertionError: No response from http://192.168.1.98:8123/
[ERROR:2021-05-09 19:03:24,620] rhasspydialogue_hermes: Session timed out for site rem1: rem1-porcupine_raspberry-pi-031df962-346d-4560-97ee-4f4e5ce99a12
[DEBUG:2021-05-09 19:03:24,624] rhasspydialogue_hermes: -> AsrStopListening(site_id='rem1', session_id='rem1-porcupine_raspberry-pi-031df962-346d-4560-97ee-4f4e5ce99a12')
[DEBUG:2021-05-09 19:03:24,625] rhasspydialogue_hermes: Publishing 99 bytes(s) to hermes/asr/stopListening```

My satellite is a RasPi 3B running a fresh install of Raspberry Pi OS desktop and Rhasspy with a ReSpeaker 4-mic HAT. Being fairly new to all this I am trying to avoid installing lots of other things (like docker or venv) I don't understand and will increase the opportunities for failure. 
My base HA server is a RasPi4 running Home Assistant OS with Rhasspy Add-on.  When i say a voice command to the satelite, the base's Rhasspy home page is regognising and showing it - but not actioning it.

Do you have a token set?