Sommare consumi metern

Discussioni relative al software di monitoraggio energetico METERN
Sandren
Messaggi: 13
Iscritto il: 03/04/2017, 17:21

Sommare consumi metern

Messaggioda Sandren » 28/06/2019, 11:01

Ciao,
provo a chidere se ce la possibilità di sommare i consumi di 2 metern in un unico valore.
Premessa doverosa, sono anni che utilizzo il sistema e funziona regolarmente. Avevo 2 contattori enel da monitorare (uno per uso domestico e uno dedicato all pompa di calore)
Recentemente ho convogliato i consumi tutti su un unico contattore enel da 6Kw , ma mi sono accorto che le letture differiscono in quanto il metern 6 (quello che misurava i consumi della pompa di calore) non viene considerato nel conteggio dell'autoconsumo.
Immagine
Nell'immagine mi aspettavo l'autoconsumo sui 434W

Cè la possibilità di impostare i consumi come somma di più metern senza dover spostare nulla fisicamente ?

Grazie in anticipo per il consiglio


America
Messaggi: 185
Iscritto il: 26/08/2018, 13:15

Re: Sommare consumi metern

Messaggioda America » 02/07/2019, 22:11

Ma i consumi che visualizzi sono totali di cui 103 w di pompa di calore.
Io l'ho interpretato così.
A casa io ho altri due sotto contatori e mi sembra funzioni così.....

Inviato dal mio Redmi 4X utilizzando Tapatalk

Sandren
Messaggi: 13
Iscritto il: 03/04/2017, 17:21

Re: Sommare consumi metern

Messaggioda Sandren » 02/07/2019, 23:20

Purtroppo no.. sono 331 +103 ... i 103 della PDC è come fossero solo letture Live e non conteggiati nel totale consumi....

Se ci fosse la possibilità di impostare anche quelle letture nel totale sarebbe perfetto . :?

America
Messaggi: 185
Iscritto il: 26/08/2018, 13:15

Re: Sommare consumi metern

Messaggioda America » 03/07/2019, 3:47

Secondo me è un problema di collegamento elettrico e non di software. Se nei consumi totali non sono compresi i consumi della pdc è perché la linea pdc non passa attraverso il contatore consumi. Ho avuto un problema simile anche io.

Per quel poco che ci capisco io. Attendi pareri più autorevoli.

Inviato dal mio Redmi 4X utilizzando Tapatalk

sunpower327
Messaggi: 41
Iscritto il: 21/01/2018, 10:50

Re: Sommare consumi metern

Messaggioda sunpower327 » 12/08/2019, 22:17

Imposti house consumption su tutti i metern che devi sommare poi crei un contatore virtuale con la comapps pooltot impostata come consumi editando il file
con la base raspbian stretch penso si debba mettere il metern virtuale pooltot sul metern numero 2

io non ho provato per i consumi ma lo sto usando per la produzione e funziona bene con metern 1.2
qui sotto la comapps che stò utilizzando già impostata per i consumi da inserire sul metern 2
pooltot energy sul main 5min pooling
pooltot power sul dashboard live

ricordarsi di cambiare nello script pooler485.php gli indirizzi dei contatori reali usati per i consumi che dobbiamo sommare tra di loro che dovranno essere a mio giudizio dal 6 in poi quindi se usiamo il 6 e il 7 anche nei relatii sdm120c vanno inseriti gli indirizzi rispettivamente 6 e 7

Codice: Seleziona tutto

#!/usr/bin/php
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
// If you own several production or consumption meters, this script will simulate a total production or consumption meter .
//
// How-to :
// 1) Make a link : ln -s /var/www/comapps/pooltot.php /usr/local/bin/pooltot
// 2) In meterN, set your real meters as 'Elect' 'House production | House consumption'
// 3) Then, set this virtual meter in meterN. The type should be 'Elect Other' with a passover value like 100000
//    Request the 'Main command' with 'pooltot energy' and 'Live command' with 'pooltot power'
// 4) Configure the script

// meterN config
$pathtomn  = '/var/www/metern'; // without / at the end
// This virutal total meter config
$WHICHTYPE = 2; // Set to 1 for a virtual production meter and 2 for a consumption
$METERID   = 2; // this vitual meter ID
$METERNUM  = 2; // this vitual meterN meter number

// No edit should be needed bellow
$prevfile = '/dev/shm/prevpooltot.json';
$verbose  = false; //debug

function getvalue($id, $cmd) //  Get data and validate with IEC 62056 data set structure
{
    $datareturn = null;
    $giveup     = 0;
    $regexp     = "/^$id\(-?[0-9\.]+\*[A-z0-9³²%°]+\)$/i"; //ID(VALUE*UNIT)
   
    while (!isset($datareturn) && $giveup < 3) { // Try 3 times
        exec($cmd, $datareturn);
        $datareturn = trim(implode($datareturn));
       
        if (preg_match($regexp, $datareturn)) {
            $datareturn = preg_replace("/^$id\(/i", '', $datareturn, 1); // VALUE*UNIT)
            $datareturn = preg_replace("/\*[A-z0-9³²%°]+\)$/i", '', $datareturn, 1); // VALUE
            settype($datareturn, 'int');
        } else {
            $datareturn = null;
        }
        $giveup++;
    }
    return $datareturn;
}

function retrievecsv($meternum, $csvarray, $passo, $datareturn) // Retrieve last know value in latest csv
{
    $datareturn = null;
    $contalines = count($csvarray);
    $j          = 0;
    while (!isset($datareturn)) {
        $j++;
        $array      = preg_split('/,/', $csvarray[$contalines - $j]);
        $datareturn = (int) trim($array[$meternum]);
        if ($datareturn == '') {
            $datareturn = null;
        }
        if ($j == $contalines) {
            $datareturn = 0;
        }
    }
    if ($datareturn > $passo) {
        $datareturn -= $passo;
    }
    return $datareturn;
}

