At my former job, we had 16 people on our floor with two single person bathrooms. So there were times where myself or my coworkers would get up to head to the head only to find that both of the bathrooms were full. Now, you could be like one of our former coworkers and wait in the darkened hallway to startle whoever was coming out, or just go back to your desk and come back later. Sometimes you would have to get up and down a couple of times before you got a shot at an empty one. Of course, being programmers, my room began brainstorming how we could fix the situation with technology. This was the beginning of Project TMD.

The idea that I settled on was to use a couple of Z Wave Plus door/window sensors and just track when the door was open to signal that the bathroom was available. After doing some research, I also was able to find a USB Z Wave controller. I could have hooked it up to my work machine, but I happened to have a Raspberry Pi sitting around collecting dust.

The first iteration of this project I had help from my friend David Ray. He builds a bunch of really cool stuff that you should definitely check out! I had a very limited exposure to Python and David suggested that we could easily write a script for communicating with the controller and seeing the state change on the sensors to determine when they opened and closed. In a couple of hours David had guided me through and we had a nice little script running. I later added some Slack web hook integrations and a timer. You can find this script on my GitHub repo.

This was a good start. But again, being a developer, I needed to build something that had data persistence, a web interface, and otherwise overengineered! So, now I am on that journey. My next series of posts will be me trying to work through to build this second iteration of Project TMD. I hope you enjoy it and also learn from what I am sure will be some mistakes.

Setting up my environment

The first thing that I knew is that I did not want to develop on my Pi. It was just cumbersome to remote into the Pi and develop on it. So I decided to dual boot my laptop with the current version of Ubuntu (18.04) and set up a Linux development environment. I also decided to give Visual Studio Code for Linux a try while developing this. I also was able to find a python library, Python OpenZWave, that I am hoping will make my life a little easier when dealing with the controller and sensors.

I hit a couple of errors while trying to run the check outlined in the installation instructions on GitHub. I first was install the project due to an error of the process failing on the building of the wheel. After some searching I found a tip on the Homeassistant.io forum that advised installing libpython3.6-dev and python3.6-dev which fixed the error.

Once installed I had to find out where the controller was on my machine. Using the command ls /dev/tty* once with the USB controller plugged in and once without, I was able to locate the controller. For me it was ttyACM0 and from what I found many of the examples that guided me through this had the same. One other snag that I hit when running the check command for the project was that I had to add my user account to the dialout group which the USB controller is a part of.

So now I had an environment set up and ready to work with my controller and sensors. Next up writing a script to connect to the controller, see the sensors on the network and beginning to track their state change. Thanks for reading!