I was recently browsing /r/InternetIsBeautiful and came across a site that a family in Fairbanks, AK puts up each year that allows web access to their Christmas lights, making it possible to switch the exterior lights on and off with a live video feed of the action. I thought this was a great idea and thought I could replicate it to a smaller scale and allow web access to our Christmas tree.

I previously looked into home automation using the open source platform OpenHAB so I thought that I could easily implement it for this project. OpenHAB is a hardware-agnostic home automation server software that can be used with a number of different protocols for interfacing with a number of different switches, smart lights, thermostats, and other sensors. I previously purchased an AEOTEC Z-Stick USB dongle for controlling Z-Wave compatible devices. Z-Wave is a wireless communications protocol predominantly used in home automation. There are quite a number of compatible devices that can be paired with the controller including the Aeon Labs DSC06106-ZWUS Smart Energy Switch in which I connected to the lights on the tree.

zwave switch zwave dongle

The OpenHAB software is fairly lightweight so I wanted to use as little hardware as possible to lessen power consumption. I decided to use my ODROID C1 as my OpenHAB and web server. OpenHAB requires no installation, only to download and unzip the OpenHAB files by issuing wget and unzip commands. I downloaded the runtime environment and all the addons to interface with z-wave by issuing the following commands:

wget https://github.com/openhab/openhab/releases/download/v1.5.0/distribution-1.5.0-addons.zip

wget https://github.com/openhab/openhab/releases/download/v1.5.0/distribution-1.5.0-runtime.zip

I used version 1.5.0 because it was the last known working version for the setup I was looking to use. I then copied the org.openhab.binding.zwave-1.5.0.jar file from addons.zip to the addons folder within the OpenHAB runtime folder to allow Z-wave binding. To allow OpenHAB to interface with the Z-stick, I modified the openhab.cfg file under configurations to assign the zwave port to /dev/ttyUSB0.

################################ Z-Wave  Binding ######################################
#
# The Z-Wave controller port. Valid values are e.g. COM1 for Windows and /dev/ttyS0 or
# /dev/ttyUSB0 for Linux
zwave:port=/dev/ttyUSB0

Once I paired the switch with the z-stick USB dongle, I plugged the z-stick into the C1 and ran the OpenHAB server by issuing the command sh start.sh to discover that the switch was assigned to node 16. The next step would be to add the node to the items config file and create a sitemap to control the switch. I created a default.items file in the items directory and entered the following:

Switch tree { zwave="16:command=SWITCH_BINARY" }

Within the sitemaps directory, I created a default.sitemap file and entered the following:

sitemap demo label="Lawler House"
{

        Frame {
                Switch item=tree
        }
}

To incorporate a live video feed, I used the Windows based Java application YAWCAM. YAWCAM allows assigning an IP address to a USB web cam. I attached a Logitech C920 to my ASUS REVO Build. Again, I tried to use a low power server to lessen power consumption.

To set up the C1 as the web server I set it up as a LAMP server for future projects by issuing the following commands:

sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install php5 libapache

I then created an index.php file in /var/www/html and entered the following:

<!DOCTYPE html>

<html>
<head>
<title>Lawler Tree</title>
<meta equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
        <body>
                <div align="center">
                <img id="camImg" src="http://[hostname].duckdns.org:8081/video.mjpg?q=30&amp;fps=33&amp;id=0.4496315997093916&amp;r=1450567547584" onmouseover="javascript:fixMenuColPos(this);showAllMenuCols();" onmouseout="javascript:hideAllMenuLayers();" onload="javascript:updateID();startPoll()" onerror="javascript:showErrorImage(true)" width="640" height="480" style="border: 1px solid #000000;">
                <p><iframe src="http://[hostname].duckdns.org:8080/openhab.app"></iframe></p>
        </body>
</html>

To allow web access, I set up port forwarding for the following applications: YAWCAM (port 8081), Apache (port 80), and OpenHAB (port 8080).

port forwarding

I also used the dynamic DNS service, DuckDns to resolve the Apache server to a hostname. Finally to start everything, I made sure Apache was running on the C1, streaming was started in YAWCAM on the ASUS Revo Build, and started the OpenHAB server by issuing the sh start.sh command.

openhab start yawcam stream lawlerhouse

Leave a Reply

Your email address will not be published. Required fields are marked *