Instalare openHab in Docker

openHAB @openhab.org
openHAB @openhab.org

Daca intutorialul anterior instalam OpenHab pe Raspberry Pi ca imagine stand alone, in tutorialul de astazi vom instala OpenHab in Docker.

Hardware:

Dependinte:

  • Legatura la internet.
  • Sistemul de operare instalat (Raspbian)
  • Docker
  • Acces la router – pentru a vedea adresele IP alocate de acesta si pentru a deschide porturile de comunicare catre exterior.

Pregatire instalare OpenHab

Pentru inceput va trebui sa vream directoarele in care vom stoca informatiile penru OpenHab:

sudo mkdir -p /opt/openhab3/data/openhab/{conf,userdata,addons}

sudo mkdir -p /opt/openhab3/data/mosquitto/conf/ 

Pentru a securiza instalarea vom crea un nou user denumit openhab , si userul pi va adera la grupul acestuia.

sudo useradd -r -s /sbin/nologin openhab
sudo usermod -a -G openhab pi

Vom acorda drepturi de scriere pentru intreg folderul anterior creat.

sudo chown -R openhab:openhab /opt/openhab

Dependinte Docker

Editam fisierul /opt/openhab3/.env adaugand urmatoarele date:

Config File for openHAB SmartHome Application
 
#Docker Compose Project Name
PROJECT_NAME=openhab3
 
 # Port Configuration openHab
OPENHAB_HTTP_PORT=8080
OPENHAB_HTTPS_PORT=8443
 
 # Port Configuration Mosquitto
###Stergem simbolul "#" in urmatoarele randuri daca intentionam sa folosim MQTT.
#MOSQUITTO_MQTT_PORT=1883
#MOSQUITTO_MQTTS_PORT=8883

  # InfluxDB Configuration
### Stergem simbolul "#" in urmatoarele randuri daca intentionam sa folosim INFLUXDB.
#INFLUXDB_ADMIN_USER=admin
#INFLUXDB_ADMIN_PASSWORD=<PAROLA>
#INFLUXDB_USER=openhab
#INFLUXDB_USER_PASSWORD=<PAROLA>
#INFLUXDB_READ_USER=openhab_ro
#INFLUXDB_READ_USER_PASSWORD=<PAROLA>
#INFLUXDB_OPENHAB_DB=openhab_db

  # Port Configuration InfluxDB
### Stergem simbolul "#" in urmatoarele randuri daca intentionam sa folosim INFLUXDB.
#INFLUXDB_DB_PORT=8086

  # Port Configuration Grafana
### Stergem simbolul "#" in urmatoarele randuri daca intentionam sa folosim GRAFNA.
#GRAFANA_HTTP_PORT=3000
 
 # Port Configuration Chronograf
###Stergem simbolul "#" in urmatoarele randuri daca intentionam sa folosim CHRONOGRAF
#CHRONOGRAF_HTTP_PORT=8888

  # Timezone
 TZ=Europe/Bucharest

Cream fisierul docker-compose.yml

version: '3.8'
 services:
   openhab:
     image: openhab/openhab:latest
### Eliminam simbolul "#" daca folosim INFLUXDB si MQTT
#     depends_on:
#       - influxdb
#       - mosquitto
#      restart: always

### Eliminam simbolul "#" daca avem nevoie de log-uri persistente 
#tmpfs: 
#   - /openhab/userdata/logs 
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - "./data/openhab/conf:/openhab/conf"
      - "./data/openhab/addons:/openhab/addons"   
      - data_openhab_userdata:/openhab/userdata 
 environment:
   TZ: ${TZ}
   OPENHAB_HTTP_PORT: ${OPENHAB_HTTP_PORT}
   OPENHAB_HTTPS_PORT: ${OPENHAB_HTTPS_PORT}
   CRYPTO_POLICY: "unlimited"
   EXTRA_JAVA_OPTS: "-Duser.timezone=${TZ}"
   USER_ID: 999
   GROUP_ID: 994
 labels:   - "com.centurylinklabs.watchtower.enable=true"
 network_mode: host

### eliminam simbolul "#" daca folosim MQTT
# mosquitto:
# image: eclipse-mosquitto:latest
# restart: always
# volumes:
# - "./data/mosquitto/conf:/mosquitto/config"
# - data_mosquitto_data:/mosquitto/data
# - data_mosquitto_log:/mosquitto/log
# ports:
# - ${MOSQUITTO_MQTT_PORT}:1883
# - ${MOSQUITTO_MQTTS_PORT}:8883
# environment:
# TZ: ${TZ}
# labels:
# - "com.centurylinklabs.watchtower.enable=true"
# networks:
# app-nw:
# aliases:
# - mqtt

