Using Server-side Javascript
Posted: 30 Aug 2014 18:33
Howdy.
I was excited when my RaZberry module arrived in the mail. Tossing my Aeon stick aside and plugging my RaZberry in, I quickly started reading up on all of the APIs that are available. With the Aeon stick I was writing my own serial IO interface, discovering the network, trying to frame the bits properly, write job control logic, etc. What a pain!
All of this was being written in Python, and there are specific reasons for using Python, namely use of the Twisted framework and the manner in which I could handle web requests as well as interface with the serial device. Now I'm looking at taking the existing Python code and working with the Z-Way API. I get that there is a mechanism for interating via JSON as well as POSTing Javascript code, but my application is server-side and running alongside the Z-Way server on my RaspberryPi, so what I want to do is, in my Python code, talk directly to Z-Way through... what? That's where I'm confused.
There's a C library, but there are also a lot of examples using straight up Javascript. But how does one interface with that Javascript, particularly if I'm embedding that Javascript into a runtime interpreter through Python (PyExecJS). Or, to make it even simpler, let's say I have node (as in node.js) on my Pi, and I'm sitting at the console. How do I interact with Z-Way through that?
I was excited when my RaZberry module arrived in the mail. Tossing my Aeon stick aside and plugging my RaZberry in, I quickly started reading up on all of the APIs that are available. With the Aeon stick I was writing my own serial IO interface, discovering the network, trying to frame the bits properly, write job control logic, etc. What a pain!
All of this was being written in Python, and there are specific reasons for using Python, namely use of the Twisted framework and the manner in which I could handle web requests as well as interface with the serial device. Now I'm looking at taking the existing Python code and working with the Z-Way API. I get that there is a mechanism for interating via JSON as well as POSTing Javascript code, but my application is server-side and running alongside the Z-Way server on my RaspberryPi, so what I want to do is, in my Python code, talk directly to Z-Way through... what? That's where I'm confused.
There's a C library, but there are also a lot of examples using straight up Javascript. But how does one interface with that Javascript, particularly if I'm embedding that Javascript into a runtime interpreter through Python (PyExecJS). Or, to make it even simpler, let's say I have node (as in node.js) on my Pi, and I'm sitting at the console. How do I interact with Z-Way through that?