-
Notifications
You must be signed in to change notification settings - Fork 8
MQTT broker
NimHA depends on a MQTT broker, which connects all the different modules. The current setup requires Mosquitto. In the future Mosquitto will be replaced by a Nim MQTT broker.
Mosquitto is a message broker that implements the MQTT protocol versions 3.1 and 3.1.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.
Install using your package manager (sudo apt install mosquitto, sudo pacman -S mosquitto, etc.).
NimHA uses 3 different clients for connecting to the broker. You have to add all 3 users and it is required, that they use the same password.
Usernames:
- nimha
- nimhagate
- nimhawss
If you are going to use Owntracks, you can already now add another user for this. The password for this user should not be the same as the ones above. Call the user owuser
. See the section below to Owntracks.
Navigate to the Mosquitto folder
cd /etc/mosquitto
Open the password file
sudo nano passwd
Add users
Insert the usernames and your password (in clear text). The format needs to be username:password
.
nimha:exampePassword
nimhagate:exampePassword
nimhawss:exampePassword
Run
Passwords are stored in a similar format to crypt.
sudo mosquitto_passwd -U passwd
Open the configuration file
sudo nano /etc/mosquitto/mosquitto.conf
Insert the data at the bottom
password_file /etc/mosquitto/passwd
allow_anonymous false
port 1883 localhost
listener 8883
Config should look like this
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
include_dir /etc/mosquitto/conf.d
password_file /etc/mosquitto/passwd
allow_anonymous false
port 1883 localhost
listener 8883
Make sure that Mosquitto startup on boot:
sudo systemctl enable mosquitto
sudo systemctl daemon-reload
sudo systemctl start mosquitto
You need to open your firewall and/or forward you routers port to allow outside connections. This is required, if you are going to use Owntrack.
mosquitto_sub -d -t "#" -u USERNAME -P PASSWORD -h 192.168.1.160 -p 1883
mosquitto_pub -d -t TOPIC -m MESSAGE -u USERNAME -P PASSWORD -h 192.168.1.160 -p 1883
-b does not to work ?? using hack:
sudo mosquitto_passwd -c tmppwdfile username
# enter passwd
# copy content of tmppwdfile
# insert into real passwd file
- Home
- Requirements
- Install NimHA
- Optional
- Modules
- Tutorials (helpers, etc.)
- Development