OH2 Z-Wave refactoring and testing... and SECURITY

The latest version of the development binding dated 8th Sep 2018 is here.


Toward the end of last year I spent some time doing some initial refactoring of the ZWave binding in OH2. This focussed on rewriting the way transactions work as this is an enabler for other areas of the code. At the same time I also restructured the different layers of the binding to make things cleaner, and done some changes to support a system of autocoding the command classes directly from the Z-Wave standard which should ensure we have better compatibility with the formal Z-Wave standards.

For most people, the major benefit is this change brings security and mesh healing. If you want to test these features, then this development branch might be worth looking at and Iā€™ll find a way to make this available.

Since this was quite a large change to the binding it needs some more testing before itā€™s merged into master - thereā€™s bound to be bugs ;). That said, a few people have been testing it for a while now and itā€™s been working well (so far!).

Iā€™ll post a link to a JAR for testing in the next day or so - it will need to be manually installedā€¦

FTR -:

Cheers
Chris

A more detailed over of the major (visible) changes are -:

  • Security command classes are included. You can now install locks and other devices that utilise the security command class. Note that this doesnā€™t mean you should use security for everything ā€“ personally I would suggest to only use it for devices like locks and not for all sensors etc since the amount of traffic on the network will increase significantly. Security causes every command transmitted to actually send 2 or 3 commands over the air. Note that the database will likely need to be updated for secure devices to add the secure classes.
  • Network heal has been added back into the binding. This was removed as the old transaction code was not reliable when dealing with the commands that are used for heal that can take some time to complete. This was (is) a problem on OH1 as well but hopefully this is working much better now.
  • Command class names have changed to bring them inline with the ā€˜officialā€™ names in the Z-Wave standard. Itā€™s worth noting that this change does require all things to be updated since the configuration is slightly different.

Iā€™ve also changed the way weā€™re handling retries and dead nodes. Iā€™ve currently removed retries from the binding ā€“ this is because the controller already performs 3 retries, and itā€™s my feeling that have 3 retries at binding level was probably causing more problems than it solved as it blocks the binding from dealing with other commands for 15 seconds. I also donā€™t set a device as dead if it times out ā€“ only if the controller thinks the device is failed. If this causes problems then Iā€™m happy to look at this further.

Currently Iā€™m planning to merge these changes into a development branch to allow more widespread testing of these changes. Also, there are some other changes Iā€™m working on that will likely be merged here first as well. These changes are to support dynamic channels so that weā€™re less reliant on defining channels within the database. This is something that is done on other bindings, but unfortunately itā€™s a feature that wasnā€™t available in ESH when the OH2 Z-Wave binding was written. This is something Iā€™ve started to implement, but will be phased in to command classes over time starting with common classes. This should then allow devices to be used within the binding without the database being added ā€“ although clearly without the database there will be limited ability to configure devices since all configuration information is only available from the database.

42 Likes

Very good news! Do you happen to know how to use text files to configure things?

Sorry - Iā€™m not sure what you mean?

I have seen many people say that you donā€™t need to use Paper UI to configure openHAB, that it is possible to configure everything in text files. I know how to configure .items with the zwave 2.0 binding:

