washcroft / homebridge-http-garagedoorcontroller

An HTTP based Garage Door/Light plugin for HomeBridge
MIT License
15 stars 7 forks source link

Request. #1

Closed 0xfgarcia closed 7 years ago

0xfgarcia commented 7 years ago

Hi, good job!

I have a z-wave gateway with the following response:

HTTP/1.1 202 Accepted Date: Mon, 10 Apr 2017 14:41:50 GMT Server: 0.9 Cache-Control: no-cache, no-store, must-revalidate, max-age=0, max-age:0 Content-Type: application/json;charset=UTF-8 Pragma: no-cache Expires: Fri, 01 Jan 2010 00:00:00 GMT Connection: close Transfer-Encoding: chunked

{"id":0,"jsonrpc":"2.0","result":{"result":0}}

How can i parse this with your plugin for work ¿? Homebridge return:

ERROR in setDoorTargetState() - The JSON body of the HTTP response could not be parsed: Unexpected end of JSON input

Thanks!.

washcroft commented 7 years ago

That means the JSON cannot be parsed, but the response you included as an example does appear to be valid.

Try editing the module to write the response body to the log/output: \usr\lib\node_modules\homebridge-http-garagedoorcontroller\index.js

Before:

json = JSON.parse(body);

Add:

that.log.error(body);

Restart homebridge, open/close the door. Does the output match the JSON payload in your example?