maumi
(Maumi)
1
Hey guys,
I try to use CompreFace over rest in HA.
I have This working curl and want to convert it to a rest_command.
Curl:
curl -X POST "http://192.168.1.121:8000/api/v1/recognition/recognize" -H "Content-Type: multipart/form-data" -H "x-api-key: 67f91561-6a4c-4f87-a36b-xxxxxxx" --form file=@/root/.homeassistant/snapshots/Klingel/4B26FB5C-85E7-415D-9FAB-FA0D8744C4FF.jpeg
What I have so far in HA is:
rest_command:
face_recognition:
url: http://192.168.1.121:8000/api/v1/recognition/recognize
method: POST
headers:
x-api-key: '67f91561-6a4c-4f87-a36b-xxxxxxx'
Content-Type: 'multipart/form-data'
payload: "file=@/root/.homeassistant/snapshots/Klingel/4B26FB5C-85E7-415D-9FAB-FA0D8744C4FF.jpeg"
verify_ssl: false
It is just a first try with hardcoded picture. Later I would change it with a template.
I think my problem is at form-data with the picture.
I would highly appreciate in anyone is willing to help.
koying
(Chris B)
2
I don’t think you’ll manage through a rest_command.
--form file=@
is a way to tell curl to send the file, the actual payload looks like
POST / HTTP/1.1
Host: localhost:8000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __atuvc=34%7C7; permanent=0; _gitlab_session=226ad8a0be43681acf38c2fab9497240; __profilin=p%3Dt; request_method=GET
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 554
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="text"
text default
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain
Content of a.txt.
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html
<!DOCTYPE html><title>Content of a.html.</title>
-----------------------------9051914041544843365972754266--
With binary data base64 encoded, iirc.
You’ll be best with a shell_command
calling curl
in this specific instancE.