Benutzer-Werkzeuge

Webseiten-Werkzeuge


wiki:projekte:iobroker:uebersicht

Neuinstallation ioBroker auf einem R-Pi 3 B+ oder 4 B

Quellen:

Das Grundsystems

Installation

Die Verwendung von InfluxDB 2.x setzt ein 64-bit Betriebssystem voraus.
Ein Desktop bzw. eine vollständige grafische Oberfläche wird nicht benötigt. Daher bezeichnet man ein solches System als „Headless“. Somit basiert dieses Heimautomatisierungsprojekt auf einem Raspberry Pi OS (32 oder 64-bit) Lite.

# Raspberry Pi Image besorgen
#wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-02-22/2023-02-21-raspios-bullseye-armhf-lite.img.xz
wget https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2023-10-10/2023-10-10-raspios-bookworm-armhf-lite.img.xz
oder 
#wget https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-02-22/2023-02-21-raspios-bullseye-arm64-lite.img.xz
wget https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-10-10/2023-10-10-raspios-bookworm-arm64-lite.img.xz
# R-Pi Imager herunterladen und intallieren:
wget https://downloads.raspberrypi.org/imager/imager_latest_amd64.deb
sudo dpkg -i imager_latest_amd64.deb
rpi-imager
#sudo touch /media/<benutzername>/bootfs/ssh
#sync
# SD-Karte aushängen und damit den R-Pi booten

Konfiguration

Während des Bootvorganges erhält der Raspberry eine IP Adresse vom Router. Diese kann über die entsprechende Weboberfläche des Routers ermittelt werden.

# Grundsystem auf den aktuellen Stand bringen:
ssh -l pi <IP>
sudo su
apt-get update && sudo apt-get upgrade
apt-get install aptitude mc apt-transport-https software-properties-common raspi-gpio
raspi-config nonint do_hostname iobroker
raspi-config nonint do_onewire 0
raspi-config nonint do_change_locale de_DE.UTF-8 UTF-8
raspi-config nonint do_expand_rootfs
raspi-config nonint do_update
reboot
# Feste IP für eth0 einstellen:
mcedit /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.10.11/24
static routers=192.168.10.1
static domain_name_servers=192.168.10.1
#
# Seit OS "Bookworm":
nmcli -p connection show
nmcli con mod "Kabelgebundene Verbindung 1" ipv4.addresses 192.168.10.11/24 ipv4.method manual
nmcli con mod "Kabelgebundene Verbindung 1" ipv4.gateway 192.168.10.1
nmcli con mod "Kabelgebundene Verbindung 1" ipv4.dns "192.168.10.1"
reboot
# oder
nmcli c down "Kabelgebundene Verbindung 1" && sudo nmcli c up "Kabelgebundene Verbindung 1"
#
# nicht benötigte Dienste beenden und/oder entfernen:
systemctl disable ModemManager.service
systemctl stop ModemManager.service
apt-get purge modemmanager
#
mkdir -p /mnt/usb-stick
echo "UUID="52ff610a-2612-4021-8a8d-b818b3dba1f4" /mnt/usb-stick  ext4  defaults  0  1" >> /etc/fstab
systemctl daemon-reload
mount -a

GPIO für USV

aptitude install raspi-gpio
# konfiguriere GPIO #18 als Input mit internem Pull-Down:
raspi-gpio set 18 ip pd
# GPIO Zustand abfragen:
raspi-gpio get 18

InfluxDB 1.x

Installation

sudo su
#wget -qO- https://repos.influxdata.com/influxdata-archive_compat.key | sudo apt-key add -
#source /etc/lsb-release
#echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
#curl https://repos.influxdata.com/influxdata-archive.key | gpg --dearmor | sudo tee /usr/share/keyrings/influxdb-archive-keyring.gpg >/dev/null
#echo "deb [signed-by=/usr/share/keyrings/influxdb-archive-keyring.gpg] https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
 
apt-get update
apt-get install influxdb
 
systemctl unmask influxdb.service
systemctl enable influxdb
systemctl start influxdb
systemctl status influxdb

Konfiguration

sudo su
influx
> CREATE USER "admin" WITH PASSWORD 'influxdbadmin' WITH ALL PRIVILEGES
> CREATE USER "iobroker" WITH PASSWORD 'iobroker'
> CREATE DATABASE "iobroker"
> GRANT ALL ON "iobroker" TO "iobroker"
> exit
#
mcedit /etc/influxdb/influxdb.conf
[http]  
 enabled = true  
 bind-address = ":8086"  
 auth-enabled = true
 log-enabled = true  
 write-tracing = false  
 pprof-enabled = true  
 https-enabled = false
#
systemctl restart influxdb

Datenbankgröße ermitteln

sudo su
du -sh /var/lib/influxdb/data/iobrokerdb/

Backups

Erstellen

sudo su
influxd backup -portable /path/to/backup-destination
# or do it in one line:
cd /; influxd backup -portable /mnt/usb-stick/backup/influxdb/`date +%Y%m%d`

Wiederherstellen

sudo su
influxd restore -portable /path/to/backup-destination

InfluxDB 2.x

Installation

sudo su
cd ~
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
apt-get update
apt-get install influxdb2
systemctl start influxdb
systemctl status influxdb

Konfiguration

Die Konfiguration der InfluxDB erfolgt über den Browser via http://RASPI-IP:8086.

