Introduction
Command Lessons are the important thing to Z-Wave’s application-level interoperability. All protocols have a standardized bodily layer which ensures gadgets manufactured by completely different firms can talk. Z-Wave’s bodily layer is outlined within the ITU-T G.9959 customary. The bodily layer customary is important, however inadequate for IoT gadgets to speak in a significant means. Command Lessons are the important thing to enabling a controller to “know” the best way to activate a light-weight when movement is detected and regulate the thermostat to the liking of the person. Command Lessons are outlined within the Utility Work Group Z-Wave Specification obtainable on the Z-Wave Alliance web page.
The “spec” is over 1300 pages lengthy. In the event you need assistance sleeping one evening, crack this open and also you’ll be off to lala land very quickly! Happily, it’s not a doc you learn from cowl to cowl. It’s extra like a dictionary, the place you lookup particular objects to grasp precisely how an IoT system communicates in an interoperable means, so all events correctly talk the data. I make in depth use of the bookmarks bar within the PDF reader to rapidly bounce to the part I want. Search can be helpful to search out the reply to a particular query.
While you first open the specification, you’ll see many variations of a command class and quite a few ones which can be out of date or deprecated. If a command class is out of date, you can’t use it ever and as a controller you don’t should assist it. Deprecated command lessons are largely outdated variations, and you should use the newer ones. Word that it’s NOT required to assist the newest model of a command class. For instance, Battery Command Class model 1 is completely superb for many gadgets. Variations 2 and three add further data for particular varieties of batteries, however model 1 is ok for many IoT gadgets with easy batteries.
One other key Z-Wave file is the ZW_classcmd.h file which is within the SDK. This file explicitly defines each area of each command in each command class. The spec will get you to the suitable command, however the ZW_classcmd.h file defines the precise syntax and spelling of the fields it’s essential to put in your code. Happily, VS Code does a reasonably good job of filling most of this in for you when utilizing Simplicity Studio V6. I’ll go into extra coding particulars within the subsequent weblog put up.
There are eight sections to the spec:
| 1 | Introduction | |
| 2 | Utility Command Lessons | Majority of the Command Lessons |
| 3 | Administration Command Lessons | Z-Wave & Machine Administration |
| 4 | Transport-Encapsulation Command Lessons | Safety & transport encapsulation |
| 5 | Community-Protocol Command Lessons | Controller associated CCs |
| 6 | Command Class Management | Command Class guidelines |
| 7 | Machine Kind Specification | Necessary CCs |
| 8 | Function Kind Specification | Extra guidelines and energy supply sorts |
The place Do I Begin?
What’s step one in coding a brand new Z-Wave Product? You’ve already chosen the pattern app within the 2nd weblog and that alternative goes a good distance towards your first step right here. Begin with the Machine Kind V2 Specification part 7. There’s a lengthy checklist of widespread gadgets like switches, locks, bulbs, thermostats, sensors, and gateways. Your system ought to match into one among these broad classes. Every Machine Kind specifies a listing of obligatory command lessons.
Necessary Command Lessons
The pattern app sometimes offers all of the obligatory command lessons so there isn’t any work required right here. However you need to double test as necessities change and generally the code lags the specification. The Z-Wave Certification Take a look at Instrument will do a complete test for all of the obligatory command lessons so it’s price a couple of minutes to test early within the venture growth.
Necessary command lessons are obligatory for a cause! They considerably enhance interoperability! They assist make most gadgets function in a predictable means and supply related data. Additionally they guarantee your system may be probed for all salient options enabling the hub to supply all of your options to the person. This permits your product to be supported the day it begins transport with out ready for the hub vendor to “assist” your product via handbook coding. Word that part 7.2 of the specification has a listing of obligatory command lessons which can be required for all merchandise. These embrace Z-Wave Plus Data which helps the hub know precisely the final kind of system, Affiliation which tells the system the place to ship unsolicited experiences, Firmware Replace which allows updates within the area which is now required for the brand new world safety initiatives.
Command Lessons for My Product
With the obligatory command lessons out of the way in which, the subsequent step is to find out what different command lessons are wanted. The pattern software sometimes has a number of extra command lessons included to offer the performance for a particular system. For instance, a thermostat would begin utilizing the door lock pattern app since there isn’t a thermostat pattern app. Most thermostats are LSEN gadgets the identical as door locks however in fact they want completely different command lessons. The very first thing to do is take away the door lock associated command lessons.
For Silicon Labs you employ Simplicity Studio V6 and easily Set up or Uninstall command lessons you do or don’t need. Open the .SLCP file within the venture, choose Software program Parts then scroll all the way down to Z-Wave and open the Command Lessons pull down. Click on on all of the door lock associated command lessons and uninstall them. Subsequent, you need to add the Thermostat associated command lessons. However wait, there are none! That is the place you should write them your self. For Trident there’s a separate cmake library for every command class that are commented out so that you merely uncomment those you want.
Most gadgets require a number of command lessons to create a whole product. Utilizing the thermostat instance, along with Thermostat Mode, Set Level, Fan Mode, Fan State, Setback you’d additionally sometimes embrace Multilevel Sensor for the temperature and humidity sensors, Time and Schedule to have the everyday seven-day setback schedules, and maybe different command lessons that make your product distinctive. There isn’t one method to assemble the command lessons which is how one can make your product stand out however nonetheless be interoperable.
What to do for Command Lessons That Haven’t Been Carried out But
Not all command lessons have been carried out but. Can AI write them? Most likely – let me know in the event you can create a working command class with AI. Not one of the thermostat associated command lessons are within the open-source repository as talked about above. What do you do? You need to implement them your self. Ideally you need to submit your implementation to the open-source repository to assist the whole neighborhood. It is a fairly high-bar as you should implement each command within the command class and comply with the coding guidelines in addition to present take a look at code to make sure the code is bug-free (possibly bug-lite?). I’m at the moment implementing Geographic Location and Time command lessons which I hope to Pull Request into the repository within the coming months.
The bottom line is to repeat the same command class to make use of as a place to begin. Step one is to implement the REGISTER_CC_V6 macro. Every present command class has this macro, or an earlier model of it, on the backside of the principle command class file. The macro installs the command class into the Node Data Body (NIF) and offers hyperlinks to the command class handlers and different features. The NIF is the checklist of command lessons the system helps which the hub makes use of to interrogate the system to study what it could do when first joined to a community. Subsequent, implement the handlers that decode all of the instructions of a command class and return a report when a Get command is acquired. The command to ship a body is zaf_transport_tx() which places the message into the FreeRTOS queue and sends it to the SDK. A callback perform known as when the message is shipped with a standing of success or not.
Help vs. Management
One of many important confusion factors about command lessons is that if your system will Help or Management it. In some instances, your system might do each! This is a vital distinction for Z-Wave certification as completely different take a look at instances might be utilized to your system relying on which one is carried out. Controllers particularly are a bit complicated since in lots of instances they each Help and Management particular command lessons. The selection of Help or Management is usually easy: Your system Helps a command class if it receives a GET or SET command and replies with a REPORT. Your system Controls a command class if it sends a GET or SET command. For many finish gadgets and most command lessons this rule is simple. The issue is available in with issues like Time Command Class which most finish gadgets (often door locks and thermostats) BOTH Help and Management it. They Help Time as a result of they’ll obtain a SET command to set their inner clock to the present time. However, extra usually they’ll SEND a GET asking for the present native time and obtain a REPORT from the web linked gateway with the native time correct to a couple milliseconds.
There’s much more work concerned in absolutely implementing a command class, however I don’t have the house to undergo a complete instance. Nevertheless, you’ll be able to overview my efforts in implementing Geographic Location command class via my Geographic Location CC github repository. Is there one thing you don’t like within the spec? Become involved within the Utility Working Group and you’ll repair it! If there’s a command class that has not been carried out, bounce in and submit it for overview. Z-Wave is an open customary and depends on the neighborhood to maintain it contemporary and preserve the code coming.
Subsequent Steps
Half 4 of the Developer’s Journey will talk about particulars about coding and debugging Z-Wave firmware. It is a longer weblog as there’s a lot to cowl. I’ll embrace a number of display screen photographs and advocate instruments that I discover invaluable. As we proceed alongside the Z-Wave Developer’s Journey, I welcome your feedback and questions. Please be at liberty to achieve out to me immediately through electronic mail.
In regards to the Writer
Eric Ryherd has been on the forefront of Z-Wave innovation since 2003, starting as a marketing consultant and later serving as a Discipline Utility Engineer at Silicon Labs. Over the course of his profession, he has contributed to the design and growth of a variety of Z-Wave merchandise, together with sensors, distant controls, motorized window shades, and in-wall dimmers, a lot of that are available on the market right now.
Though he “retired” in 2022, Eric stays deeply engaged in embedded programs and Z-Wave growth by way of his weblog, DrZWave.weblog, and ongoing IoT consulting initiatives. He’s additionally a well-recognized face at Z-Wave Alliance Unplug Fests, the place he incessantly serves because the lead coordinator, supporting interoperability and developer collaboration.







