Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

  1. Zuerst muss ein Server aufgesetzt werden, welcher über USB an die unterbrechungsfreie Stromversorgung (USV) angeschlossen wird.
    Wenn ein LoxBerry mit dem /wiki/spaces/LOXBERRY/pages/1193709023 Plugin verwendet wird, entfällt Schritt 1 - dies wäre dann die Installation des Plugins auf dem LoxBerry inkl. Neustart.   
    Ich habe einen Raspberry Pi verwendet, da ich diesen sowieso habe und er noch andere Dinge tut, die Loxone nicht selbst kann.
    Zur Raspbian Grundinstallation schreibe ich hier daher nichts, da es dazu genügend Tutorials im Netz gibt.

    Also das Paket installiert:

    Codeblock
    languagebash
    titleInstallation des APC UPS Däemon
    sudo apt-get install apcupsd

    Jetzt die Konfiguration anpassen - hier ist meine:

    Codeblock
    languagetext
    firstline1
    title/etc/apcupsd/apcupsd.conf
    linenumberstrue
    collapsetrue
    UPSNAME Back-UPS
    UPSCABLE usb
    UPSTYPE usb
    LOCKFILE /var/lock
    SCRIPTDIR /etc/apcupsd
    PWRFAILDIR /etc/apcupsd
    NOLOGINDIR /etc
    ONBATTERYDELAY 2
    BATTERYLEVEL 5
    MINUTES 3
    TIMEOUT 0
    ANNOY 300
    ANNOYDELAY 60
    NOLOGON disable
    KILLDELAY 0
    NETSERVER on
    NISIP 0.0.0.0
    NISPORT 3551
    EVENTSFILE /var/log/apcupsd.events
    EVENTSFILEMAX 10
    UPSCLASS standalone
    UPSMODE disable
    STATTIME 0
    STATFILE /var/log/apcupsd.status
    LOGSTATS off
    DATATIME 0

    Mit den folgenden Kommandos kann man den Daemon starten und den Status auslesen:

    Codeblock
    languagebash
    titleUSV-Status auslesen
     service apcupsd restart
     service apcupsd status


  2. Auf dem oben konfigurierten NISPort 3551 ist die USV nun vom Miniserver aus ansprechbar.
  3. Jetzt habe ich in der Loxone Config ein Programmbaustein eingefügt und die Ausgänge verbunden:
     

  4. Das Programm sieht wie folgt aus - in Zeile 12 ist der Hostname raspberry.pi und der Port gegebenenfalls durch eigene Werte zu ersetzen :

    Codeblock
    languagec#
    firstline1
    titleLoxone-Programm
    linenumberstrue
    collapsetrue
    char* p,*pS;
    char* cStatus;
    char* cBattdate;
    char* cModel;
    char szBuffer[1500];
    int nLen;
    int bOnline = 0;
    double dCharge,dLoad,dLinev,dTimeleft,dBattv,dTonbatt,dCumonbatt,dOutputv;
    //printf("Starting USV APC BackUPS 1500 watch");
    while(TRUE)
        {
        STREAM* stream = stream_create("/dev/tcp/192.168.178.254/3551",0,0);
        if (stream != NULL)
            {
            szBuffer[0] = 0;
            szBuffer[1] = 6;
            stream_write(stream,szBuffer,2);
            stream_flush(stream);
            stream_write(stream,"status",6);
            stream_flush(stream);
            nLen = stream_read(stream,szBuffer,2,1000);
            nLen = stream_read(stream,szBuffer,sizeof(szBuffer) - 1,1000);
            stream_close(stream);
            szBuffer[nLen] = 0;
            szBuffer[nLen + 1] = 0;
            //printf("APC BufferLen=%d",nLen);
            pS = szBuffer;
            while(*pS)
                {
    
                //MODEL : UPS model derived from UPS information
                  p = strstr(pS,"MODEL    :");
                  if (p != NULL)
                   {
                    cModel = strstrskip(p,"MODEL    : ");
                    //printf("APC Model=%s",cModel);
                    setoutputtext(0,cModel);
                   }
    
                //STATUS : UPS status (online, charging, on battery etc)
                  p = strstr(pS,"STATUS   :");
                  if (p != NULL)
                   {
                    cStatus = strstrskip(p,"STATUS   : ");
                    //printf("APC Status=%s",cStatus);
                    setoutputtext(1,cStatus);
                    p = strstr(pS,"ONLINE");
                    if (p != NULL)
                    setoutput(0,0);
                    else
                    setoutput(0,1);
                   }
    
                //LINEV : Current input line voltage
                  p = strstr(pS,"LINEV    :");
                  if (p != NULL)
                   {
                    dLinev = batof(p + 11);
                    setoutput(1,dLinev);
                    //printf("APC Linev=%f",dLinev);
                   }
    
                //LOADPCT : Percentage of UPS load capacity used as estimated by UPS
                  p = strstr(pS,"LOADPCT  :");
                  if (p != NULL)
                   {
                    dLoad = batof(p + 11);
                    setoutput(2,dLoad);
                    //printf("APC Load=%f",dLoad);
                   }
    
                //BCHARGE : Current battery capacity charge percentage
                  p = strstr(pS,"BCHARGE  :");
                  if (p != NULL)
                   {
                    dCharge = batof(p + 11);
                    setoutput(3,dCharge);
                    //printf("APC Bcharge=%f",dCharge);
                   }
    
                //TIMELEFT: Remaining runtime left on battery as estimated by the UPS
                  p = strstr(pS,"TIMELEFT :");
                  if (p != NULL)
                   {
                    dTimeleft = batof(p + 11);
                    setoutput(4,dTimeleft);
                    //printf("APC Timeleft=%f",dTimeleft);
                   }
    
                //BATTV : Current battery voltage
                  p = strstr(pS,"BATTV    :");
                  if (p != NULL)
                   {
                    dBattv = batof(p + 11);
                    setoutput(5,dBattv);
                    //printf("APC Battv=%f",dBattv);
                   }
                //TONBATT :Seconds currently on battery
                  p = strstr(pS,"TONBATT  :");
                  if (p != NULL)
                   {
                    dTonbatt = batof(p + 11);
                    setoutput(6,dTonbatt);
                    //printf("APC Tonbatt=%f",dTonbatt);
                   }
    
                //CUMONBATT : Cumulative seconds on battery since apcupsd startup
                  p = strstr(pS,"CUMONBATT:");
                  if (p != NULL)
                   {
                    dCumonbatt = batof(p + 11);
                    setoutput(7,dCumonbatt);
                   }
    
                //BATTDATE: Date battery last replaced (if set)
                  p = strstr(pS,"BATTDATE :");
                  if (p != NULL)
                   {
                    cBattdate = strstrskip(p,"BATTDATE : ");
                    //printf("APC Battdate=%s",cBattdate);
                    setoutputtext(2,cBattdate);
                   }
    
    
                  //OUTPUTV: Output voltage
    
                  p = strstr(pS,"OUTPUTV :");
                  if (p != NULL)
                  {
                  dOutputv = batof(p + 11);
                  setoutput(8,dOutputv);
                  }
    
    
                 pS += (strlen(pS) + 1);
                }
                sleeps(15);     
    		 }
        else
             {
                //printf("APC no connection");
                sleeps(15);        // wait 15 seconds
             }
        }
    


  5. Hier die Loxone-Konfig-Datei zum Download: Back-UPS.Loxone
  6. Die Zeilen mit printf erzeugen eine Ausgabe im Log-Tab der Loxone Config (ganz unten) und können im Produktivbetrieb mit einem vorangestellten // auskommentiert werden.
  7. Fertig sieht es dann so aus:

...

Seiteneigenschaften
hiddentrue


Verwandte Vorgänge