Domoticz MQTT konfiguracja

1. update the raspberry pi: sudo apt-get update && sudo apt-get upgrade

2. install mosquitto: sudo apt-get install mosquitto mosquitto-clients

3. make a mqtt user: sudo mosquitto_passwd -c /etc/mosquitto/pwfile mqtt

4. add a couple of rules to the config: sudo nano /etc/mosquitto/mosquitto.conf

4. add these rules: allow_anonymous false 
password_file /etc/mosquitto/pwfile

5. save with these key combinations: ctrl+O and ctrl+X

6. open rc.local: sudo nano /etc/rc.local

7. put in before exit 0 the following:  /usr/sbin/mosquitto -d

8. restart your pi: sudo reboot

9. open domoticz via the web interface

10. go to: settings - hardware

11. add hardware: name: mqtt
type: MQTT Client Gateway with LAN interface
remote address: the ip address of your pi
Port: 1883
Username: mqtt
Password: password
Publish topic: out

Na koniec

pip3 install --requirement requirements.txt --target .

Domoticz Watchdog


function message() {
    echo "Watchdog: $1"
    /home/max/scripts/ "Watchdog: $1"

if curl --output /dev/null --silent --head --fail "http://localhost:8080"
    echo "Watchdog: Domoticz is running"
    message "Domoticz offline!!! Trying to start..."
    # doing restart is safer than start
    service restart

    # wait couple secs 
    sleep 20

    if curl --output /dev/null --silent --head --fail "http://localhost:8080"
        message "Domoticz is running back again!"

Dodajemy do CRON

0 * * * * /home/max/scripts/

Automatyczny reset Domoticza

Automatyczny reset Domoticza.

Gdy nie działa Domoticz sprawdzamy proces.

proces ps -e | grep domoticz

usluga sudo systemctl status domoticzy

skrypt uprawnienia i pozniej do crona , uruchamiasz co x min

oczywiscie [user] to katalog domowy

if $(ps -e | grep -q "domoticz") ; then
echo "(Domoticz aktualnie dziala.)"
else sudo /home/pi/domoticz/ restart &
echo "(Domoticz ponownie uruchomiony.)"