OpenHAB...getting there...

A project log for Home Automation - Garage Door Opener

Extract best practices from existing garage door projects. Build version that suites my needs; eventually integrate into other HA efforts.

luffmanbluffmanb 04/22/2016 at 22:180 Comments

Okay... After a few hours of digging, trial-n-error, and frustration, I sorta' have some things working w/ my Nest Thermostat. Still some work ahead, but here's what I've done to get this far:

As stated earlier, I started w/ this article (but jumped around stuff like Samba; not a big fan of it or M$ Windows, and I don't need it since I'm running everything at home on Linux, Mac, or iOS):

Also the Phillips Hue example didn't do much for me, so jumped at that point to OpenHAB's wiki on Nest Bindings:


(Steps 2 & 3 take about 20 minutes by themselves.)

  1. Fresh install of Rasbpian "Jessie" full version (includes Java stuff needed; OpenHAB is built on Java.)
  2. Ensure RPi's firmware up-to-date:

  3. Ensure running latest software:

    sudo apt-get update -y
    sudo apt-get upgrade -y
  4. Install OpenHAB runtime. (Not real keen on this since diverges from original project, but shortest path to proof of concept and all that; perhaps I'll rebuild from scratch once I get things working.)

    wget -qO - '' | sudo apt-key add -
    apt-key add -
    echo "deb stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
    sudo apt-get update
    sudo apt-get install openhab-runtime
    sudo update-rc.d openhab defaults
  5. Correct ownership of files:

    sudo chown -hR openhab:openhab /etc/openhab
    sudo chown -hR openhab:openhab /usr/share/openhab
  6. Start tracking log file in new terminal window:

    tail -f /var/log/openhab/openhab.log
  7. Confirm OpenHAB is running and webpage is ready to work (just missing the guts, so expect error listing.)

    URL: http://raspberry.local:8080
  8. Download the demo site form, unzip, move files to where belong, correct ownership:

    sudo cp -r configurations/ /etc/openhab
    sudo cp -r addons/ /usr/share/openhab
    sudo chown -hR openhab:openhab /etc/openhab
    sudo chown -hR openhab:openhab /usr/share/openhab
  9. Confirm it works:

    URL: http://raspberry.local:8080/
  10. Now install Nest Binding Add-on (actually first downloaded latest stable from OpenHAB w/o thinking, then went back and grabbed from apt-get source added earlier in instructions):

    sudo apt-get install openhab-addon-binding-nest
    sudo chown -hR openhab:openhab /usr/share/openhab/addons
  11. Copy openhab_default.cfg to openhab.cfg.

    cd /etc/openhab/
    sudo cp openhab_default.cfg openhab.cfg
  12. Using the Nest-Binding directions, Convince Google to let you tinker w/ your own device:
    1. Register as a developer.
    2. Register your "product".
    3. Gather your nest:client_id and nest:client_secret codes.
    4. Use the Authorization URL to get your pin_code.

  13. Edit open.cfg: uncomment out the three lines of code for the data you just gathered under the Nest section, and add said data to those lines.
  14. Using Vim (sudo apt-get install vim -y) , copy code samples of nest.items and nest.sitemap from and paste into new files w/ these names in their respective directories. Since I do not own the Smoke+CO alarm, left this extra code out. Also did the trick they used in copying existing icons to newly named representations for Nest controls.

  15. Change names of thermostat and references to item to match what was registered already w/ Nest account. In other words, their demo uses "Dining Room" and "dining_room*"; if your thermostat is name, "Yo Mama", then either edit manually or use something like this:

    sed -i '/Dining Room/c\Yo Mama' /etc/openhab/items/nest.items
    sed -i '/dining_room/c\yo_mama' /etc/openhab/items/nest.items
    sed -i '/dining_room/c\yo_mama' /etc/openhab/sitemaps/nest.sitemap

    (I would still recommend cat/less your files out to double-check yourself when done.)

  16. Test and tweak...