Raspberry Pi installation - StefCoene/velserver GitHub Wiki
I recently installed velserver on a new PI and these are the steps I did:
- Give your PI a fixed IP address in config file
/etc/dhcpcd.conf
(If your network is NOT 192.168.1.0/255.255.255.0, you also have to change the apache configuration fileapache-velserver.conf
):
# Custom static IP address for eth0. interface eth0> static ip_address=192.168.1.3/4 static routers=192.168.1.1 static domain_name_servers=192.168.1.10
- Install needed packages:
apt upgrade apt-get autoremove apt-get install screen apt-get clean
mkdir /usr/local/zulu tar xvzf ezdk-1.8.0_112-8.19.0.31-eval-linux_aarch32hf.tar.gz -C /usr/local/zulu/ update-alternatives --install /usr/bin/java java /usr/local/zulu/bin/java 100 update-alternatives --config java
From http://docs.openhab.org/installation/linux.html#package-repository-installation:
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add - echo 'deb http://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list apt update apt-get install openhab2 /bin/systemctl daemon-reload /bin/systemctl enable openhab2.service
- Config file:
/etc/openhab2/addons.cfg
I want astro binding for sunrise and sunset and I have a Nest protect. I want mysql persistent for graphs. We need http binding and jsonpath transformation for velserver.
binding = astro,http1,nest1 persistence = mysql transformation = jsonpath
- Config file:
/etc/openhab2/services/mysql.cfg
Use the appropriate settings for you environment.
url=jdbc:mysql://mysql:3306/openhab user=openhab password=openhab reconnectCnt=10
- Create config file:
/etc/openhab2/items/velbus_group.items
These groups are also defined in the config file of velserver and are used to group the items.
Group G_DIMMERS_ALL <slider> Group G_TEMPERATURE_ALL <temperature> Group G_HEATER_ALL <temperature> Group G_BUTTON_ALL Group G_RELAY_ALL Group G_BLINDS_ALL "Blinds" <rollershutter> Group G_COUNTER_ALL Group G_COUNTERCURRENT_ALL Group G_ALL
- I assume velserver will be installed in /home/velbus
- Go to /home/velbus and pull the git repository:
mkdir /home/velbus cd /home/velbus git clone https://github.com/StefCoene/velserver
- Make the openHAB items file and make sure we can update it from the website (TODO: better security):
touch /etc/openhab2/items/velbus.items chown www-data: /etc/openhab2/items/velbus.items
- Install apache2 ad some extra modules we need:
apt-get install apache2 libdbi-perl libhttp-message-perl libwww-perl libdbd-mysql-perl libjson-perl libcgi-session-perl libhash-merge-perl libconvert-color-perl
- Configure apache:
ln -s /home/velbus/velserver/etc/apache-velserver.conf /etc/apache2/sites-enabled/001-apache-velserver.conf a2enmod cgi service apache2 restart
- Configure logrotate:
ln -s /home/velbus/velserver/etc/logrotate-velserver.cfg /etc/logrotate.d/velserver
- Config file
mysql.cfg
I have a mysql server running on an other hosts (alias mysql):
host = mysql name = velbus user = velbus pass = velbus
- Config file
openHAB.cfg
# openHAB webservice REST API URl REST_URL = http://localhost:8080/rest/items # URL used by openHAB # No '"' ! BASE_URL = http://localhost/velserver/service.pl # openHAB items file that will populated with Velbus devices # Make sure that the user that runs the website can write to this file ITEM_FILE = /etc/openhab2/items/velbus.items # Group definitions # GROUP_<openHAB group> = <list of Velbus devices/channels> GROUP_G_DIMMERS_ALL = %^Dimmer.+ GROUP_G_BLINDS_ALL = %^Blind.+ GROUP_G_TEMPERATURE_ALL = %^Temperature.+ GROUP_G_HEATER_ALL = %^Heater.+ GROUP_G_RELAY_ALL = %^Relay.+ GROUP_G_COUNTER_ALL = %^Counter.+ %^Divider.+ GROUP_G_COUNTERCURRENT_ALL = %^CounterCurrent.+ GROUP_G_BUTTON_ALL = %^Button.+ GROUP_G_ALL = %.
- Config file
velbus.cfg
install_directory = /home/velbus/velserver host = localhost port = 3788
- compile velserv or use a pre-compiled binary in the bin directory
cd /home/velbus/velserver/src gcc -o velserv velserv.c -lpthread
- add the command
/home/velbus/velserver/bin/velserv
to/etc/rc.local
before the exit 0 at the end of the file.
- add this before the exit 0 at the end of the file to start logger.pl at boot time:
screen -d -m -S logger /home/velbus/velserver/bin/logger.pl
You can use screen -r
to resume the screen background process.
- You can add this entry to your crontab for time sync:
0 4 * * * /home/velbus/velserver/bin/commands.pl -o date