aklambeth / bg-hive-api

Hive Active Heating. Node.js API.
MIT License
17 stars 6 forks source link

Parsing of returned data error #2

Closed travellingnashes closed 8 years ago

travellingnashes commented 9 years ago

When running the getstate on a 10 second timer I am getting the following. It would appear that there is no reply and Widget.js tries to parse the response rather than handling the error

SyntaxError: Unexpected end of input at Object.parse (native) at Object.callback (/projects/node_modules/bg-hive-api/Widget.js:49:44) at next (/projects/node_modules/bg-hive-api/node_modules/async/lib/async.js:801:43) at /projects/node_modules/bg-hive-api/node_modules/async/lib/async.js:32:16 at Request._callback (/projects/node_modules/bg-hive-api/Connection.js:63:9) at Request.self.callback (/projects/node_modules/bg-hive-api/node_modules/request/request.js:373:22) at Request.emit (events.js:110:17) at Request. (/projects/node_modules/bg-hive-api/node_modules/request/request.js:1318:14) at Request.emit (events.js:129:20) at IncomingMessage. (/projects/node_modules/bg-hive-api/node_modules/request/request.js:1266:12)

aklambeth commented 9 years ago

I'll see if I can spare some time this week to handle the error, however the problem is the server implements rate limiting therefore I strongly suggest not polling the server more than once every 10 minutes. If you need to get the temperature over a period of time use "GetState(temp.Period.Day)". You could also store the last known state in a common database or filestore which would prevent multiple applications from poll the server and trigging the rate limit.

aklambeth commented 8 years ago

Rate limiting event handler implemented in v1.0.4