robertklep / homebridge-nefit-easy

DEPRECATED — Homebridge plugin for Nefit Easy™
14 stars 3 forks source link

SyntaxError: Unexpected token #18

Closed GuitarHer01 closed 5 years ago

GuitarHer01 commented 5 years ago

Hello Robert,

When I run Homebridge and start the Homekit on an IOS device, the plugin crashes at "Getting current state"

[2019-1-25 20:40:42] Homebridge is running on port 51826. [2019-1-25 20:40:44] [thermostaat] Getting current temperature... [2019-1-25 20:40:44] [thermostaat] Getting target temperature... [2019-1-25 20:40:44] [thermostaat] Getting current state.. SyntaxError: Unexpected token ? in JSON at position 0 at JSON.parse (<anonymous>) at pending.(anonymous function).send.then.response (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\nefit-easy-core\lib\index.js:216:30) at tryCatcher (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:512:31) at Promise._settlePromise (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:569:18) at Promise._settlePromise0 (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:694:18) at _drainQueueStep (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:147:5) at Immediate.Async.drainQueues (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5) SyntaxError: Unexpected token ? in JSON at position 0 at JSON.parse (<anonymous>) at pending.(anonymous function).send.then.response (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\nefit-easy-core\lib\index.js:216:30) at tryCatcher (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:512:31) at Promise._settlePromise (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:569:18) at Promise._settlePromise0 (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:694:18) at _drainQueueStep (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:147:5) at Immediate.Async.drainQueues (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5) SyntaxError: Unexpected token ? in JSON at position 0 at JSON.parse (<anonymous>) at pending.(anonymous function).send.then.response (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\nefit-easy-core\lib\index.js:216:30) at tryCatcher (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:512:31) at Promise._settlePromise (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:569:18) at Promise._settlePromise0 (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\promise.js:694:18) at _drainQueueStep (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:147:5) at Immediate.Async.drainQueues (C:\Users\Camera\AppData\Roaming\npm\node_modules\homebridge-nefit-easy\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5)

Below is my config.json. It validates OK. I changed the Serial, Acceskey and Password on this site only to 1234. The real data is the same as I use in the Nefit App and it works OK there. Even tried to change the password, to exclude that as a problem, but the issue still exists.

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" }, "description": "Mijn Huis", "accessories": [ { "accessory": "NefitEasy", "name": "thermostaat", "options": { "serialNumber": "1234", "accessKey": "1234", "password": "1234" } } ] }

Do you have any idea what's the problem here?

Thx in advanced very much for your answer!

robertklep commented 5 years ago

This happens with invalid credentials, either the access key or the password.

If your access key contains hyphens (-), try removing them. There's also a limit to how long your password can be (either 12 or 10 characters, can't remember exactly) and certain "special" characters in a password (like !) can also be problematic.

To do some quick testing (without having to restart Homebridge all the time), you can install the CLI tool which uses the same underlying library.

GuitarHer01 commented 5 years ago

Thanks for your quick reply very much.

The password is 11 characters in length. (Only X,x and 1) The serial contains 9 numbers only. The Accesskey is 16 keys (Only X, x and 1), but I’m not sure if this can be changed. It came with the Nefit Easy.

The format is including the “ at the start and end, so example “password”: “MyPassword1”

In the CLI tool I have the same error, so it's related to the credentials indeed. Can the Accesskey value be changed on Nefit Easy?

robertklep commented 5 years ago

The serial number and access key are fixed, the only thing you can changed is the password. I think you can change it from the mobile app.

In the config.json file for Homebridge, the password should be surrounded by double quotes ("), so that's good. With the CLI tool, they are not necessary but they won't hurt either.

GuitarHer01 commented 5 years ago

Change the password again and used only lowercase. It works now. Thanks for you help!