if (isset($argv[1]) && ($argv[1] == 'power' || $argv[1] == 'energy')) {
    define('checkaccess', TRUE);
    include("$pathtomn/config/config_main.php");
    include("$pathtomn/config/memory.php");
    for ($i = 1; $i <= $NUMMETER; $i++) {
        include("$pathtomn/config/config_met$i.php");
    }
    date_default_timezone_set($DTZ);
   
    if ($argv[1] == 'power') {
        $nowUTC  = strtotime(date("Ymd H:i:s"));
        ///// open mN shm live memory
        $data    = file_get_contents($LIVEMEMORY);
        $livemem = json_decode($data, true);
        if ($nowUTC - $livemem['UTC'] > 30) {
            die("Abording: Too late mN live values\n");
        }
    } else { // energy
        // Retrieve previous virtual meter value
        if (file_exists($prevfile)) {
            $data     = file_get_contents($prevfile);
            $previous = json_decode($data, true);
        }
       
        if (!isset($previous['KWHtot'])) { // At boot retrieve values in last csv
            $output = array();
            $output = glob($pathtomn . '/data/csv/*.csv');
            sort($output);
            $cnt = count($output);
           
            if ($cnt > 0) {
                $lines              = file($output[$cnt - 1]);
                $contalines         = count($lines);
                $lastarray          = preg_split("/,/", $lines[$contalines - 1]);
                $datareturn         = null;
                $previous['KWHtot'] = retrievecsv($METERNUM, $lines, ${'PASSO' . $METERNUM}, $datareturn);
                if ($verbose) {
                    $t = $previous['KWHtot'];
                    echo "Retrieve KWHtot value in last csv : $t kWh\n";
                }
            } else { // no csv, starting from scratch !
                $previous['KWHtot'] = 0;
                if ($verbose) {
                    echo "Starting from scratch !\n";
                }
            }
        } elseif ($verbose) {
            $t = $previous['KWHtot'];
            echo "Previous KWHtot value : $t kWh\n";
        }
    }
   
    $GPtot = 0;
    $diff  = 0;
    // Retreiving latest values
    for ($i = 1; $i <= $NUMMETER; $i++) {
        $value = null;
        if (${'TYPE' . $i} == 'Elect' && ${'PROD' . $i} == $WHICHTYPE && $i != $METERNUM && !${'SKIPMONITORING' . $i}) {
            if ($argv[1] == 'power') {
                if (isset(${'LIVECOMMAND' . $i}) && isset($livemem["${'METNAME'.$i}$i"])) {
                    $GPtot += $livemem["${'METNAME'.$i}$i"];
                }
                if ($verbose) {
                    $t = $livemem["${'METNAME'.$i}$i"];
                    echo "\nPower #$i ${'METNAME'.$i} : $t W\n";
                }
            } else {
                $value = getvalue(${'ID' . $i}, ${'COMMAND' . $i});
                if ($verbose) {
                    echo "\nGetting latest energy for #$i (${'METNAME'.$i}) : $value kWh\n";
                }
                if (isset($value)) {
                    if (isset($previous["prevTotalcounter$i"])) {
                        if ($verbose) {
                            $t = $previous["prevTotalcounter$i"];
                            echo "Previous value: $t kWh\n";
                        }
                        // Some passover checks
                        if ($value >= $previous["prevTotalcounter$i"]) {
                            $diff = $value - $previous["prevTotalcounter$i"];
                        } else {
                            if ($verbose) {
                                echo "passover: $value < ${'PASSO' . $PRODmetnum} \n";
                            }
                            $diff = $value + ${'PASSO' . $PRODmetnum} - $previous["prevTotalcounter$i"];
                        }
                    }
                    settype($previous["prevTotalcounter$i"], 'int');
                    $previous["prevTotalcounter$i"] = $value;
                    if ($verbose) {
                        echo "The difference is $diff, saving as prev value $value for #$i (${'METNAME'.$i})\n";
                    }
                    $previous['KWHtot'] += $diff;
                }
            }
        }
    }
    // Output
    if ($argv[1] == 'power') {
        if ($GPtot > 1000) {
            $GPtot = round($GPtot, 0);
        } else {
            $GPtot = round($GPtot, 1);
        }
        echo "$METERID($GPtot*W)\n";
    } else { // energy
        if ($verbose) {
            $t = $previous['KWHtot'];
            echo "\nSaving total #$METERNUM ($METERID) : $t kWh\n--\n";
        }
        if ($previous['KWHtot'] >= ${'PASSO' . $METERNUM}) { // virtual meter passed over
            $previous['KWHtot'] -= ${'PASSO' . $METERNUM};
            if ($verbose) {
                $t = $previous['KWHtot'];
                echo "Total passover $METERID :  $t > ${'PASSO' . $METERNUM}\n";
            }
        }
        // Save previous values
        $data = json_encode($previous);
        file_put_contents($prevfile, $data);
       
        $KWHtot = $previous['KWHtot'];
        echo "$METERID($KWHtot*Wh)\n";
    }
} else {
    echo "Usage: pooltot { power | energy }\n";
    if (file_exists($prevfile)) {
        $data     = file_get_contents($prevfile);
        $previous = json_decode($data, true);
        print_r($previous);
    }
}
?>


Torna a “MeterN”

Chi c’è in linea

Visitano il forum: Nessuno e 10 ospiti