Grafana

Installation

sudo su
#wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key
#echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
 
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
apt-get update
# Install the latest OSS release:
apt-get install -y grafana
# Start System Service aka. Server
systemctl daemon-reload
systemctl start grafana-server
systemctl status grafana-server
systemctl enable grafana-server.service

Grafana Server: http://IP:3000

Grafana ohne Login

mcedit /etc/grafana/grafana.ini
# [auth.anonymous]
enabled = true
systemctl restart grafana-server

Backup

Erstellen

sudo su
cp /var/lib/grafana/grafana.db /path/to/backup-destination
cp /etc/grafana/grafana.ini /path/to/backup-destination
# or do it in one line:
cd /; mkdir /mnt/usb-stick/backup/grafana/`date +%Y%m%d`; cp /etc/grafana/grafana.ini /mnt/usb-stick/backup/grafana/`date +%Y%m%d`; cp /var/lib/grafana/grafana.db /mnt/usb-stick/backup/grafana/`date +%Y%m%d`

Wiederherstellen

sudo su
cd /path/to/backup-destination
cp grafana.db /var/lib/grafana/
cp grafana.ini /etc/grafana/

ioBroker

Wiederherstellung

Folgende Backup Dateien via Backitup Adapter wieder einsoielen:

  • iobroker_<TIMESTAMP>_backupiobroker.tar.gz
  • influxDB_<TIMESTAMP>_backupiobroker.tar.gz
  • grafana_<TIMESTAMP>_backupiobroker.tar.gz
  • javascripts_<TIMESTAMP>_backupiobroker.tar.gz

Installation

sudo su
# automatische Installation:
curl -sLf https://iobroker.net/install.sh | bash -

Nach der Installation ist die ioBroker Instanz erreichbar unter http://<Raspberry-Pi-IP>:8081.

Steuerung

# ioBroker starten:
iobroker start
# ioBroker stoppen:
iobroker stop
# ioBrker Infos anzeigen
iobroker info

Backups

Erstellung

Siehe unten → Script oder per 'Backitup' Adapter

Wiederherstellung

  • Verzeichniss '/opt/iobroker/backups' anlegen
  • Kopieren des Backups dort hinein

Backups die mit dem Backitup-Adapter erstellt wurden können nachde dem kopieren via Web-Interface wieder eingesielt werden.
Alternativ kann auch die Konsole verwendet werden:

sudo su
cd /opt/iobroker
iobroker stop
iobroker restore 0
iobroker stop

Adapter installieren

Als Adapter werden alle Schnittstellen zu externen aber auch zu internen Datenquellen (z.B. Shelly Sensoren, Temperatur, Luftfeuchte, GPIO, 1-Wire, etc.) und Senken (Shelly Aktoren) bezeichnet.

  • influxDB (Datenbank zur Speicherung von Messwerten)
  • DS18B20 (Auslesen von 1-Wire Temperatursensoren)
  • HABpanel (Steuerung von Aktoren vis Webseite)
  • Jeelink-Geräte (Empfangen von 868mHz LaCrosse Temperatur- und Feuchtesensoren (hier z.B. TX29DTH-IT) mit Hilfe eines Jeelink Klones
  • MQTT Broker (zur Datenverarbeitung von MQTT-fähigen Sensoren und Aktoren)
  • Philips Luftreiniger (für die Anbindung eines Philips Air Purifier 4000i Series (Typ: AC4236/10)
  • RPI-Monitor (Nutzung von GPIOs z.B. zum Einlesen eines Reed-Kontaktes für den Gaszähler)
  • Skriptausführung (Javascript und Blockly)
  • WEB-Server (für HABpanel)
  • Shelly

Adapter konfigurieren

Die oben aufgeführten Adapter sind nach der Installation unter Instanzen zu finden und müssen dort konfiguriert werden.

1-Wire

DS18B20

TBC - Empfänger bauen und programmieren → TBC

MQTT

Für IKEA Sensoren –> Die angepasste Firmware gibt es hier.

Philips

Gaszähler

Reedkontakt am GPIO #17 - Name: Gaszähler

Blockly

Und das ganze als XML:

Title

Stromzähler

Zur Erfassung des Stromverbrauches meiner Wohnung verwende ich einen Shelly 3EM Pro den ich via Shelly Adapter eingebunden habe.

Blockly

Und das ganze als XML:

Title

InfluxDB

Backup durch Script

// Täglich um 03:00 Uhr Nachts wird das Backup ausgeführt. Anpassbar unter "schedule"
var usbstick = "/mnt/usb-stick/backup/"; /*Hier den Pfad zum USB-Stick eintragen*/
 
function backup() {
    exec('iobroker backup', 
        function (error, stdout, stderr) {console.log('stdout: ' + stdout);});
    setTimeout( function() { 
        exec('mv  -v /opt/iobroker/backups/* ' + usbstick,
            function (error, stdout, stderr) {console.log('stdout: ' + stdout);});
    }, 180000);
}
 
schedule("0 3 * * *",  function(obj){
    backup();
});

Update und Bugfixing

iobroker stop
iobroker update
iobroker fix
# oder curl -sL https://iobroker.net/fix.sh | bash -
iobroker upgrade self
iobroker start
wiki/projekte/iobroker/uebersicht.txt · Zuletzt geändert: 2024/03/31 13:03 von wikimaster