damianxd / homebridge-vera

Apache License 2.0
50 stars 37 forks source link

Sensor Exception #111

Closed machinen closed 7 years ago

machinen commented 7 years ago

I got this exception: Unhandled rejection TypeError: Cannot read property 'name' of undefined at /usr/lib/node_modules/homebridge-vera/lib/types/sensor.js:132:45 at /usr/lib/node_modules/homebridge-vera/lib/functions.js:213:45 at Array.forEach (native) at Object.module.processdevices (/usr/lib/node_modules/homebridge-vera/lib/functions.js:169:16)

for the sensor: { "altid": "21", "id": 57, "category": 12, "subcategory": 0, "room": 1, "parent": 1, "batterylevel": "100", "armedtripped": "0", "armed": "0", "name": "Multisensor", "state": -1, "comment": "", "lasttrip": "1490193559", "tripped": "0" },

In JSON, the name parameter is properly configured but I didn't understand how it couldn't parse it.

drewcovi commented 7 years ago

So that can't possibly be the device causing the error. The sensor script is only used for devices in categories 4, 16 & 18. Subcategories also need to match. Sounds like there might have been a configuration issue with your multi sensor.

Check the devices created by your multi sensor and verify they match the categories and subcategories listed. http://wiki.micasaverde.com/index.php/Luup_Device_Categories

All the same I'll build in the code to skip items that are misconfigured. Nobody likes it when code crashes. 🙂

drewcovi commented 7 years ago

I'm using the aeotec multisensor 6 and the parent sensor becomes a motion sensor. Which brand is this?

drewcovi commented 7 years ago

So the way devices are parsed they iterate through and use the category number as a switch. 12 isn't actually accounted for at all yet. Something must have changed for the multisensor six because for mine there is no generic sensor. The parent is a motion sensor.

drewcovi commented 7 years ago

@machinen any updates?

machinen commented 7 years ago

I am using Aeotec Multisensor 6 just like you and didn't make a special configuration for the device. 12 seems to be Generic Sensor according to Luup device categories (which makes sense). When I have some spare time, I will get the full JSON info and debug it. I also consider to exclude and re-include the device itself (to detect a special configuration if exists).

drewcovi commented 7 years ago

I would consider it. It seems like it didn't set up properly. When configured properly you will not get one device. You will get 5 (vibration just registers as a tamper alert) And incidentally it takes awhile for them to show up so be diligent. Notice the parent device will be the only one with battery level. img_2097

drewcovi commented 7 years ago

@machinen closing for now. Generic Sensors really have no equivalent in Homebridge and typically mean there was some sort of configuration issue. In your case you should have 5 devices not one. I would either use the vera option to "Configure Now" for that device or exclude/re-include it.