POST request with dynamic body text from HA to other device

I want to send small pieces of text to a tts capable device. I preferably send the text as body from a POST request. What would be the easiest approach in doing this?

Python script. Then you can actually use requests.post. Unless this isn’t what you mean.

r = requests.post(‘http://httpbin.org/post’, data = {‘key’:‘value’})

Thanx, that probably would have worked as well but I went with https://www.home-assistant.io/components/notify.rest/ . This suits my needs as well.

1 Like

I’m pretty sure rest uses the requests.post, so it’s essentially the same thing. I didn’t even know about the rest component. TIL. There are way too many components to keep in mind!

I tried the python_script way.

> send = requests.post('http://' + ipaddr + ':8090/speaker', data=sendXML)

This is the result:

2019-05-16 21:28:02 ERROR (SyncWorker_19) [homeassistant.components.python_script.bosenotify.py] Error executing script: name ‘requests’ is not defined
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/python_script/init.py”, line 159, in execute
exec(compiled.code, restricted_globals, local)
File “bosenotify.py”, line 14, in
NameError: name ‘requests’ is not defined

i cant “import request” for security reasons. Any hint?