thechrisreese / Homebridge-winkv2

Don’t Install This One
2 stars 1 forks source link

Unexpected end of JSON input #4

Open mousey76397 opened 7 years ago

mousey76397 commented 7 years ago

I get the following error when trying to run the wink platform. SyntaxError: Unexpected end of JSON input at JSON.parse () at IncomingMessage. (/usr/lib/node_modules/homebridge-winkv2/node_modules/wink-jsv2/index.js:69:19) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) raw message /usr/lib/node_modules/homebridge-winkv2/index.js:143 for (var i = 0; i < devices.data.length; i++) { ^

TypeError: Cannot read property 'data' of undefined at /usr/lib/node_modules/homebridge-winkv2/index.js:143:33 at /usr/lib/node_modules/homebridge-winkv2/node_modules/wink-jsv2/index.js:245:9 at IncomingMessage. (/usr/lib/node_modules/homebridge-winkv2/node_modules/wink-jsv2/index.js:76:7) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)

ericrichner commented 7 years ago

Getting this error as well.

thechrisreese commented 7 years ago

Can you all post your redacted config file

ericrichner commented 7 years ago

This is the version that was throwing the issues:

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "031-45-154"
    },
    "platforms": [{
        "platform": "Nest",
        "token": "token_from_nest",
        "clientId": "client_id_from_nest",
        "clientSecret": "client_secret_from_nest",
        "code": "code_for_nest",
        "username": "myemail@email.com",
        "password": "mypassword"
    }, {
        "platform": "HarmonyHub",
        "name": "Harmony Hub"
    }, {
        "platform": "Wink",
        "name": "Wink",
        "username": "myemail@email.com",
        "password": "mypassword",
        "client_id": "client_id_from_wink",
        "client_secret": "client_secret_from_wink",
        "hide_groups": ["thermostat"],
        "hide_ids": [],
        "fan_ids": []
    }],

    "accessories": [{
        "accessory": "Sonos",
        "name": "Media Room Speakers",
        "room": "Media Room"
    }, {
        "accessory": "Sonos",
        "name": "Kitchen Speakers",
        "room": "Kitchen"
    }, {
        "accessory": "Sonos",
        "name": "Living Room Speakers",
        "room": "Living Room"
    }]
}

I ended up switching to /pdlove/homebridge-wink and it worked after I took out the client_id and client_secret and left the fields blank for his plugin.

mousey76397 commented 7 years ago

{ "bridge": { "name": "Homebridge", "username": "CC:22:4C:E3:CE:30", "port": 51826, "pin": "031-45-154" },

    "platforms": [
    {
            "platform": "Hue",
            "name": "Hue",
            "sensors": true,
            "users": {
                    "001788FFA3E15": "iR27v7zkloc1ut5TkkFk-9bjgrXKptf"
            }
    },{
            "platform": "BelkinWeMo",
            "name": "WeMo Platform",
            "noMotionTimer": 60,
            "ignoredDevices": []
    },{
            "platform": "Wink",
            "name": "Wink",
            "client_id": "Client ID",
            "client_secret": "Client Secret",
            "username": "username",
            "password": "password",
            "hide_groups": [],
            "hide_ids": []
    }]

}

thechrisreese commented 7 years ago

Look up the Android API V1 Client ID and Secret and see if using that fixes it.

Jborn4christ commented 7 years ago

Did anyone find a fix for this yet?

thechrisreese commented 7 years ago

I cannot reproduce the issue.

That tells me it's either some of the devices you have attached, or something in your config file

thechrisreese commented 7 years ago

Or are you all aren't using the android credentials

Jborn4christ commented 7 years ago

Added android creds, that almost got it running, but now this...

events.js:160 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::51826 at Object.exports._errnoException (util.js:1026:11) at exports._exceptionWithHostPort (util.js:1049:20) at Server._listen2 (net.js:1257:14) at listen (net.js:1293:10) at Server.listen (net.js:1389:5) at EventedHTTPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19) at HAPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:158:20) at Bridge.Accessory.publish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:509:16) at Server._publish (/usr/local/lib/node_modules/homebridge/lib/server.js:114:16) at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:372:14)

