jperkin / node-openzwave

node.js interface to libopenzwave
Other
109 stars 54 forks source link

Cannot toggle my fibaro switch #28

Open zatmonkey opened 10 years ago

zatmonkey commented 10 years ago

Hi guys, I'm totally new to openzwave so I may be asking a silly question

here's my fibaro switch node:

node2: FIBARO System, FGS211 Switch 3kW
node2: name="", type="Binary Power Switch", location=""
node2: class 32
node2: class 37
node2:   Switch=false
node2: class 39
node2:   Switch All=240
node2: class 112
node2:   1. Enable/Disable ALL ON/OFF=-32096
node2:   3. Enable/Disable OFF-delay=-32096
node2:   4. Relay: OFF-delay time (10ms)=20
node2:   6. Separation of association sending (key 1)=-32236
node2:   13. Inputs behaviour=-32236
node2:   14. Inputs Button/Switch configuration=-32236
node2:   15. Dimmer/Roller shutter control=-32236
node2:   16. Saving state before power faillure=-32236
node2:   30. Relay: Response to General Alarm=-32236
node2:   31. Relay: Response to Water Flood Alarm=-32236
node2:   32. Relay: Response to Smoke, CO, CO2 Alarm=3
node2:   33. Relay: Response to Temperature Alarm=1
node2:   39. ALARM FLASHING alarm time=88
node2: class 115
node2:   Powerlevel=240
node2:   Timeout=0
node2:   Set Powerlevel=undefined
node2:   Test Node=0
node2:   Test Powerlevel=0
node2:   Frame Count=120
node2:   Test=undefined
node2:   Report=undefined
node2:   Test Status=120
node2:   Acked Frames=48
node2: class 134
node2:   Library Version=3
node2:   Protocol Version=3.42
node2:   Application Version=2.01

I'm trying to turn it on ... so I did

var OZW = require('openzwave'); undefined var zwave = new OZW('/dev/ttyUSB0'); undefined zwave.connect(); undefined zwave.switchOn(2); TypeError: Illegal invocation at repl:1:7 at REPLServer.eval (repl.js:80:21) at repl.js:190:20 at REPLServer.eval (repl.js:87:5) at Interface. (repl.js:182:12) at Interface.emit (events.js:67:17) at Interface._onLine (readline.js:162:10) at Interface._line (readline.js:426:8) at Interface._ttyWrite (readline.js:603:14) at ReadStream. (readline.js:82:12)

any idea what's wrong ?

thanks !

sja commented 10 years ago

You missed completly the async programming paradigm. Please read carefully the example and some NodeJS docs.

ekarak commented 10 years ago

Hey, what sja is saying is that you have to wait for the library to finish its initialisation. Just copy up the example code (with all the event handlers) up to the "zwave.connect();" line, then paste it in a nodejs terminal. When you get the "initialisation complete" message you can start issuing zwave commands.