This discussion was continued over private message, for future reference: the system (Raspbian Jessie) was set up from scratch using the following tutorial and now works fine with mosquitto and mqtt:
Login via ssh
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get upgrade
install mosquitto:
pi@raspberrypi:~ $ wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
pi@raspberrypi:~ $ sudo apt-key add mosquitto-repo.gpg.key
pi@raspberrypi:~ $ cd /etc/apt/sources.list.d/
pi@raspberrypi:~ $ sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install mosquitto mosquitto-clients python-mosquitto
test mosquitto:
open two putty windows, in the first one:
pi@raspberrypi:~ $ mosquitto_sub -h 127.0.0.1 -t myTopic/#
in the second one:
pi@raspberrypi:~ $ mosquitto_pub -h 127.0.0.1 -t myTopic/Temp -m "test1"
Now you should see “test1” in the first window.
Install openhab:
pi@raspberrypi:~ $ wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
pi@raspberrypi:~ $ echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install openhab-runtime
pi@raspberrypi:~ $ sudo systemctl daemon-reload
pi@raspberrypi:~ $ sudo systemctl enable openhab
pi@raspberrypi:~ $ sudo reboot
install mqtt and rrd4j binding:
pi@raspberrypi:~ $ sudo apt-get install openhab-addon-binding-mqtt
pi@raspberrypi:~ $ sudo apt-get install openhab-addon-persistence-rrd4j
Configuration files:
copy openhab_default.cfg to openhab.cfg:
pi@raspberrypi:~ $ sudo cp /etc/openhab/configurations/openhab_default.cfg /etc/openhab/configurations/openhab.cfg
edit openhab.cfg:
pi@raspberrypi:~ $ sudo nano /etc/openhab/configurations/openhab.cfg
replace
#mqtt:<broker>.url=tcp://<host>:1883
with
mqtt:mosquitto.url=tcp://localhost:1883
define items:
pi@raspberrypi:~ $ sudo nano /etc/openhab/configurations/items/mqtt.items
Switch Test_Switch1 "Testswitch 1" {<see wiki>}
Switch Test_Switch2 "Testswitch 2" {<see wiki>}
define sitemap:
pi@raspberrypi:~ $ sudo nano /etc/openhab/configurations/sitemaps/default.sitemap
sitemap default label="MQTT"
{
Switch item=Test_Switch1
Switch item=Test_Switch2
}
config for rrd4j persistence:
pi@raspberrypi:~ $ sudo nano /etc/openhab/configurations/persistence/rrd4j.persist
// Persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
everyMinute : "0 * * * * ?"
// If no strategy is specified for an item entry below, the default list will be used.
default = everyChange
}
/*
* Each line in this section defines for which item(s) which strategy(ies) should be applied.
* You can list single items, use "*" for all items or "groupitem*" for all members of a group
* item (excl. the group item itself).
*/
Items {
* : strategy = everyMinute, restoreOnStartup
}
reboot system
pi@raspberrypi:~ $ sudo reboot
call in browser:
http://<your_ip_Pi>:8080/
oder
http://raspberrypi:8080/