I’m trying to trigger a sensor (or input boolean, does not matter that much) from a Win7 machine to HASS.
Got myself a windows Curl version from here and trying to execute (as a test):
curl -v -H "Content-Type: application/json" -X POST -d '{"entity_id":"light.bank_tolomeo_40","brightness":"255"}' http://192.168.1.196:8123/api/services/light/turn_on?api_password=XXXXX
This works perfectly fine via Putty on my HASS RPI however if I execute same on my windows machine I get:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.1.196...
* TCP_NODELAY set
* Connected to 192.168.1.196 (192.168.1.196) port 8123 (#0)
> POST /api/services/light/turn_on?api_password=XXXXXX HTTP/1.1
> Host: 192.168.1.196:8123
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 50
>
* upload completely sent off: 50 out of 50 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/html; charset=utf-8
< Content-Length: 141
< Date: Sun, 11 Jun 2017 02:00:25 GMT
< Server: Python/3.4 aiohttp/2.1.0
< Connection: close
<
<html><head><title>500 Internal Server Error</title></head><body><h1>500 Interna
l Server Error</h1>Server got itself in trouble</body></html>* Closing connectio
n 0
In the HASS logs this generates:
2017-06-11 10:37:35 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/home/hass/.homeassistant/deps/aiohttp/web_protocol.py", line 421, in start
resp = yield from self._request_handler(request)
File "/home/hass/.homeassistant/deps/aiohttp/web.py", line 303, in _handle
resp = yield from handler(request)
File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
res = yield from res
File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
res = yield from res
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
return (yield from handler(request))
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 424, in handle
result = yield from result
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/api.py", line 313, in post
data = json.loads(body) if body else None
File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
Any ideas?