Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Ubuntu on x64

proxenus edited this page Jul 2, 2016 · 15 revisions

Introduction

Basically a step by step guide to install OpenHAB 1.8 on an Intel x86 machine using a few common bindings.

The content is mostly copy & pasted from other parts of the wiki.

Operating System

I've picked the LTS version for stability.

  • Download Ubuntu 14.04 LTS 64bit
  • Next, make a USB drive to install Ubuntu onto a spare machine:
    • If you're using Windows: Download Rufus
    • If you're using a unix machine: sudo ddrescue -f (infile or your .iso file) (outfile or your usb drive)
      • Example: sudo ddrescue -f ~/ubuntu-14.04-server.iso /dev/sda1
      • DDRescue is usually better and more user friendly than just dd as it gives you a timer and actual information as it works.

Install Ubuntu LTS

When going through the installation process, on the Packages options, pick the following options:

  • OpenSSH server (To administrate the server using PuTTY or your favorite terminal)
  • Samba Fileserver (To get access to the OpenHAB config files from Windows or OS X)

Dependencies

Java

We need Java 8, which is not included in Ubuntu 14.04 LTS, so we add a repository and install it:

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

It will ask you to accept the Terms and Conditions of Oracle to use Java.

MySQL for Persistence

sudo apt-get install mysql-server

Here, it will ask for a root password, saying that "While it is not necessary, it is suggested." Of which it is always a good idea to include a root password. Make sure, of course, to remember this password as well.

Start the Mysql commandline as root

sudo mysql -u root -p

Create a database for OpenHAB

CREATE DATABASE OpenHAB;

Create a user for OpenHAB

CREATE USER 'openhab'@'localhost' IDENTIFIED BY 'yourpassword';

Grant the user permissions for the database

GRANT ALL PRIVILEGES ON OpenHAB.* TO 'openhab'@'localhost';

Quit the Mysql command prompt

quit

Mosquitto as MQTT broker

MQTT, for those who don't know, is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.

Mosquito is the program/broker that implements the MQTT protocol.

sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
sudo apt-get install mosquitto

Setup TLS on Mosquitto (optional)

Copy the SSL CA to /etc/mosquitto/ca-certificates copy the SSL certificate and private key (.crt and .key) to /etc/mosquitto/certs

Protect your SSL certificate

cd /etc/mosquitto/certs
sudo chmod 600 *
sudo chown mosquitto *

Configure TLS

sudo nano /etc/mosquitto/conf.d/tls.conf

Add the following

listener 8883
tls_version tlsv1
cafile /etc/mosquitto/ca-certificate/ca.crt
certfile /etc/mosquitto/certs/server.crt
keyfile /etc/mosquitto/certs/server.key
require_certificate false

To restart Mosquitto, try one of the following;

sudo /etc/init.d/mosquitto restart
sudo service mosquitto restart

Portforward

Make sure you portforwarded the default mosquitto port 1883 to your server!

Install OpenHAB

Configure the repository

wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
sudo apt-get update

Install the runtime

sudo apt-get install openhab-runtime

Get needed addons

sudo apt-get install openhab-addon-binding-astro openhab-addon-binding-http openhab-addon-binding-mqtt openhab-addon-binding-mqttitude openhab-addon-binding-networkhealth openhab-addon-binding-wol openhab-addon-binding-zwave openhab-addon-persistence-mysql

Extra addons that are popular

Setup the configuration

Copy the default configuration

cd /etc/openhab/configurations/
sudo cp openhab_default.cfg openhab.cfg

openhab.cfg

sudo nano ./openhab.cfg

Create items, sitemaps and rules

This is where you should create items, sitemaps and rules.

See the Configuring the openHAB runtime wiki page.

Symlink com ports for Zwave devices

The Symlink page has the best instructions on how to add the info for three popular Z-Wave USB Sticks, as well as how to find the needed info for any other USB Sticks.

Set autostart

sudo update-rc.d openhab defaults

Note that for UBUNTU 15.10 and Raspian Jessie - or if you prefer using systemctl - this should be:

sudo systemctl enable openhab

Share the configuration files using Samba

This is for being able to see and edit the files easily from other machines, if you don't know how to use SSH.

sudo nano /etc/samba/smb.conf

Go to the bottom of the file and add

[OpenHAB]
comment = OpenHAB Configuration
path = /etc/openhab/configurations
browseable = yes
writeable = yes
guest ok = no
create mask = 0777
directory mask = 0777

Restart Samba

sudo service samba restart

Change permissions on the OpenHAB config to 777

cd /etc/openhab
sudo chmod -R 777 configurations/

Now you can go to your Windows machine using \\hostname\OpenHAB from your file explorer. Type the string into the Address bar (where the Directory names are at the top) and it should try to access that location. Next, it will ask for your login information, use your Ubuntu credentials.

Now, it should show the files that are available inside of /etc/openhab/configurations.

Use Notepad++ since most files have Unix linefeeds.

Installation


User Interfaces


Community

(link to openHAB forum)

Development



Misc


Samples

A good source of inspiration and tips from users gathered over the years. Be aware that things may have changed since they were written and some examples might not work correctly.

Please update the wiki if you do come across any out of date information.

Use case examples

Collections of Rules on a single page

Single Rules

Scripts


Release Notes

Clone this wiki locally