The Hubitat Journey Continues – WebCoRE

The continuing saga of Local Processing – WebCoRE 

WebCoRE LogoIn my post yesterday I described the initial migration steps from SmartThings’ (ST) cloud based home automation to Hubitat’s local processing solution. I am extremely impressed with the speed of Hubitat Elevation’s (HE) automations, and the depth of integrations they already provide, and continue to develop. Another benefit is the depth of the Hubitat Community‘s bench of developers and integrators. A case in point is the Hubitat port of SmartThing’s WebCoRE, a rules engine that allows you to quickly model, write and deploy complex automations.

As a SmartThings refugee in the state of Hubitat, I had tons of pistons (what WebCoRe calls its automation routines) and the thought of migrating them into Hubitat’s Rules Machine (RM), the native automation rules engine, was daunting. Further, there are some controls/options that exist in WebCoRE that are not currently exposed in RM.  What’s a person to do in this situation? Roll a RaspberryPi to serve the WebCoRE dashboard, and install the WebCoRE applications on the Hubitat. 

I am not taking any credit for any of this work – it was all done by the phenomenal community – I am just putting all the bits here in one place so that others may find an simple soup-to-nuts process to get running – as well as documenting what I did so I can do it again if I need to. 🙂

Setting up the RaspberryPi Dashboard Server

So, the first thing is to install Raspbian on your Pi. I wont get into how to do this here, I assume that you know how to install Raspbian, or can follow the directions on the Raspberry website. As my device was going to be a webserver only, I installed Rasbian Lite – I do not need a GUI for this and it is a smaller installation this way. Once you get that finished and do some basic configurations with raspbi-config I suggest that you set up your static IP address for the Pi. You can do this one of two ways; what I did was simply create a static DHCP lease for the Pi’s MAC Address. Alternatively you can configure a static IP in your Pi’s networking configuration, this post provides some guidance on how to do it.

Once you get the network setup correctly, and run your initial updates using the following at a command prompt

sudo apt-get update;sudo apt-get upgrade -y

Next step is to get Apache installed, configured and running, straight forward process

sudo apt-get install apache2 -y

Now you need to make sure you have GIT installed and grab the web app for the Dashboard. I did this all as the default user pi 

cd ~
git clone https://github.com/ajayjohn/webCoRE
cd webCoRE
git checkout hubitat-patches
cd dashboard
sudo ln -s `pwd` /var/www/webcore

What the above does is get the WebCoRE git repository and the Hubitat branch patches cloned (downloaded) and placed in your /home/pi/webCoRE directory with the dashboard in /home/pi/webCoRE/dashboard 

Configure Apache

So we have the files for the web dashboard on the pi, and created a symbolic link to them in the webserver’s file structure (on the pi and other linux variants apache’s web files default to the /var/www/ directory structure). Here is a bit of a gotcha – if you want to browse to the dashboard, now you would need to use http:///dashboard/ but WebCoRE expects to be in the root directory of the web server. We accomplish this by editing /etc/apache2/sites-available/000-default.conf with your favorite text editor such as vi or nano etc. Keep in mind, the apache configuration files are owned by root, so you need to use sudo to edit the file (e.g.: sudo vi <filename>). You should replace the contents of this file with the following (I stripped out all the default comments for brevity):

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        #The DocumentRoot is changed to the webCoRE installation symlink directory
        DocumentRoot /var/www/webcore/

        #We need to allow all overrides for the dashboard directories
        <Directory "/var/www/webcore">
                AllowOverride All
        </Directory>
        #These are not changed - they are the default log directives - change as you need/want
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
     </VirtualHost>

We also need to enable apache’s mod_rewrite which is simply done by:

sudo a2enmod rewrite; sudo service apache2 restart

Install and Configure WebCoRE in Hubitat

Now we go into the Hubitat Portal and install the apps. Open your browser and enter go to your Hubitat hub’s IP, in the left hand menu click Apps Code > New App (you will need to do this four times, once for each of the WebCoRE apps/child apps below). Thanks to ajayjohnm for making this git available!

You will need to copy each of these into a new app in Hubitat and save each:

Once these are installed, go to Apps > Load New App you are presented a list of applications you can install on your Hub. Scroll down to the User Apps section and select WebCoRE to start the configuration of your local instance of WebCoRE. 

First you will need to name your instance – I simply called mine WebCoRE Local (I know its boring such is life). Read this page! At the bottom you will need to set a password for your dashboard. Even though this is all local, use a strong one! Also keep the default to change the password monthly – yes its a pain in the ass – but the whole point of running things locally is speed and security. 

After hitting next, you are presented a page to select all your devices that you want to manage or use as triggers/conditions in this instance. Go through and enable as many as you want and then hit Next at the bottom of the page. You are now configured and (almost) ready to go. I ran into an issue at this point and for whatever reason I needed to re-enable my devices as they didn’t ‘take’ on the first try – YMMV.

Now lets set up your new instance to use the Dashboard you just set up on the RaspberryPi. In the Apps List, open your WebCoRE instance (WebCoRE Local in my setup). You want to configure this page as shown below:

Hubitat WebCoRE Instance Configuration

As you can see, you need to flip the Use custom endpoints switch, and enter the URL of your Hubitat Portal in the first box, and the URL of your RaspberryPi dashboard in the second box. Important: Do Not Enter a Trailing Slash for the RaspberryPi URL. This means enter for example http://192.168.1.100 not  http://192.168.1.100/ – The trailing slash will cause issues with rewrites from what I can gather.

Gentlemen – Start your (automation) engines!

You can now open your RaspberryPi dashboard in your browser. If you are asked for a Registration Number, go back to the Hubitat’s WebCoRE settings page and click Register Browser (see image above). This will give you a temporary registration credential, enter this when prompted, log in with your password and you are presented an empty WebCoRE dashboard similar to the following (I already have a couple of pistons ported over):

WebCoRE Dashboard

Now you’re all ready to start creating your pistons and automations. For more information on how to use WebCoRE, functions, events, triggers, example pistons, etc., head on over to the WebCoRE Community Forums. This is another great community of folks and I’ve given and received a ton of help there. If you can imagine the routine, it is probably already covered. Seriously!

If there is anything that gets you hung up feel free to post a comment, or head over to the Hubitat forum thread that a majority of this post is based on.

Share Some Love!


This entry was posted in Computing, SmartHome, Technology and tagged , , , , , , , .