In my effort to build a better bathroom monitor, I have encountered an new enemy to my project: battery powered Z Wave devices. As I outlined in my last post, I had installed the python openzwave project and gotten the controller to communicate with my python script. But for some reason, it would not see or react to the door sensors. I tried over a weekend to figure out my issue when it hit me Saturday night. Maybe the batteries had died in my devices. A quick trip to the CVS and that sure enough fixed one issue. Then I could see the door sensors, but I could not get all the information from them and I also was not getting expected messages from them when I triggered them.

After more than a few evenings of researching and trying new things, I stumbled on the fact that battery powered Z Wave devices have a wake up interval. So they stay dormant until they wake up at that interval and look for the network they have been added to. Then they can send messages back to the controller. I found that I could manually wake them up, but on a reboot of the machine, I would have to do this again or wait until they woke up on their own and showed back up on the Z Wave network. For my testing purposes, I am just going to wake them up by removing the backs and resetting them using the button in the sensor.

The sensors had been added to the config file of the openzwave project. It was only basic information about the sensors. Further down the road I will see about getting that information and maybe storing it someplace, but now I just want to get the open and close notifications.

My first step was to set up the Z Wave network and its options. I used the examples from the python-openzwave GitHub repo to help guide me on this and the next steps of setting up event listeners for incoming signals. I was unable to get the Z Wave network to send a ready signal back. I found out from some research that the signal does not come from openzwave itself, only from the Python wrapper. One thing that tripped me up here, due to both my unfamiliarity developing in a Linux system and using the Python virtual environments, was where the configuration files for openzwave were. I am guessing that the directory is going to be different once I set it up on my Raspberry Pi. Great opportunity to use some config files and learn how Python reads those!

Got to get those strings out of there!!


Once the network is set up, I added the listener events to fire when the sensors open and close. I first hooked up some listeners for network events. One of these would register the event that would listen for value changes from the sensors. Then, I unregistered that event so it would not fire every time the network ready signal is sent. For Python 3, python-openzwave uses Pydispatch to handle event passing. I dug into it’s documentation along with the documentation for python-openzwave.






So now with some handy debugging statements and references back to the python-openzwave documentation, I was able to get those notifications on opening and closing and that information printing out as you can see below.  Still having some errors that I will need to address, but they are not stopping the execution. Now we can move on to some other things like data persistence and developing an api that can be called by other applications.

 

Hopefully, I can get some input about what else I can add to the project this weekend when I head back down to Augusta, Georgia for the first annual Southern Dev Conference!