Group     Tstat10                                                                                                     (Thermostats)
Group     Tstat10_Chart                                                                                               (Tstat10)
Number    Basement_Tstat_HeatSetPoint         "Basement Heat Setpoint [%.1f Ā°F]"                      <temperature>   (Tstat10)                               {zwave="4:command=thermostat_setpoint,setpoint_type=1,setpoint_scale=1,refresh_interval=600"}
Number    Basement_Tstat_CoolSetPoint         "Basement Cool Setpoint [%.1f Ā°F]"                      <temperature>   (Tstat10)                               {zwave="4:command=thermostat_setpoint,setpoint_type=2,setpoint_scale=1,refresh_interval=600"}
Number    Basement_Tstat_Temperature          "Basement Temperature [%.1f Ā°F]"                        <temperature>   (Tstat10_Chart, Room_Temperature)       {zwave="4:1:command=sensor_multilevel,sensor_type=1,refresh_interval=600"}
Number    Basement_Tstat_Humidity             "Basement Humidity [%.1f %%]"                           <humidity>      (Tstat10_Chart, Humidity)               {zwave="4:2:command=sensor_multilevel,sensor_type=5,refresh_interval=600"}
Number    Basement_Tstat_OpMode               "Basement Mode"                                         <settings>      (Tstat10)                               {zwave="4:command=thermostat_mode,refresh_interval=600"}
Number    Basement_Tstat_ModeState            "Basement State [MAP(ct100.map):%s]"                    <settings>      (Tstat10)                               {zwave="4:command=thermostat_operating_state,refresh_interval=60"}
Number    Basement_Tstat_Battery              "Basement Thermostat Battery [%d %%]"                   <battery>       (Tstat10, Battery)                      {zwave="4:command=BATTERY,refresh_interval=1200"}
DateTime  Basement_Tstat_Clock

Turns into:

Group     Tstat10                                                                                                     (Thermostats)
Group     Tstat10_Chart                                                                                               (Tstat10)
Number    Basement_Tstat_HeatSetPoint         "Basement Heat Setpoint [%.1f Ā°F]"                      <temperature>   (Tstat10)                               {channel="zwave:device:67cd13f9:node4:thermostat_setpoint_heating"}
Number    Basement_Tstat_CoolSetPoint         "Basement Cool Setpoint [%.1f Ā°F]"                      <temperature>   (Tstat10)                               {channel="zwave:device:67cd13f9:node4:thermostat_setpoint_cooling"}
Number    Basement_Tstat_Temperature          "Basement Temperature [%.1f Ā°F]"                        <temperature>   (Tstat10_Chart, Room_Temperature)       {channel="zwave:device:67cd13f9:node4:sensor_temperature"}
Number    Basement_Tstat_Humidity             "Basement Humidity [%.1f %%]"                           <humidity>      (Tstat10_Chart, Humidity)               {channel="zwave:device:67cd13f9:node4:sensor_relhumidity2"}
Number    Basement_Tstat_OpMode               "Basement Mode"                                         <settings>      (Tstat10)                               {channel="zwave:device:67cd13f9:node4:thermostat_mode"}
Number    Basement_Tstat_ModeState            "Basement State [MAP(ct100.map):%s]"                    <settings>      (Tstat10)                               {channel="zwave:device:67cd13f9:node4:thermostat_state"}
Number    Basement_Tstat_Battery              "Basement Thermostat Battery [%d %%]"                   <battery>       (Tstat10, Battery)                      {channel="zwave:device:67cd13f9:node4:battery-level"}
DateTime  Basement_Tstat_Clock                                                                                        (Tstat10, Clock)                        {channel="zwave:device:67cd13f9:node4:time_offset"}

What I donā€™t know how to do and canā€™t find any documentation on is the .things file. I also canā€™t find out how to set the sale from Celsius to Fahrenheit. I have two dozen thermostats and going through Paper UI and changing everything is a major bummer. I really would like to stick to text config files if possible.

Itā€™s not possible to do this in the current release/snapshot versions. It will be in the development version but Iā€™ve not tested it myself at the moment.

Iā€™ve created a test version of the binding here.

You should uninstall the existing Z-Wave binding and manually install this file into the addons folder. It seems that OH comes with the serial bundle installed now so hopefully you shouldnā€™t need to manage thatā€¦

Points to note -:

  • Firstly - use at own risk :wink:
  • You MUST delete your existing things and add them back. Current definitions are not compatible due to a number of breaking changes. You donā€™t need to re-initialise the network or re-include devices - just delete the things and add back again.
  • If you have included secure devices you need to copy the network key over to the controller (donā€™t loose the key like I did tonight in all my messing around with deleting things to test the new version - tomorrows job will be to re-include my door lock!).

Any problems, please report here or raise an issue. Database definitions will need to be updated for locks to work as the additional classes will need to be added. My lock is here so you can see the door_lock channel. This will likely need to be added to other locks.

Happy testing ;).

4 Likes

link doesnā€™t seem to go anywhere

Agreed, link is dead for me too. :frowning:

Link is working (or at least working for me).

2 Likes

Hi, so Iā€™m running a fresh OpenHAB2 2.1.0-SNAPSHOT Build 771 and still canā€™t figure out how to activate this test Z-Wave binding. I have not installed any Z-Wave Bindings specifically and this is as a said, a brand new install. I add the test z-wave jar to the \addons folder, I can run list from the console and I see the line ā€œ9 | Installed | 80 | 2.1.0.201701302330 | ZWave Bindingā€ Now how in the world do I make this Addon Active so it works?!?

Thanks,
Glenn

On a completely clean installation of OH2 Snapshot (#771), you will get the following error when you try to start the new Z-Wave binding:

openhab> bundle:start org.openhab.binding.zwave
Error executing command: Error executing command on bundles:
	Error starting bundle 208: Could not resolve module: org.openhab.binding.zwave [208]
  Unresolved requirement: Import-Package: gnu.io

To fix this: feature:install openhab-transport-serial and then Z-Wave will start

6 Likes

Sorry - I missed the http off the front of the link - Iā€™ve now updated this.

Maybe it needs to be started? In the past at least, when you dropped bundles into the addons folder they would automatically start so long as all dependencies resolved. So, thereā€™s two options - either you just need to start the bundle (with the start command in Karaf) or you might need to manage the dependencies (ie add the serial library). When I tested this yesterday, the serial library seems to be installed by default, but this might not be correctā€¦

Thanks a ton! Thats exactly what my problem was with all of the versions I think Iā€™ve been trying the last few days. Once I added that feature the Zwave package shows as Active! This is all brand new to me, but Iā€™m highly enjoying the learning experience. Thanks again for all of the quick replies!

~Glenn

1 Like

One point to note - the binding is very ā€˜chattyā€™ - ie thereā€™s a LOT of debug information. I will reduce this shortly if the initial testing shows no major issues - for now Iā€™d recommend people are running with debug logging enabledā€¦

1 Like

I can confirm this works with my lock now!!! 914TRL Touchpad Electronic Deadbolt is what it shows up as, but itā€™s really a Kwikset SmartCode 910. Awesomeness, thanks so much!

1 Like

Cool - thanks for the feedback.

One point to note - I would strongly suggest to use HABmin and not PaperUI when doing a secure inclusion. HABmin will be able to provide information about the success (or not!) of a secure inclusion. It will pop up a box in the top right corner saying if secure inclusion was successful or notā€¦

If you want to use PaperUI, then you probably need to check the logfile, or there should be an attribute that also shows if it was securely included -:

(note that the above isnā€™t a secure device but it shows the ā€œUsing Securityā€ attribute)

1 Like

Iā€™ve done everything I can remotely here from my office, installing the new test binding, removing all devices and then re-adding them. Iā€™m just canā€™t wake up my lock not being at home yet to test it.

But my lock seems to still show not using security. And this my lock that I previously secure included with OZCP and can control the lock from OZCP. I did also copy my network security key over to the Controller in Habmin.

We only include the security key as XX XX XX, correct? and not as 0xAB, 0xCD, etc? Just the 2 digit numbers separated by a space?

And why on earth would my Kwikset lock show as ā€œBlack and Deckerā€ ???

Iā€™d need to check - I think I wrote it to allow both options, but for sure it will work with the 2 digit numbers.

Presumably because thatā€™s who makes it. The manufacturer names come from the ZWave standard.

can anyone walk me through moving the file to a headless linux install from the bash? I have a pine 64 headless openhab.