Domoticz is a lightweight, open-source home automation system designed to help users manage a variety of smart devices and sensors. Its self-hosted nature makes it an ideal choice for those who value customization, privacy, and full control over their automation setups. This guide will walk you through the process of installing Domoticz, configuring it with reverse proxy settings, managing logs, performing backups, updating the app, and leveraging its unique features.
Installing Domoticz
π¦ Docker/Docker Compose Setup
Using Docker simplifies deployment and maintenance. Below is a docker-compose.yml
file tailored for Domoticz:
version: '3'
services:
domoticz:
image: domoticz/domoticz:latest
container_name: domoticz
restart: unless-stopped
ports:
- "8080:8080" # Web interface
volumes:
- ./domoticz_data:/opt/domoticz/config
environment:
- TZ=Europe/Amsterdam
networks:
default:
driver: bridge
Deploy Domoticz with the below commands:
mkdir domoticz && cd domoticz
nano docker-compose.yml # Paste the above YAML
docker-compose up -d
This will start Domoticz on port 8080, storing configuration data in the domoticz_data
directory.
π Manual Installation
To install Domoticz manually on a Linux server:
sudo apt update && sudo apt upgrade -y
sudo apt install build-essential cmake libsqlite3-dev libcurl4-openssl-dev zlib1g-dev -y
wget https://www.domoticz.com/releases/domoticz_linux_x86_64.tgz
tar -xvzf domoticz_linux_x86_64.tgz
cd domoticz
./updatebeta
./domoticz -www 8080
This sets up Domoticz and starts it on port 8080. For persistent operation, consider setting it up as a systemd service.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
To serve Domoticz through Nginx, create the following configuration file:
sudo nano /etc/nginx/sites-available/domoticz.conf
Add the following content:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/domoticz.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx
π SSL/TLS Setup
Secure the connection using Let's Encrypt:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
Automate certificate renewals:
sudo systemctl enable certbot.timer
π οΈ Testing and Reloading Nginx
Verify the configuration and reload:
sudo nginx -t
sudo systemctl reload nginx
Your Domoticz instance is now securely accessible at https://yourdomain.com
.
Logging and Debugging Domoticz
ποΈ Enabling Debug Logs
To activate debug-level logging, modify the startup command:
./domoticz -loglevel=debug -www 8080
π Viewing Logs
If using Docker, view logs with:
docker logs domoticz
If manually installed, check the log file:
tail -f domoticz.log
π οΈ Troubleshooting Common Issues
-
Port Conflicts: Ensure no other application uses port 8080.
-
Permission Errors: Verify the app has write access to configuration directories.
π€ Exporting Logs
Send logs to an ELK Stack:
cat domoticz.log | curl -XPOST 'http://elkserver:9200/domoticz-logs/_bulk' -H 'Content-Type: application/json' --data-binary @-
Backup and Restore
ποΈ File-Based Backups
Backup Domoticz configuration files:
tar -czvf domoticz_backup.tar.gz ./domoticz_data
π Database Backups
Domoticz uses an SQLite database. Backup the database with:
sqlite3 domoticz.db ".backup domoticz_backup.db"
π Automated Backup Scripts
Automate backups using cron
:
crontab -e
Add the following:
0 3 * * * tar -czvf /backups/domoticz_backup_$(date +\%F).tar.gz /path/to/domoticz_data
Updating and Upgrading Domoticz
β¬οΈ Updating Docker Images
Update Domoticz in Docker:
docker pull domoticz/domoticz:latest
docker-compose down && docker-compose up -d
π οΈ Manual Updates
For manual installations:
cd domoticz
./updatebeta
π Checking for Updates
Navigate to Settings > Check for Updates
within the Domoticz UI to verify version information.
Leveraging Domoticzβs Unique Features
π§ Enabling APIs
Enable APIs in Domoticz:
-
Go to
Settings > System > Enable API
. -
Use the following
curl
command to test:
curl -X GET "http://yourdomain.com/json.htm?type=devices"
π Advanced Configurations
Integrate MQTT for advanced automation:
-
Enable MQTT in
Settings > Hardware > Add MQTT
. -
Install Mosquitto as the MQTT broker:
sudo apt install mosquitto mosquitto-clients -y
- Test communication:
mosquitto_pub -h localhost -t "domoticz/in" -m '{"idx":1,"nvalue":1}'
Wrapping Up
This guide has provided a detailed walkthrough for deploying, configuring, and managing Domoticz. By following the provided steps, you can leverage Domoticzβs powerful features to create a highly customized and secure home automation setup. Dive into the examples, explore the API, and enjoy full control over your smart home environment.