### eliminam simbolul "#" daca folosim INFLUXDB
# influxdb:
# image: influxdb:latest
# restart: always
# volumes:
# - data_influxdb:/var/lib/influxdb
# ports:
# - ${INFLUXDB_DB_PORT}:8086
# environment:
# - INFLUXDB_DATA_ENGINE=tsm1
# - INFLUXDB_REPORTING_DISABLED=false
# - INFLUXDB_ADMIN_USER=${INFLUXDB_ADMIN_USER}
# - INFLUXDB_ADMIN_PASSWORD=${INFLUXDB_ADMIN_PASSWORD}
# - INFLUXDB_USER=${INFLUXDB_USER}
# - INFLUXDB_USER_PASSWORD=${INFLUXDB_USER_PASSWORD}
# - INFLUXDB_READ_USER=${INFLUXDB_READ_USER}
# - INFLUXDB_READ_USER_PASSWORD=${INFLUXDB_READ_USER_PASSWORD}
# - INFLUXDB_DB=${INFLUXDB_OPENHAB_DB}
# - TZ=${TZ}
# labels:
# - "com.centurylinklabs.watchtower.enable=true"
# networks:
# app-nw:
# backend-nw:
# aliases:
# - db
 
###  eliminam simbolul "#" daca folosim GRAFNA
# renderer:
# image: adejong/grafana-image-renderer-pi:1.0.8-beta2
# restart: always
# environment:
# ENABLE_METRICS: 'true'
# labels:
# - "com.centurylinklabs.watchtower.enable=true"
# networks:
# - backend-nw

# grafana:
# image: grafana/grafana:latest-ubuntu
# depends_on:
# - influxdb
# - renderer
# restart: always
# user: "0"
# volumes:
# - data_grafana:/var/lib/grafana
# ports:
# - ${GRAFANA_HTTP_PORT}:3000
# environment:
# - GF_INSTALL_PLUGINS=grafana-clock-panel,briangann-gauge-panel,natel-plotly-panel,grafana-simple-json-datasource
# - GF_SMTP_ENABLED=true
# - GF_SMTP_HOST=YOURMAILSERVER:465
# - GF_SMTP_USER=YOURSMTPUSER
# - GF_SMTP_PASSWORD=SMTPPASSWORD
# - GF_SMTP_FROM_ADDRESS=MAILFROMADRESS
# - GF_AUTH_ANONYMOUS_ENABLED=true
# - GF_SECURITY_ALLOW_EMBEDDING=true
# - GF_RENDERING_SERVER_URL=http://renderer:8081/render
# - GF_RENDERING_CALLBACK_URL=http://grafana:3000/
# - GF_LOG_FILTERS=rendering:debug
# - TZ=${TZ}
# labels:
# - "com.centurylinklabs.watchtower.enable=true"
# network_mode: host
# networks:
# - app-nw
# - backend-nw
# volumes:
#   data_openhab_userdata:
#   data_influxdb:
#   data_grafana:
#   data_mosquitto_data:
#   data_mosquitto_log:
# networks:
#  app-nw:
#     internal: false
#     driver: bridge
#     driver_opts:
#       com.docker.network.bridge.name: app-${PROJECT_NAME}
#   backend-nw:
#     internal: true
#     driver: bridge
#     driver_opts:
#       com.docker.network.bridge.name: be-${PROJECT_NAME}

Instalare openHAB

Avem fisierele crete, atuci putem lansa instalarea OpenHAB.


cd /opt/openhab3 
docker-compose up -d

Toate containerele se vor descarca si instala automat.Dupa aproximativ 10 minute de la instalare accesand http://192.168.IP.rPI:8080 vom putea configura openHAB.

Dupa configurare sistemul va fi complet functional si ca bonus ne vom bucura de noua interfata si noile functionalitati ale OpenHAB3.

Linkuri utile

laub-home.de

docker.com & hub.docker.com

openhab.org

De Iulian Susnea

Pasionat de tehnologie, gadgeturi smart home si automatizari si am pornit la drum in crearea acestui site cu tutoriale pentru cele mai importante sisteme Smart Home ale momentului din dorinta de a-i ajuta pe cei la inceput de drum.

Lasă un comentariu

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *