Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yi Cameras - curl commands works but not netcat #2

Open
jcconnell opened this issue May 12, 2019 · 0 comments
Open

Yi Cameras - curl commands works but not netcat #2

jcconnell opened this issue May 12, 2019 · 0 comments

Comments

@jcconnell
Copy link

jcconnell commented May 12, 2019

I'm getting the following output from Netcat on the Yi camera:

# echo -ne $head | nc -i 5 local-hass-ip 8123
HTTP/1.0 400 Bad Request
Content-Type: application/json
Content-Length: 41
Date: Sun, 12 May 2019 22:50:12 GMT
Server: Python/3.6 aiohttp/3.5.4

{"message": "Data should be valid JSON."}#

This curl command works from my Mac:
curl --trace-ascii - -0 var=val -X POST -H "x-ha-access: password-example" -H "Content-Type: application/json" -d '{"payload": "{\"camera\":\"living room\",\"date\":\"02-16-2018\",\"time\":\"20:13\"}", "topic": "homeassistant/motion", "qos": 0, "retain": 0}' https://example/api/services/mqtt/publish

I'm executing these commands on the Yi from a telnet session:

body='{"payload": "{"camera":"living room","date":"02/26/18","time":"2:00pm"}", "topic": "homeassistant-motion", "qos": 0, "retain": 0}'
body_len=$(echo -n "$body" | wc -c)
head="POST /api/services/mqtt/publish HTTP/1.0\r\nHost: example.com\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\nx-ha-access: example-password\r\nContent-Type: application/json\r\nContent-Length: ${body_len}\r\n\r\n${body}"
echo -ne $head | nc -i 5 local-hass-ip 8123

Any idea what the issue might be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant