szokeptr / homebridge-tradfri-plugin

Ikea Tradfri plugin for Homebridge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled promise rejection - Unexpected token v in JSON at position 0

123rolle opened this issue · comments

I'm getting the following:

Mon, 17 Apr 2017 10:41:01 GMT EventedHTTPServer [::ffff:192.168.0.108] Muting event '3.10' notification for this connection since it originated here.
Mon, 17 Apr 2017 10:41:01 GMT Accessory [Homebridge] Got Characteristic "Saturation" value: 26909
Mon, 17 Apr 2017 10:41:01 GMT EventedHTTPServer [::ffff:192.168.0.108] Muting event '3.12' notification for this connection since it originated here.
(node:6316) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token v in JSON at position 0
(node:6316) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Mon, 17 Apr 2017 10:42:01 GMT EventedHTTPServer [::ffff:192.168.0.108] Client connection closed
Mon, 17 Apr 2017 10:42:01 GMT EventedHTTPServer [::ffff:192.168.0.108] HTTP connection was closed
Mon, 17 Apr 2017 10:42:01 GMT EventedHTTPServer [::ffff:192.168.0.108] HTTP server was closed

Had homebridge-ikea plugin before but uninstalled it. That didn't solve the problem. Then I tried with clean install (new clean ubuntu-image without any additional stuff). Only homebridge and this plugin installed and still the same.

I am using node v.7.9.0 also tried with 6.10.2. Any ideas how to fix it?

I don't really understand where does the HTTP Server logs originate from, especially if you don't have any other plugin installed. Anyway, I will do some more testing, I discovered that from time to time a coap requests fails, probably has something to do with dtls, maybe it is related.

I think those HTTP server logs come from pairing devices. When the pairing is done, HTTP servers are closed. Only the homebridge http-server keeps running. I think that the problem is that some pairing isn't done fully because of:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token v in JSON at position 0.

And I think you're right it might have something to do with the coap request failing. So the bulbs aren't "paired" for HomeKit.

The gateway was blocking and not sending responses because of multiple simultaneous requests fired at the very same moment. I fixed that by grouping those requests into one, the problem should be gone now, let me know if it's so.

Seems to give error :(

Accessory [Homebridge] Error setting Characteristic "Identify" to value true: undefined

can you please attach your config.json and the complete log? I am suspecting that some other plugin is interfering.

Config.json

{
    "bridge": {
        "name": "Homebridge",
        "username": "A1:22:3D:EB:45:B8",
        "port": 51826,
        "pin": "112-99-112"
    },

    "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

    "accessories": [],

    "platforms": [
      {
        "platform": "IkeaTradfri",
        "name": "Tradfri",
        "host": "192.168.0.111",
        "key": "XXXXXXXXXXXXXXXX"
      }
    ]
}

Log:
homebridge_log.txt

Apart from the error message, is the plugin working at all? Do the light(s) show up and can you control them?

... It just started working??? Only thing I changed was the username, but I have changed that on every start.

But before the "Homebridge" was found -> ok -> Bulb was found (gave error on phone screen saying something about "Cannot connect to the device" (tried to take screen shot of it but now I cant.)) -> Ok -> After all the steps were done those bulbs were showing as gray and saying "UPDATING". After updating it gave that JSON parse error.

Maybe you were still using the older version of my plugin. I just published version 1.0.4 then 1.0.5 (just a quick readme update) a couple of minutes ago. Version 1.0.4 was supposed to fix the JSON.parse errors.

Could be that the older package was cached somewhere because that log was taken after I updated to 1.0.4. But thanks for the support! I'll close this thread and reopen if something about this appears again (which doesnt).