Skip to main content

Configuring openHAB on Rasberry pi


General Configuration - openhab.cfg

The runtime comes with one core configuration file, the file openhab_default.cfg. The purpose of this file is to define all basic settings, such as IP addresses, mail server, folder locations etc.
The file also contains settings for all (optional) bindings. These settings are automatically dispatched to the according binding. For this, all settings come with a namespace (such as "mail:" or "knx:") to identify the associated binding.
First thing after unzipping the runtime should be creating a copy of openhab_default.cfg to openhab.cfg
cd /usr/share/openhab/configurationssudo cp openhab_default.cfg openhab.cfgsudo nano openhab.cfg

All personal settings should always only be done in this copy. This ensures that your settings are not lost, if you unzip a new version of the runtime to your openHAB home directory.
The openhab_default.cfg file comes with extensive comments which explain, what settings are available and what can be configured with them. If you have any doubts, please ask on the discussion group.
To activate a binding uncomment the specific settings.
Individual Configuration
Besides the *.cfg files and *.xml files (see below: loggin) the configuration folder /etc/openhab/configurations consists of dedicated subfolders for specific topics. For each topic, there should be another sub folder, such as /etc/openhab/configurations/items.

Item Definitions

Item files are stored in /etc/openhab/configurations/items.
Although items can be dynamically added by item providers (as OSGi services), it is usually very practical to statically define most of the items that should be used in the UI or in automation rules.
These static definition files follow a certain syntax. This syntax will be explained here. (For the technical interested: This syntax is in fact a Xtext DSL grammar.)
Please visit the Items page on how to configure items.

Sitemap Definitions

Sitemap files are stored in /etc/openhab/configurations/sitemaps.
Sitemaps are a declarative UI definition. With a few lines it is possible to define the structure and the content of your UI screens.
(For the technical interested: This syntax is in fact a Xtext DSL grammar.)
Please see page sitemaps for a description on how to create sitemaps.

Automation

Rule files are stored in /etc/openhab/configurations/rules.
Script files are stored in /etc/openhab/configurations/scripts.
Rules provide flexible logic to openHAB for automation which can also use scripts(macros) using related events and actions..
Please visit the automation section for further detailes.

Persistence

Script files are stored in /etc/openhab/configurations/persistence.
Persistences can store item states over a time (a time series).
Please visit the persistence section for further details.

Transformation

Transformations files are stored in /etc/openhab/configurations/transformation.
Purpose: tbd...
Please visit the transformation section for further details.

Advanced Configuration

general

You will find the openHAB configuration under /etc/openhab. If you change configuration files it will not be overwritten by updates or upgrades.

${openhab_home}/etc/default/openhab

USER_AND_GROUP=openhab:openhab
HTTP_PORT=8080
HTTPS_PORT=8443
TELNET_PORT=5555
OPENHAB_JAVA=/usr/bin/java

Logging

Configuration

The runtime uses:
/etc/openhab/logback.xml and /etc/openhab/logback_debug.xml
logback_debug.xml is used when you run openHAB in debug mode (start_debug.sh) and can be used as template.
You can change logback.xml to your needs.

Enable Debug Mode

While you’re still trying to get OpenHAB working correctly, it can be useful to enable a more verbose debug log that lists everything, and not just the important stuff. To enable this mode, open up the OpenHAB Config shared folder, and edit the logback.xml. On line 40, change the following line to read DEBUG instead of INFO. You’ll need to restart after changing this.
INFO"/>
This is a global change, so you’ll be getting a lot more info once you tail the log file.

Log files

The runtime log: /var/log/openhab/openhab.log Further log files are placed also into: /var/log/openhab/

Jetty

/etc/openhab/jetty/etc/

Runtime generated files

/var/lib/openhab

login.conf

/etc/openhab/login.conf

users.cfg

/etc/openhab/users.cfg

quartz.properties

/etc/openhab/quartz.properties

Comments

Popular posts from this blog

Setting up NUT on a Raspberry Pi for Greencell USB UPS

  Background This article provides a guide for installing a USB UPS attached to a Raspberry Pi. In my case I had purchased a GreenCell 600 360W USB UPS. Integrating the USB UPS requires using NUT (Network UPS Tools). This UPS uses the blazer_usb driver. Installation NUT Plug-In the UPS USB-Connection to the host. My device showed up as Device 006 below: # lsusb   Bus 001 Device 006: ID 0001:0000 Fry's Electronics MEC0003 Bus 001 Device 005: ID 0bda:0309 Realtek Semiconductor Corp. USB3.0-CRW Bus 001 Device 004: ID 0658:0200 Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) - UZB Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub Install the NUT package with the apt package manager:   sudo apt-get install nut Make some configurations and changes in the nut directory /etc/nut: # cd /etc/nut drwxr-xr-x 2  root nut  4096   Jan 11 00:49 .

Sending SMS Messages from openHAB

Background So I setup sending SMS messages from my Raspberry Pi (see article I wrote here ) and have a bash script to automate this. The next step is to integrate this into my openHAB server, so I can send SMS messages to my mobile phone when my UPS system (managed by openHAB) is on battery power (e.g. due to a mains network failure). Installing the EXEC Binding to openHAB See here . Note especially the requirement to add commands to the whitelist. Adding a Thing to openHAB Once the EXEC binding is installed the next step is to setup a thing file to use the binding for sending bash shell commands:  $ nano /etc/openhab/things/exec.things Add the following line: Thing exec:command:sendsms [ command="/usr/local/bin/sendsms.sh %2$s", autorun=true, interval=0 ] Save the file. As you can see this thing is used to pass the command to run the bash shell script to send an SMS and pass the text sent as "%2$s" to the script. Adding Items to openHAB Two items are required, one

SMS messaging on Raspberry Pi with Gammu

Background Ever wanted to be alerted when the power fails at home? I typically worry that food in the freezer will go off when I am on vacation! (Yep, that's how I tick). I have recently installed a UPS system which I use to protect various IT and network devices from instant power loss, enabling them to shutdown gracefully. This is particulary important for my Raspberry Pi (Pi) devices, which are sensitive to this issue, as SD-Cards can be corrupted and then not re-boot.  The UPS I have installed interfaces via USB with my Raspberry Pi server using the Linux Network UPS tools NUT so that I can monitor status changes (e.g. grid power loss) and this is further integrated into my openHAB -based home automation system. This setup will be covered in another post.  I wanted to additionally be alerted when grid power fails via SMS to my mobile phone. To do this I have purchased a pre-owned USB Internet Surf Stick and a pay-as-you-go SIM card (zero cost) which I can load with credit. I a