We move on to the next stage, install and configure the openHAB 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/openhab $ cd /opt/openhab $ sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-runtime.zip $ sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-addons.zip $ sudo unzip distribution-1.8.3-runtime.zip
We add the add-on package to the temporary folder, in order to accelerate the loading of the platform, we will take only the necessary modules.
$ sudo unzip distribution-1.8.3-addons.zip -d addons-distrib $ sudo rm distribution-1.8.3-*
We copy the modules we need.
$ sudo cp addons-distrib/org.openhab.binding.exec-1.8.3.jar addons/ $ sudo cp addons-distrib/org.openhab.binding.ntp-1.8.3.jar addons/ $ sudo cp addons-distrib/org.openhab.persistence.logging-1.8.3.jar addons/ $ sudo cp addons-distrib/org.openhab.persistence.rrd4j-1.8.3.jar addons/
Create a device configuration file.
$ sudo nano configurations/items/default.items
Group All Group devrm (All) DateTime Date "Date [%1$td %1$tb %1$tY]" { ntp="Europe/Moscow:ru_RU" } Number devrm_t "RM2-T [%.1f °C]" (devrm) { exec="<[/opt/broadlink/temp.py:300000:]" } Switch devrm_01 (devrm) { exec=">[ON:/opt/broadlink/send.py /opt/broadlink/code/rm1_a] >[OFF:/opt/broadlink/send.py /opt/broadlink/code/rm1_d]" }
Create the UI configuration file.
$ sudo nano configurations/sitemaps/default.sitemap
sitemap default label="My Smart Home" { Frame label="Date" { Text item=Date icon="calendar" } Frame label="Broadlink RM Pro" { Switch item=devrm_01 label="Switch" icon="switch" mappings=["ON"="On.","OFF"="Off."] Text item=devrm_t icon="temperature" Image url="http://10.0.1.12:8080/rrdchart.png?items=devrm_t&period=3D" } }
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 }
Create an openHAB automation platform configuration file.
$ sudo cp configurations/openhab_default.cfg configurations/openhab.cfg
Configuring and adding openHAB to the system startup.
Create a service start script.
$ sudo nano /etc/init.d/openhab
#!/bin/sh ### BEGIN INIT INFO # Provides: openhab # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: OpenHAB Daemon # Description: Build your smart home in no time! ### END INIT INFO ROOT_DIR=/opt/openhab eclipsehome="$ROOT_DIR/server"; HTTP_PORT=8080 HTTPS_PORT=8443 cp=$(find $eclipsehome -name "org.eclipse.equinox.launcher_*.jar" | sort | tail -1); DAEMON_USER=root DAEMON_NAME=openhab DAEMON=/usr/bin/java DAEMON_ARGS="-Djna.boot.library.path=/usr/lib/jni -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=$HTTP_PORT -Djetty.port.ssl=$HTTPS_PORT -Djetty.home=. -Dlogback.configurationFile=configurations/logback.xml -Dfelix.fileinstall.dir=addons -Djava.library.path=lib -Djava.security.auth.login.config=./etc/login.conf -Dorg.quartz.properties=./etc/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Dfelix.fileinstall.active.level=4 -Djava.awt.headless=true -jar $cp $* -console " PIDFILE=/var/run/$DAEMON_NAME.pid . /lib/lsb/init-functions do_start() { log_daemon_msg "Starting system $DAEMON_NAME daemon" start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --chdir $ROOT_DIR --exec $DAEMON -- $DAEMON_ARGS log_end_msg $? } do_stop() { log_daemon_msg "Stopping system $DAEMON_NAME daemon" start-stop-daemon --stop --pidfile $PIDFILE --retry 10 log_end_msg $? } case "$1" in start|stop) do_${1} ;; restart|reload|force-reload) do_stop do_start ;; status) status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? ;; *) echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}" exit 1 ;; esac exit 0
Save the script, make it executable and add it to the system's startup.
$ sudo chmod a+x /etc/init.d/openhab $ sudo update-rc.d openhab defaults
Now restart 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. If everything is configured correctly, we will see the openHAB 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!