Forwarding events over http

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
beeguy123
Posts: 10
Joined: 20 Feb 2016 13:55

Forwarding events over http

Post by beeguy123 » 05 Apr 2016 22:47

I need to forward Z-Wave events over http. I have been using the userModule https://github.com/reneklootwijk/zway-eventforwarder succesfully for this purpose. (Modified it slightly so it offers a proper http api for my home server.)
However with my latest setup the module fails on startup. I guess it's not compatible with latest zway server version (2.2.1).

Can anyone suggest a different user module for forwarding events over http please ? (Or point out how to fix reneklootwijk's module. It's not being maintained, and I'm in above my head there...)

thanks!

User avatar
DomotikQuebec
Posts: 34
Joined: 14 Jan 2016 19:06
Location: Quebec City, Canada
Contact:

Re: Forwarding events over http

Post by DomotikQuebec » 06 Apr 2016 16:43

Any log ? Error message ?
Mario Gravel
Domotik Quebec

beeguy123
Posts: 10
Joined: 20 Feb 2016 13:55

Re: Forwarding events over http

Post by beeguy123 » 06 Apr 2016 23:36

DomotikQuebec wrote:Any log ? Error message ?
Yeah sorry I prly should've given that in the first place.

Natively the error message (on the web interface) is this :
Cannot instantiate module: EventForwarder: TypeError: Cannot read property 'devices' of undefined

And the log includes this :
[2016-04-06 22:07:41.568] [core] Loading module EventForwarder from userModules/EventForwarder
[2016-04-06 22:07:41.571] [core] Executing script: function EventForwarder(id, controller) { ...
[2016-04-06 22:07:41.579] [core] Instantiating module 10 from class EventForwarder
[2016-04-06 22:07:41.581] [core] --- Starting module EventForwarder
[2016-04-06 22:07:41.591] [core] EventForwarder: Created new device {"creationTime":1455655540,"creatorId":8,"deviceType":"battery","h":-592588977,"hasHistory":false,"id":"BatteryPolling_8","location":0,"metrics":{"probeTitle":"Batt$
[2016-04-06 22:07:41.601] [core] Notification: error (core): Cannot instantiate module: EventForwarder: TypeError: Cannot read property 'devices' of undefined
[2016-04-06 22:07:41.657] [core] TypeError: Cannot read property 'devices' of undefined
at EventForwarder.createDevice (automation/userModules/EventForwarder/index.js:119:51)
at handleDevCreation (automation/userModules/EventForwarder/index.js:26:14)
at Function._.each._.forEach (automation/lib/underscore.js:146:17)
at _.extend.each (automation/classes/DevicesCollection.js:181:18)
at EventForwarder.init (automation/userModules/EventForwarder/index.js:34:29)
at AutomationController.instantiateModule (automation/classes/AutomationController.js:390:22)
at AutomationController.<anonymous> (automation/classes/AutomationController.js:482:18)
at Array.forEach (native)
at AutomationController.loadModule (automation/classes/AutomationController.js:481:8)
at AutomationController.<anonymous> (automation/classes/AutomationController.js:606:14)

What I've tried is to replace all instances of 'global.zway.devices' in index.js by 'global.ZWave["zway"].zway.devices'
Then at least 'global.zway' is not undefined. But this in turn results in :

[2016-xx-xx hh:mm:ss] [core] TypeError: Cannot read property 'data' of undefined
at EventForwarder.createDevice (automation/userModules/EventForwarder/index.js:119:84)
at handleDevCreation (automation/userModules/EventForwarder/index.js:26:14)
at EventEmitter.emit (automation/lib/eventemitter2.js:339:30)
at _.extend.create (automation/classes/DevicesCollection.js:51:18)
at automation/modules/SwitchControlGenerator/index.js:90:41
at Array.forEach (native)
at SwitchControlGenerator.zwayReg (automation/modules/SwitchControlGenerator/index.js:75:119)
at SwitchControlGenerator.init (automation/modules/SwitchControlGenerator/index.js:225:18)
at AutomationController.instantiateModule (automation/classes/AutomationController.js:390:22)
at AutomationController.<anonymous> (automation/classes/AutomationController.js:482:18)


I'm not quite sure what I'm doing so I'm not getting any further than this...

User avatar
DomotikQuebec
Posts: 34
Joined: 14 Jan 2016 19:06
Location: Quebec City, Canada
Contact:

Re: Forwarding events over http

Post by DomotikQuebec » 07 Apr 2016 00:13

global.zway shouldn't be undefined in the first place.

If you modified EventForwarder, can you show us the code of the init function ?
Mario Gravel
Domotik Quebec

beeguy123
Posts: 10
Joined: 20 Feb 2016 13:55

Re: Forwarding events over http

Post by beeguy123 » 08 Apr 2016 21:29

Thanks. I haven't changed anything in the init function. (See link in first post for the original index.js)
My changes are in the http.request part.

beeguy123
Posts: 10
Joined: 20 Feb 2016 13:55

Re: Forwarding events over http

Post by beeguy123 » 17 Apr 2016 09:10

Solved for me, although not elegantly.
I found out that the 'property undefined' errors are only on one or two of the virtual devices that it tries to create. I have wrapped the involved code lines in try/catch statements. This way it can fail without crashing. (Empty catch : just disregard if it fails.)
I still don't know what's the deal with those failing virtual devices.
Not the cleanest solution but hey it works.

Post Reply