Z-Wave-Me / home-automation

Z-Way Home Automation engine
182 stars 116 forks source link

2.2.2 multisensor bug #338

Open maros opened 8 years ago

maros commented 8 years ago

My test system is running on the HEAD of the develop branch ( 002c800b3a58e46ac0b5dc9392b94197d566994a ) and experiencing issues with Multisensors (Aeon labs and Philio). Temperature, tamper and movement devices are created correctly, but luminosity, humidity and UV devices are missing.

[2016-04-04 21:04:35.879] [I] [core] Starting storage...
[2016-04-04 21:04:35.881] [I] [core] ZWay Automation started
[2016-04-04 21:04:36.043] [I] [core] Creating device sensorBinary ZWayVDev_zway_3-0-48-1
[2016-04-04 21:04:36.107] [I] [core] Creating device battery ZWayVDev_zway_3-0-128
[2016-04-04 21:04:36.184] [I] [core] Creating device sensorBinary ZWayVDev_zway_3-0-156-0-A
[2016-04-04 21:04:36.245] [I] [core] Creating device sensorBinary ZWayVDev_zway_3-1-48-1
[2016-04-04 21:04:36.299] [I] [core] Creating device sensorMultilevel ZWayVDev_zway_3-2-49-1
[2016-04-04 21:04:36.308] [I] [core] Notification: error (core): Cannot create vDev based on: 3-2-49: TypeError: undefined is not a function
[2016-04-04 21:04:36.341] [I] [core] TypeError: undefined is not a function
    at addRemoveEntry (automation/classes/AutomationController.js:1483:34)
    at AutomationController.genNspc (automation/classes/AutomationController.js:1556:46)
    at AutomationController.generateNamespaces (automation/classes/AutomationController.js:1634:28)
    at pushNamespaces (automation/classes/AutomationController.js:72:14)
    at null.<anonymous> (automation/classes/AutomationController.js:116:13)
    at EventEmitter.emit (automation/lib/eventemitter2.js:317:33)
    at _.extend.create (automation/classes/DevicesCollection.js:51:18)
    at automation/modules/ZWave/index.js:1826:42
    at Array.forEach (native)
    at ZWave.parseAddCommandClass (automation/modules/ZWave/index.js:1799:25)
ronie-z-wave commented 8 years ago

couldn't reproduce this at the moment ... works fine on my rpi with raZberry and 2.2.2-rc7 Did you do some more steps before or did you only restart the server after synchronisation?

maros commented 8 years ago

I bisected this issue and wasn't able to find a recent commit that would cause this issue. However, after restoring a previous backup file this seems to work again. Looks like a corrupted storage json file to me?! I restarted quite frequently prior to this.

ronie-z-wave commented 8 years ago

maybe has swallowed something ... we'll have an eye on this :)

maros commented 8 years ago

Unfortunately, even with the working backup applied, it keeps happening after every restart. What info/files/... do you need from me in order to investigate this issue? Is there anything I can do or check?

ronie-z-wave commented 8 years ago

hmm ... the lines are not matching with them from https://github.com/Z-Wave-Me/home-automation/blob/develop/classes/AutomationController.js ... could you please check if the file is exactly the same?

maybe also an update to v2.2.2-rc7 could help ...

maros commented 8 years ago

See https://github.com/Z-Wave-Me/home-automation/blob/002c800b3a58e46ac0b5dc9392b94197d566994a/classes/AutomationController.js

Unfortunately 2.2.2rc-8 does not solve the issue. With rc8 the line numbers are slightly different

[2016-04-06 22:37:18.450] [I] [core] Notification: error (core): Cannot create vDev based on: 3-2-49: TypeError: undefined is not a function
[2016-04-06 22:37:18.481] [I] [core] TypeError: undefined is not a function
    at addRemoveEntry (automation/classes/AutomationController.js:1487:34)
    at AutomationController.genNspc (automation/classes/AutomationController.js:1560:46)
    at AutomationController.generateNamespaces (automation/classes/AutomationController.js:1638:28)
    at pushNamespaces (automation/classes/AutomationController.js:72:14)
    at null.<anonymous> (automation/classes/AutomationController.js:116:13)
    at EventEmitter.emit (automation/lib/eventemitter2.js:317:33)
    at _.extend.create (automation/classes/DevicesCollection.js:51:18)
    at automation/modules/ZWave/index.js:1826:42
    at Array.forEach (native)
    at ZWave.parseAddCommandClass (automation/modules/ZWave/index.js:1799:25)
    at ZDataHolder.<anonymous> (automation/modules/ZWave/index.js:1303:12)
ronie-z-wave commented 8 years ago

Hmm, we need to find out what is undefined in this line: entryArr.push(devEntry);

Could you try to log this with console.log() in AutomationController.js? Otherwise you could also install node-inspector for debugging HA code:

from http://razberry.z-wave.me/docs/zwayDev.pdf

3.6.1 Debugging JavaScript code Change in config.xml debug-port to 8183 (or some other) turn on V8 debugger capability on Z-Way start.

1 <c o n fi g >
2 . . .
3 <debug−port >8183</debug−port>
4 . . . .
5 </c o n fi g >

node-inspector debugger tool is required. It provides web-based UI for debugging similar to Google Chrome debug console. You might want to run debugger tool on another machine (for example if it is not possible to install it on the same box as Z-Way is running on). Use the following command to forward debugger port defined in config.xml to your local machine: 1 s s h −N USER@IP OF Z−WAY MACHINE −L 8 1 8 3 : 1 2 7 . 0 . 0 . 1 : 8 1 8 3 (for RaZberry USER is pi) Install node-inspector debugger tool and run it: 1 npm i n s t a l l −g node−i n s p e c t o r 2 node−i n s p e c t o r −−debug−p o r t 8183 Then you can connect to http://IP OF MACHINE WITH NODE INSPECTOR:8080/debug?port=8183 If debugging is turned on, Z-Way gives you 5 seconds during startup to reconnect debugger to Z-Way (refresh the page of debugger Web UI withing these 5 seconds). This allows you to debug startup code of Z-Way JavaScript engine from the very first line of code.

maros commented 8 years ago

Sorry for the late answer - only just returned from vacation.

After some investigation it seems that this error was triggered by adding probeType to my WeatherUnderground module. During the creation of virtual devices addRemoveEntry would be called three times per device. During the third call entryArr was an object instead of an array, and therefore lacking the push method. Seems that underscores in the probeType (i was using 'temperature_forecast_low', 'temperature_forecast_high' and 'temperature_forecast') caused this.

I was able to mitigate this issue by renaming 'temperature_forecast' to 'temperature_forecast_current'. Looks like probeTypes are splited by underscores, and causing these problems when they have different lengths. eg. 'namespace1_name' vs. 'namespace1_namespace2_name'

ronie-z-wave commented 8 years ago

ok thanks for debugging.

Hmm at the moment it is designed to to have three levels: deviceType > CC > subCC like sensorBinary > alarm > tamper .. probeType is alarm_tamper.

I was sure the code could handle that but it seems not ... So I'll have a look at this. By the way which probetype did you use for your vDevs?

maros commented 8 years ago

I'm was trying to use the standard probe types whenever possible. Otherwise i used the following types