Configuration - openHAB 2

We configure the openHAB2 automation platform.

To run the platform server, you must have java.

$ sudo apt-get install oracle-java8-jdk

First we will load the installation packages.

$ sudo mkdir /opt/openhab2
$ cd /opt/openhab2
$ sudo wget https://dl.bintray.com/openhab/mvn/org/openhab/distro/openhab/2.0.0/openhab-2.0.0.zip
$ sudo unzip openhab-2.0.0.zip

The add-on package is now installed directly from the platform interface. For initial configuration, you must run the server startup.

$ sudo ./start.sh 

If the automation platform starts successfully, the openHAB console appears.

Launching the openHAB runtime...

                          __  _____    ____      
  ____  ____  ___  ____  / / / /   |  / __ )     
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  | 
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /      
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/     
    /_/                        2.0.0
                               Release Build   

Hit '' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '' or type 'system:shutdown' or 'logout' to shutdown openHAB.

openhab> 

Launch the browser and specify the address of the openHAB server http: //a.b.c.d: 8080.
The initial system installation window opens. We select the recommended installation "Standart".
After the installation is complete, go to the configuration interface "PAPER UI"
Choose the menu "Add-ons" and install the necessary add-ons.

  • "BINDINGS" - "Exec Binding"
  • "PERSISTENCE" - "RRD4j Persistence"
  • "TRANSFORMATIONS" - "Exec Transformation" и "RegEx Transformation"
Go to the console and stop the server by pressing the key combination Ctrl + d

Create a configuration file for information sources.

$ sudo nano conf/things/_default.things 
Thing exec:command:devrm_t [command="/opt/broadlink/temp.py", interval=60, timeout=5]
Thing exec:command:devrm_a [command="/opt/broadlink/send.py /opt/broadlink/code/rm1_a", interval=0, timeout=2, autorun=false]
Thing exec:command:devrm_d [command="/opt/broadlink/send.py /opt/broadlink/code/rm1_d", interval=0, timeout=2, autorun=false]

Create a device configuration file.

$ sudo nano conf/items/_default.items
String devrm_t "Temp RM2 [%s °C]" {channel="exec:command:devrm_t:output"}
Switch devrm_a {channel="exec:command:devrm_a:run"}
Switch devrm_d {channel="exec:command:devrm_d:run"}
Number Temp_period

Create the UI configuration file.

$ sudo nano conf/sitemaps/_default.sitemap
sitemap default label="My Smart Home" {
 Frame label="Smart Switch" {
  Text item=devrm_t icon="temperature"
  Switch item=devrm_a label="Button A" icon="switch" mappings=["ON"="A"]
  Switch item=devrm_d label="Button D" icon="switch" mappings=["ON"="D"]
 }
 Frame label="Temp Chart" {
  Selection item=Temp_period icon="chart" label="Period" mappings=["0"="8 hours", "1"="Day", "2"="3 days", "3"="Week"]
  Image url="http://10.0.1.12:8080/rrdchart.png?items=devrm_t&period=8h" visibility=[Temp_period==0]
  Image url="http://10.0.1.12:8080/rrdchart.png?items=devrm_t&period=24h" visibility=[Temp_period==1]
  Image url="http://10.0.1.12:8080/rrdchart.png?items=devrm_t&period=3D" visibility=[Temp_period==2]
  Image url="http://10.0.1.12:8080/rrdchart.png?items=devrm_t&period=W" visibility=[Temp_period==3]
 }
}

Create a configuration file for the storage system.

$ sudo nano configurations/persistence/rrd4j.persist
Strategies {
        everyMinute     : "0 * * * * ?"
        default = everyChange
}
Items {
        devrm_t : strategy = everyChange, everyMinute, restoreOnStartup
}

Configuring and adding openHAB 2 to the system startup.

Create a service start script.

$ sudo nano /lib/systemd/system/openhab2.service 
[Unit]
Description=The openHAB 2 Home Automation Bus Solution
Documentation=http://docs.openhab.org
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=root
Group=root
GuessMainPID=yes
WorkingDirectory=/opt/openhab2
#EnvironmentFile=/etc/default/openhab2
ExecStart=/opt/openhab2/start.sh server
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save the script and add it to the system startup.

sudo systemctl daemon-reload
sudo systemctl enable openhab2.service

Reboot the system. After rebooting in the browser, open the address http://a.b.c.d:8080, where a.b.c.d is the IP address of Raspberry Pi. Go to the "BASIC UI" configuration interface. If everything is configured correctly, we will see the openHAB2 user interface that we configured.

Do not forget to install the official openHAB mobile application on your mobile device on Android or iOS.

Mobile wallpapers!  |  Linux certification!

You can copy information from this site for personal, noncommercial use only. Copying and use of information from this site for any other purpose is prohibited.  |  All trademarks are the property of their respective owners.
© 1998-2022 Sameak. All rights reserved.