thechrisreese commented 7 years ago

That one's new to me.

thechrisreese commented 7 years ago

Google says it's because you have to kill all Homebridge processes and restart them. The server was still running when you tried so it errored out.

Jborn4christ commented 7 years ago

Yeah. Had an old launchD plist that needed to be killed. Haven't run home bridge for quite a while, and wanted to spin it back up. All set now. Do you know are there plans/upsides to develop a plugin for wink with the v2 api?

thechrisreese commented 7 years ago

I started to do just that. And in fact with a few quick edits can make this one work with V2 credentials. Main issue is with how often Homebridge pings the API you start getting 500 error timeouts after about 15 minutes. And then you get a nice note from Wink telling you that if you keep doing that you will lose your V2 credentials.

It was really an issue I decided I didn't want to resolve at this point.

Jborn4christ commented 7 years ago

And I just got an email from Wink saying they reset my password because they noticed I was using the Android api. I told them, I was aware, and had to use it for my application to function properly. Anyone else had this issue? Also, totally unrelated to Wink, Walmart and Amazon sell a nice little wifi camera, but for months I have not been able to configure it properly for Homebridge. After messing around last night, and using some tips from iSpyConnect as well as a few other places, I was able to get them working!! I'm including the code from my config.json for anyone else, as well as the link to the cameras, as they are very affordable and robust. After relying on all of you to help me get my stuff running efficiently, it feels good to contribute even on a small scale. I currently have 4 of them working flawlessly in homebridge with still image previews.

Cameras: https://www.amazon.com/Momentum-WiFi-Home-Security-Camera/dp/B018F521QC

Code: { "platform": "Camera-ffmpeg", "cameras": [{ "name": "any name", "videoConfig": { "source": "-re -i rtsp://admin:admin@yourcameraipaddress:8001/H264/sub", "stillImageSource": "-i http://admin:admin@yourcameraipaddress/snapshot.cgi?user=admin&pwd=admin", "maxStreams": 2, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 30 } }] }

thechrisreese commented 7 years ago

I would expect more of that. They are trying to shut down V1 and want everyone on V2. They are probably going to move Android app over and we will all be SOL. I am sure there is a way to have Homebridge check less on V2 and not trigger their timeouts almost immediately, but it would mean the devices arent up to date. Don't know where to go with that.

For the Camera....AWESEOME. Can you post a screenshot of what comes up on the Home App? Are there notifications of movement?

Jborn4christ commented 7 years ago

Would v1 wink plugin work with my secret API? Probably not I imagine.

Jborn4christ commented 7 years ago

img_2259

Jborn4christ commented 7 years ago

No motion support yet, but I may look into it. I could possibly use smart sensors to trigger the camera alert

thechrisreese commented 7 years ago

No plugins work with V2 API at this point.

And those are encouraging results on the camera.

sibartlett commented 7 years ago

@thechrisreese I'm using V2 API in my plugin: https://github.com/sibartlett/homebridge-wink3

thechrisreese commented 7 years ago

@sibartlett NICE! Ill check it out. Especially with the push it should resolve the timeouts.

thechrisreese commented 7 years ago

@sibartlett ok I looked at it. Can you see the hacked together Canary implementation here and integrate it somehow for yours? That's the reason I even did this.

sibartlett commented 7 years ago

Sure, I'll see if I can pull in some of the stuff you've done here. It'll take me at least a week or two - whenever I got spare time to work on it.

Just to note: I haven't got a Canary, so I'd totally be relying on your implementation as a reference.

Jborn4christ commented 7 years ago

Do i not need to use my client id and client secret with your version @sibartlett ?

thechrisreese commented 7 years ago

@Jborn4christ ok I installed camera-ffmpeg and input the info in console.json. What do I need to change other than IP address to make this work?

Jborn4christ commented 7 years ago

Sorry @thechrisreese just saw this. That should be it. Sounds like you got it already though from other post.