Hello, openHAB enthusiasts! I’m thrilled to share my journey of setting up openHAB2 from scratch. If you’re new to the world of home automation, this guide will walk you through the entire process, from installation to creating your first sitemap and rules. Let’s dive in!
Step 1: Choosing the Right Directory and Downloading the Latest Snapshot
First, I created a dedicated user and directory for openHAB2 to keep everything organized. Here’s how I did it:
bash
useradd openhab
mkdir /opt/openhab
chown openhab. /opt/openhab
su - openhab
cd /opt/openhab
Next, I downloaded the latest snapshot release using curl
:
bash
curl -O https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-2.0.0-SNAPSHOT.tar.gz
To make updates easier, I created a soft-link for the current release:
bash
mkdir openhab_date +%F
tar xvzf openhab-2.0.0-SNAPSHOT.tar.gz -C openhab_date +%F
&& rm -f openhab-2.0.0-SNAPSHOT.tar.gz
ln -s openhab_date +%F
current
Step 2: Installing the Oracle Java Development Kit (JDK)
openHAB2 requires Oracle JDK, so I installed it using yum
:
bash
yum localinstall jdk-8u112-linux-x64.rpm
I also added some environment variables to /etc/bashrc
to ensure Java is recognized:
bash
export JAVA_HOME=/usr/java/latest
export PATH=/usr/java/latest/bin:$PATH
Step 3: Starting Up openHAB2
With everything set up, I started openHAB2 for the first time:
bash
cd /opt/openhab/current
./start.sh
This launched the Karaf console, where I could monitor logs and manage the system.
Step 4: First-Time Setup
After starting openHAB2, I accessed the dashboard at <http://IP-of-your-machine:8080>
. I chose the “Standard” package to install Paper UI, Basic UI, and Habpanel.
Step 5: Configuring openHAB2 and Installing Add-Ons
Using Paper UI, I installed the Network Binding and discovered my network devices. I added my mobile phone as a thing and linked its channels to items.
Step 6: Creating a Sitemap
I created a simple sitemap to display my items:
sitemap
default label=“My First Sitemap”
{
Switch item=FragglesMobile label=“Fraggles mobile”
Switch item=Wallplug label=“My wallplug”
}
I also set this as the default sitemap in Paper UI.
Step 7: A Simple Rule
To demonstrate rules, I created a presence detection rule for my mobile phone:
rule
rule “Wallplug ON”
when Item FragglesMobile changed from OFF to ON
then
sendCommand(Wallplug, ON)
end
rule “Wallplug OFF”
when Item FragglesMobile changed from ON to OFF
then
sendCommand(Wallplug, OFF)
end
Step 8: Persistence
To ensure states are restored after a restart, I installed the MapDB Persistence service. I configured it to save states on every change and restore them on startup.
Conclusion
Setting up openHAB2 was a rewarding experience, and I’m excited to continue exploring its capabilities. If you’re new to openHAB2, I hope this guide helps you get started. Feel free to share your experiences or ask questions below—I’m happy to help!
Cheers,
[Your Name]