Java Runtime Environment: openjdk version “11.0.9” 2020-10-20 LTS
openHAB version: 3.0
OpenHAB, Linux and MQTT beginner…
Hi, I’m using 6 Tinkerforge Air Quality bricklets for measuring temperature, humidity, etc. and bring the results into OH3 through the Tinkerforge MQTT API. After some challenges… I managed to get this working and show the results from the tinkerforge sensors in my sitemap. For this I have to start tinkerforge_mqtt manually and then manually give the mosquitto_pub commands (by connecting through SSH). Now I’m not sure how to make this happen automatically at startup.
I tried to start the tinkerforge_mqtt and mosquitto_pub commands by including it in rc.local. This did start the tinkerforge_mqtt for the first bricklet but not for the others. It also didn’t run the mosquitto_pub commands. I understand I have to make sure to run the mosquitto_pub commands AFTER mosquitto has started but I have no idea how to do that. I’m also not sure how to run multiple instances of the tinkerforge_mqtt.
Questions:
What would be the best way to start multiple instances of tinkerforge_mqtt at startup?
How do I make sure mosquitto is running before I run mosquitto_pub commands?
Hi, thanks and great tutorial! Yes, installed Mosquitto from the openhabian menus and Mosquitto itself starts automatically. Tinkerforge has it’s own daemon for MQTT and it’s this daemon that I need to run on startup. Looking at systemd now, will try that for the daemon.
For the mosquitto_pub commands, what would be the best way to give these commands? Through the rc.local? Or is there another way to run this at startup?
Yeah, a bit stuck here myself - not sure how you would automatically wait until both Mosquitto and Tinkerforge are running before sending these commands out. Maybe the systemd files have options or parameters which let you do that? You could certainly do this manually from openHAB - how often do you expect your device to actually shutdown/restart?
Hopefully someone more knowledgeable will suggest something more useful!
After starting the daemons through systemd I decided to try again with rc.local to run the shell script for the publish commands and that worked! I guess systemd starts faster than rc.local so now the daemons are running before I give the mosquitto_pub commands. Either way, it’s solved now.