ptz0n / homebridge-verisure

 Platform plugin for Homebridge allowing to manage and control Verisure devices.
https://www.npmjs.com/package/homebridge-verisure
MIT License
66 stars 15 forks source link

TypeError: Cannot read property 'filter' of undefined #51

Closed olofbokedal closed 5 years ago

olofbokedal commented 5 years ago

I've added the platform to my array of platforms with the following structure:

{
  "platform" : "verisure",
  "name" : "Verisure",
  "email": "xyz@xyz.com",
  "password": "secret",
  "alarmCode": "nnnn"
}

Homebridge stopped responding after this addition, and running it in debug mode gives me the following errors:

[2/16/2019, 8:34:36 AM] [Verisure] Initializing platform accessory 'Alarm (my address)'...
[2/16/2019, 8:34:36 AM] [Verisure] TypeError: Cannot read property 'filter' of undefined
    at Alarm.getServices (/usr/lib/node_modules/homebridge-verisure/lib/accessories/alarm.js:90:7)
    at Server._createAccessory (/usr/lib/node_modules/homebridge/lib/server.js:378:36)
    at Server.<anonymous> (/usr/lib/node_modules/homebridge/lib/server.js:364:32)
    at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:16:19
    at verisure.getToken.then.then.then (/usr/lib/node_modules/homebridge-verisure/lib/platform.js:98:9)
    at process._tickCallback (internal/process/next_tick.js:109:7)
(node:25714) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: This callback function has already been called by someone else; it can only be called one time.

Maybe this is an issue for https://github.com/ptz0n/node-verisure but since I'm using this plugin I figured I might as well add the issue here.

Let me know if I can provide any further details.

ptz0n commented 5 years ago

Thanks for creating an issue. Your config looks correct.

I find it strange that targetStateCharacteristic.props.validValues in your environment is undefined.

Which version of Homebridge are you running?

$ homebridge --version
olofbokedal commented 5 years ago

Your question reminded me that I haven't updated node in some time, and I was running version 6.x. The issue might definitely be caused by the old version, but an update to version 10 caused a whole bunch of other problems with other packages.

I'll get back to you when I've got Homebridge itself up and running again.

ptz0n commented 5 years ago

I see. I'm running node v10.15 in my setup. Let's revisit if the problem still occurs 👍

olofbokedal commented 5 years ago

For anyone else encountering this: It works fine after updating node. Currently running v10.15.1 without any problems.

ptz0n commented 5 years ago

Fantastic news! Maybe we should declare node 7+ as a requirement?

olofbokedal commented 5 years ago

That could be a good idea yes, especially since Homebridge itself only requires v4.3.2 or above.

ptz0n commented 5 years ago

I've changed my mind, sorry. Tests are currently passing in node 6, therefore let's keep supporting that environment until we have identified a reproducible issue.

If you where able to reproduce this issue with a stand-alone setup, please share your exact versions of node, npm, homebridge etc.

olofbokedal commented 5 years ago

I'm afraid I didn't take notice of all the versions involved so I can't help much further in order to reproduce it.