# Grundsystem auf den aktuellen Stand bringen:
ssh -l root 
# default Passwort: "1234"
# Passort ändern Dialog abarbeiten!
# System auf der SATA HDD installieren denn der Emmc Flash hat mit 8GB zu wenig Platz ;-)
armbian-install
apt-get update && sudo apt-get upgrade
apt-get install aptitude mc apt-transport-https software-properties-common wget
# Feste IP für eth0 einstellen:
mv /etc/netplan/10-dhcp-all-interfaces.yaml /root/
mcedit /etc/netplan/20-static-ip.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    end0:
      addresses:
        - 192.168.10.11/24
      routes:
        - to: default
          via: 192.168.10.1
      nameservers:
        addresses:
          - 192.168.10.1
          - 192.168.100.1
reboot
#
# Die folgenden Schritte sind nicht notwendg, wenn das System auf eine SATA HDD installiert wird.
mkdir -p /mnt/sda1
# UUID der externen HDD ermitteln:
blkid
# fstab Eintrag erzeugen
echo "UUID="xxxxxxxxxxxxxxxxxx" /mnt/sda1  ext4  defaults  0  1" >> /etc/fstab
systemctl daemon-reload
mount -a
 
===== InfluxDB 1.x =====
Quelle: [[https://docs.influxdata.com/influxdb/v1/introduction/install/|https://docs.influxdata.com/influxdb/v1/introduction/install/]]
==== Installation ====
sudo su
#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
# influxdata-archive_compat.key GPG Fingerprint: 9D539D90D3328DC7D6C8D3B9D8FF8E1F7DF8B07E
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 ====
Quelle: [[https://docs.influxdata.com/influxdb/v1/administration/backup_and_restore/#back-up-all-databases|https://docs.influxdata.com/influxdb/v1/administration/backup_and_restore/#back-up-all-databases]]
=== 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|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
sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com 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|http://IP:3000]]
==== Grafana ohne Login ====
mcedit /etc/grafana/grafana.ini
# [auth.anonymous]
enabled = true
systemctl restart grafana-server
==== Backup ====
Quelle: [[http://cactusprojects.com/backup-restore-grafana/|http://cactusprojects.com/backup-restore-grafana/]]
=== 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_
sudo su
# automatische Installation:
curl -sLf https://iobroker.net/install.sh | bash -
Nach der Installation ist die ioBroker Instanz erreichbar unter [[http://
# 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
{{:wiki:projekte:iobroker:pasted:20230401-155520.png}}
==== Adapter konfigurieren ====
Die oben aufgeführten Adapter sind nach der Installation unter ''Instanzen'' zu finden und müssen dort konfiguriert werden.
=== 1-Wire ====
== DS18B20 ==
{{:wiki:projekte:iobroker:pasted:20231024-204714.png}}
=== JeeLink ====
TBC - Empfänger bauen und programmieren -> TBC
{{:wiki:projekte:iobroker:pasted:20231024-204958.png}}
{{:wiki:projekte:iobroker:pasted:20231024-205021.png}}
=== MQTT ====
Für IKEA Sensoren --> Die angepasste Firmware gibt es [[https://github.com/Hypfer/esp8266-vindriktning-particle-sensor|hier]].
{{:wiki:projekte:iobroker:pasted:20231024-210526.png}}
=== Philips ====
{{:wiki:projekte:iobroker:pasted:20231024-205139.png}}
=== Gaszähler ====
Reedkontakt am GPIO #17 - Name: ''Gaszähler''\\
{{:wiki:projekte:iobroker:pasted:20231126-153854.png}}
== Blockly ==
{{:wiki:projekte:iobroker:pasted:20240121-121115.png}}
{{:wiki:projekte:iobroker:pasted:20240121-121217.png}}
Und das ganze als XML:
++++ Title |
  
    GasZaehlerstand 
    
      
        0 
       
     
    
      
        {"type":"number", "unit":"m³"} 
       
     
    
      
        GasZaehlerstandkWh 
        
          
            0 
           
         
        
          
            {"type":"number", "unit":"kWh"} 
           
         
        
          
            GasTagesverbrauch 
            
              
                0 
               
             
            
              
                {"type":"number", "unit":"m³"} 
               
             
            
              
                GasTagesverbrauchkWh 
                
                  
                    0 
                   
                 
                
                  
                    {"type":"number", "unit":"kWh"} 
                   
                 
                
                  
                    0 0 * * * 
                    
                      
                        .0 
                         
                        
                          
                            text 
                           
                          
                             
                            
                              
                                Gas Tagesverbrauch am  
                               
                             
                            
                              
                                 
                                
                                  
                                     
                                    DD.MM.YYYY 
                                    
                                      
                                        - 
                                        day 
                                        
                                          
                                             
                                            object 
                                           
                                          
                                             
                                            object 
                                           
                                         
                                        
                                          
                                            1 
                                           
                                         
                                       
                                     
                                   
                                 
                                
                                  
                                     
                                    
                                      
                                        :  
                                       
                                     
                                    
                                      
                                         
                                        
                                          
                                            3 
                                            
                                              
                                                3.1234 
                                               
                                              
                                                val 
                                                javascript.0.GasTagesverbrauch 
                                               
                                             
                                           
                                         
                                        
                                          
                                             m³ 
                                           
                                         
                                       
                                     
                                   
                                 
                               
                             
                           
                         
                        
                          
                             
                            javascript.0.GasTagesverbrauch 
                            FALSE 
                            
                              
                                0 
                               
                             
                            
                              
                                 
                                javascript.0.GasTagesverbrauchkWh 
                                FALSE 
                                
                                  
                                    0 
                                   
                                 
                               
                             
                           
                         
                       
                     
                    
                      
                        rpi2.0.gpio.17.state 
                        false 
                         
                        
                          
                             
                            javascript.0.GasTagesverbrauch 
                            FALSE 
                            
                              
                                ADD 
                                
                                  
                                    1 
                                   
                                  
                                    val 
                                    javascript.0.GasTagesverbrauch 
                                   
                                 
                                
                                  
                                    0.01 
                                   
                                 
                               
                             
                            
                              
                                 
                                javascript.0.GasZaehlerstand 
                                FALSE 
                                
                                  
                                    ADD 
                                    
                                      
                                        1 
                                       
                                      
                                        val 
                                        javascript.0.GasZaehlerstand 
                                       
                                     
                                    
                                      
                                        0.01 
                                       
                                     
                                   
                                 
                               
                             
                           
                         
                        
                          
                            javascript.0.GasZaehlerstand 
                            ne 
                             
                            
                              
                                m³ x Zustandszahl X Brennwert 
                                
                                  
                                     
                                    javascript.0.GasZaehlerstandkWh 
                                    FALSE 
                                    
                                      
                                        3 
                                        
                                          
                                            3.1234 
                                           
                                          
                                            MULTIPLY 
                                            
                                              
                                                9.866 
                                               
                                             
                                            
                                              
                                                1 
                                               
                                              
                                                MULTIPLY 
                                                
                                                  
                                                    1 
                                                   
                                                  
                                                    state.val 
                                                   
                                                 
                                                
                                                  
                                                    0.9613 
                                                   
                                                 
                                               
                                             
                                           
                                         
                                       
                                     
                                   
                                 
                               
                             
                            
                              
                                javascript.0.GasTagesverbrauch 
                                ne 
                                 
                                
                                  
                                    m³ x Zustandszahl X Brennwert 
                                    
                                      
                                         
                                        javascript.0.GasTagesverbrauchkWh 
                                        FALSE 
                                        
                                          
                                            3 
                                            
                                              
                                                3.1234 
                                               
                                              
                                                MULTIPLY 
                                                
                                                  
                                                    9.866 
                                                   
                                                 
                                                
                                                  
                                                    1 
                                                   
                                                  
                                                    MULTIPLY 
                                                    
                                                      
                                                        1 
                                                       
                                                      
                                                        state.val 
                                                       
                                                     
                                                    
                                                      
                                                        0.9613 
                                                       
                                                     
                                                   
                                                 
                                               
                                             
                                           
                                         
                                       
                                     
                                   
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
             
           
         
       
     
   
 
++++
=== Stromzähler ====
Zur Erfassung des Stromverbrauches meiner Wohnung verwende ich einen [[https://www.shelly.com/de/products/shop/shelly-pro-3-em-120-a-1|Shelly 3EM Pro]] den ich via Shelly Adapter eingebunden habe.\\
== Blockly ==
{{:wiki:projekte:iobroker:pasted:20240121-123848.png}}
{{:wiki:projekte:iobroker:pasted:20240121-123946.png}}
Und das ganze als XML:
++++ Title |
  
    StromZaehlerstandkWh 
    
      
        0 
       
     
    
      
        {"type":"number", "unit":"kWh"} 
       
     
    
      
        StromZaehlerstandkWh_gestern 
        
          
            0 
           
         
        
          
            {"type":"number", "unit":"kWh"} 
           
         
        
          
            StomTagesverbrauchkWh 
            
              
                0 
               
             
            
              
                {"type":"number", "unit":"kWh"} 
               
             
            
              
                TotalActiveEnergyWh_gestern 
                
                  
                    0 
                   
                 
                
                  
                    {"type":"number", "unit":"Wh"} 
                   
                 
                
                  
                    shelly.0.shellypro3em#c8f09e8314fc#1.EMData0.TotalActiveEnergy 
                    ne 
                     
                    
                      
                         
                        javascript.0.StomTagesverbrauchkWh 
                        FALSE 
                        
                          
                            DIVIDE 
                            
                              
                                1 
                               
                              
                                MINUS 
                                
                                  
                                    1 
                                   
                                  
                                    val 
                                    shelly.0.shellypro3em#c8f09e8314fc#1.EMData0.TotalActiveEnergy 
                                   
                                 
                                
                                  
                                    1 
                                   
                                  
                                    val 
                                    javascript.0.TotalActiveEnergyWh_gestern 
                                   
                                 
                               
                             
                            
                              
                                1000 
                               
                             
                           
                         
                        
                          
                             
                            javascript.0.StromZaehlerstandkWh 
                            FALSE 
                            
                              
                                ADD 
                                
                                  
                                    1 
                                   
                                  
                                    val 
                                    javascript.0.StromZaehlerstandkWh_gestern 
                                   
                                 
                                
                                  
                                    1 
                                   
                                  
                                    val 
                                    javascript.0.StomTagesverbrauchkWh 
                                   
                                 
                               
                             
                           
                         
                       
                     
                    
                      
                        0 0 * * * 
                        
                          
                            .0 
                             
                            
                              
                                text 
                               
                              
                                 
                                
                                  
                                    Stom Tagesverbrauch am  
                                   
                                 
                                
                                  
                                     
                                    
                                      
                                         
                                        DD.MM.YYYY 
                                        
                                          
                                            - 
                                            day 
                                            
                                              
                                                 
                                                object 
                                               
                                              
                                                 
                                                object 
                                               
                                             
                                            
                                              
                                                1 
                                               
                                             
                                           
                                         
                                       
                                     
                                    
                                      
                                         
                                        
                                          
                                            :  
                                           
                                         
                                        
                                          
                                             
                                            
                                              
                                                3 
                                                
                                                  
                                                    3.1234 
                                                   
                                                  
                                                    val 
                                                    javascript.0.StomTagesverbrauchkWh 
                                                   
                                                 
                                               
                                             
                                            
                                              
                                                 kWh 
                                               
                                             
                                           
                                         
                                       
                                     
                                   
                                 
                               
                             
                            
                              
                                 
                                javascript.0.TotalActiveEnergyWh_gestern 
                                FALSE 
                                
                                  
                                    val 
                                    shelly.0.shellypro3em#c8f09e8314fc#1.EMData0.TotalActiveEnergy 
                                   
                                 
                                
                                  
                                     
                                    javascript.0.StromZaehlerstandkWh_gestern 
                                    FALSE 
                                    
                                      
                                        val 
                                        javascript.0.StromZaehlerstandkWh 
                                       
                                     
                                    
                                      
                                         
                                        javascript.0.StomTagesverbrauchkWh 
                                        FALSE 
                                        
                                          
                                            0 
                                           
                                         
                                       
                                     
                                   
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
             
           
         
       
     
   
 
++++
=== InfluxDB ===
{{:wiki:projekte:iobroker:pasted:20231024-210408.png}}
==== Backup durch Script ====
{{:wiki:projekte:iobroker:pasted:20231024-210243.png}}
// 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