REST API testing

Hi,
I’d like to quickly test if my HASS.IO installation can send POST commands to a REST API. Any ideas how to quickly do that? Using postman or is there an open API i can just check if the commands arrive or if my configuration is wrong?

Ultimately I’d like to make my Rahsspy TTS system talk, and while sending a command to it with postman works, I cannot get it to speak via an Hass.io Service.

This is what I entered in my configuration.yaml. Triggering the service in the developer tab does not have any effect. Maybe it is as simple as having the wrong syntax or quotation marks in place?


rest_command:
  rhasspy_speak:
    method: POST
    url: '192.168.0.28:12101/api/text-to-speech'
    content_type: 'text/plain'
    payload: 'hello world'
1 Like

You could send it to HA’s own REST API. E.g., you could fire an event in HA using this POST or call a HA service using this POST.

Hi Phil, thanks I have also found these pages, but I am afraid I am too little technical to understand all it takes. For example I have copied now this into my configuration.yaml, but nothing happens:

turn_light_on:
  url: http://localhost:8123/api/states/light.study_light
  method: POST
  headers: 
    authorization: 'Bearer ABCDEFGH'
    content-type: 'application/json'
  payload: '{"state":"on"}'

That just changes the representation of the light in the State Machine. It doesn’t actually turn on the light. For that you’d need to use:

turn_light_on:
  url: http://localhost:8123/api/services/light/turn_on
  method: POST
  headers: 
    authorization: 'Bearer ABCDEFGH'
    content-type: 'application/json'
  payload: '{"entity_id": "light.study_light"}'
1 Like

Never mind, I fixed it. Was indeed just a simple mistake, forgotten the http:// (because it is not needed in postman).

The working code is

rest_command:
  rhasspy_speak:
    url: http://192.168.0.28:12101/api/text-to-speech
    method: POST
    headers:
      content_type: 'text/plain'
    payload: 'hello world'

and for the final with dynamic texts:

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

and then I can just call the service “rest_command.rhasspy_speak” and give it the parameters:

payload: 'it works'
1 Like