Premise Open-zwave?

Motorola Premise

w84no1

Active Member
I want to use Z-Wave devices, and I can get a Aeon Labs Z-Stick for about $50. The VRCOP/RZCOP is about twice that amount.

Open-zwave allows anyone to create applications that manipulate and respond to devices on a Z-Wave network, without requiring in-depth knowledge of the Z-Wave protocol or the purchase of expensive development kits.

Could I write a native driver for Premise using this library?

Or I can install zVirtualScences, (which uses open-zwave) because it has a http-api that returns and receives json or xml and create a module to interact with the z-wave network.

Would either of these methods work or both? I am a web developer, so the second option would work best for me as I haven't done C++/.Net stuff in years.

Advice and thoughts are welcomed.
 
One way to look at it is that the extra $50 for a VRC0P gets you a free zWave driver. Unless you feel compelled to write a new driver (always welcome), that's a pretty good deal.

I'm no zWave expert but my understanding is that you'll need something other than the VRC0P to act as the primary controller. I believe the Z-Stick can serve this purpose. Buy both, use the VRC0P with the free driver today. While that is working nicely with your zWave lights, motion detectors, thermostats, and locks, take your time learning how to write a driver for the Z-Stick.

Native drivers require use of the HSDK which means you need to know how to code in C++ and have Visual Studio (not Express because the HSDK includes macros, to build classes, that do not work in Express). I wrote the USB-UIRT driver using the HSDK and it took me awhile to wrap my head around it.

If you use MiniBroker (a COM object that exposes Premise's internals) you can code a driver using any language that supports COM objects.

The easiest way to write a driver is as a Module. Builder provides a nice development environment that includes an interactive debugger (code-completion, breakpoints, observe variable values, etc). The best thing is that the development cycle is fast. What do I mean by that? Compare the following:

Compiled Driver
Writing a driver with the HSDK or MiniBroker using a third-party tool like Visual Studio.(very similar to how drivers are created in many HA programs):
  1. Write some code. Save it.
  2. Compile/link/whatever to generate a DLL (i.e. the driver).
  3. Unload the existing driver from Premise.
  4. Load the new driver in Premise.
  5. Test the driver.
  6. Uh-oh. A bug. Repeat edit/compile/unload/reload/test.
Interpreted Driver

Writing a driver as a Module using Builder:
  1. Write some code. Press F12.
  2. Test the driver.
  3. Uh-oh. A bug. Repeat edit/test.
Plus you have an interactive debugger at your disposal so in step 2 you can stop execution wherever you want and observe the state of the variables to help you find the bug.





Being object-oriented is an enormous benefit. Premise has a truckload of classes designed to simplify your life, accelerate software development, and maintain consistency. For example, let's say you need to store temperature. You could just create a Real variable and store it as a Fahrenheit value. Folks outside the US will naturally ask you to add Fahrenheit -> Celsius and Celsius -> Fahrenheit conversions. This is not the right way to do it in Premise!

The solution? Don't use a Real variable, use the Temperature Property class. Let's say you call your Temperature Property variable ExteriorTemp and you are reading the exterior temperature in Fahrenheit. Just do this:
ExteriorTemp.Fahrenheit = 73
If you need the value in Celsius you use the Celsius method like so:
x = ExteriorTemp.Celsius
Premise is actually storing ExteriorTemp in Kelvin units. Premise has Property classes for Speed, Length, TimeSpan, Voltage, etc (see attached image or this document).

Premise's object-oriented architecture lets you easily model complicated real-world devices. You can build a single driver that support multiple physical devices. For example, one serial port can communicate with several Adicon Bobcat sensors. In Premise, the driver is seen as a single root node (the part that talks to the serial port) with multiple child nodes (representing several sensors). The HAI Omnistat driver I created lets you use one serial port to talk to multiple Omnistat thermostats. Each Omnistat appears as a child-object of the root driver.

OmnistatNet
.......Omnistat1
.......Omnistat2

You can create classes to represent real-world situations more clearly. For example, an ELK M1 Zone has numerous properties including:
  • Status
  • Logical State
  • Physical State
  • Definition
  • Area
  • Trouble
  • Bypassed
In many HA systems, these properties are represented as arrays. If you want to know the Logical State of zone 43, the LaundryWindow sensor, you'd go to the M1 > LogicalState array and look at array element 42 (zero-based array).



Premise lets you build classes containing properties and methods that do a better job of modeling a device. In Premise you'd go to:
M1 > Zones > LaundryWindow > LogicalState
The LaundryWindow object, a Zone, contains all of its properties (LogicalState, Status, Definition, etc) in one place.

Premise stores objects using a hierarchical linked list which means you never have to predefine the number of elements like you would with an array. Create a parent object and as many child-objects as needed, on the fly. Child-objects can also have child-objects so you can see that this degree of flexibility lets you model some very complex real-world systems

The best way to learn how to construct a driver as a Module is to download an existing one and examine how it is written. Sometimes the device's complexity makes the driver hard to understand to I recommend you look at a simple one like Weeder Digital I/O driver. This driver demonstrates several techniques:
  1. Read/write via a serial port.
  2. Parse ASCII Text protocol.
  3. Single driver supporting multiple devices.
  4. "Watchdog". Device is polled and alert is raised if unresponsive.

This gadget has I/O ports that can be designated as Input or Output by the end-user. The driver demonstrates a special ability of Premise to swap one class (Input) for another (Output) on the fly ("Transformable").

Have fun!
 

Attachments

  • Premise Property classes.png
    Premise Property classes.png
    26.6 KB · Views: 14
123 thanks for the info. I am going to look at the driver you mentioned. I have some rs232 devices that I want to control, so that example might be a good starting point.

As far as the z-wave driver, I will go ahead and get the z-stick and one device to control, if I can't get a driver working I will then get the VRCOP.

Also, I have made some progress with my jQuery Mobile MiniBrowser UI. I just don't have any devices to control yet.
 
If the z-stick shows up as a virtual COM port, would Premise Builder recognize it as an available COM port? If it does, you should be able to connect your device driver to the virtual com port and use vbscript from within Builder to develop a module. What would save you a lot of time then is using the VRC0P driver and modifying it to use the Open-ZWave api. You would still need to figure out things at a much lower level, especially how to send secure z-wave messages for locks.

The neat thing about the VRC0P is that it really has two controllers: a microcontroller and the Zensys chip. The microcontroller handles the receipt of plain text commands on the COM port and transforms them into Zensys Z-Wave commands that the Zensys chip can understand. This means the Zensys protocol is greatly simplified by the microcontroller.
 
Back
Top