Friday, 2 June 2017

HOME AUTOMATION: openHAB and myopenhab - Accessing your openHAB installation from the web

I've been thinking about the best way to access my openHAB installation from outside my network for a little while, but I've always been worried about the safety of exposing my network to the world so I never did it. Luckily though the folks at openHAB have created a free way to access your openHAB installation via the web without having to deal with port forwarding, firewalls and VPNs, This service is called myopenHAB.

My main reasons for enabling this feature is for integration with cloud services like IFTTT, which I am using for integration with the Google Home Assistant. I'll share more on that topic in another post.


Plugin Installation

Log in to your local openHAB installation and navigate to the PaperUI interfact, From here navigate to the Add-ons tab and search for "openHAB Cloud Connector" in the MISC page of add-ons.


Installation takes while so be patient. It took around 20 minutes on my Raspberry Pi 3.
While we are waiting for the add-on to install we will get our myopenHAB account setup and ready for action.

myopenHAB Account Setup

Navigate to the myopenHAB website and then make your way to the registration page. Create your account and be sure to verify your account once created. You will be sent a verification email to the registered email address, follow the links to confirm your account. If you don't do this you may end up stuck with your device only ever showing "Offline" even if you have everything configured correctly.
Once you have setup you account check back in to your openHAB add-on installation. Once it is complete we need to grab a couple of auto-generated strings to link our openHAB add-on installation to the cloud service. We need to grab the UUID and Secret that were generated by the openHAB Cloud add-in and add them to our account:


Use the following commands to view your UUID and Secret from the command line:
 nano /var/lib/openhab2/uuid  
 nano /var/lib/openhab2/openhabcloud/secret  

Once these settings have been added to myopenHAB if everything was done right you should see your device come online. If not, there are a few things that could have gone wrong that I'll cover in the troubleshooting section below.


Add-on Configuration

With the add-on installed the last thing we need to do is enable remote access of our device and exposing items to 3rd party services like IFTTT
openHAB Cloud add-on configuration


Add the items you would like to be exposed to external services like IFTTT here by selecting the items from the drop down box and save your configuration.

If it has all worked you should now be able to navigate to the myopenHAB page, login and then follow the links to your openHAB dashboard.

myopenHAB logged in


Troubleshooting

I ran in to a few issues when connecting my openHAB installation to the myopenHAB cloud service:

  1. I had missed a character off the secret. 
  2. I was running an old version of oracle java. I fixed this by simply doing an apt-get update then apt-get upgrade followed by a reboot. There is also another issue with open-jdk that is described in this post

No comments:

Post a Comment