meterN 1.0

Talks about metering
jeanmarc
Posts: 1917
Joined: Thu Aug 29, 2013 7:16 am

Re: meterN 1.0

Post by jeanmarc » Mon Jan 20, 2020 11:57 am

I am not sure about "virtmet", i don't know how it work.
The error you get (metern.php on line 23/24) is because you have empty LIVECOMMAND. To avoid theses errors, you can change the line 20 in metern.php to

Code: Select all

if (!${'SKIPMONITORING' . $metnum} && !empty(${'LIVECOMMAND' . $metnum})) {

megamarco83
Posts: 102
Joined: Tue Apr 14, 2015 9:25 am

Re: meterN 1.0

Post by megamarco83 » Tue Jan 21, 2020 10:47 am

hi JM, i chnage metern.php as you suggested and now it works perfectly. the value are now not negative and the graphics are without "holes"
if in the future i will update metern, i will need to implement again the modification on metern.php by myself due to my personal usage of virtmet.php ?
anyway virtmet.php is a script, like eflow, to calculate the energy consumption taken from the grid and split it in two different value: one that is during the night (in this time the energy has a different price compared to dyatime) and onther one during the day.

i have a second question, i have some meters that i not use anymore. is it possible to implement in the next version a tool/option to delete on visualization of metern about that sensors?
thanks
Image

jeanmarc
Posts: 1917
Joined: Thu Aug 29, 2013 7:16 am

Re: meterN 1.0

Post by jeanmarc » Tue Jan 21, 2020 11:59 am

Hi Marco,
Sure i have corrected it too, it will be ok in next update. Sorry for the inconvenience.
What i don't like about virtmet and eflow, is that they reads past data in CSV. (Like i previously did years ago)
It's better to use the houseenergy/com_daemon approach and read real live data. The authors should work on that, imho ;)

I have change the index, "---" won't show if there is no live command (for next update too), or read that post.
Also, you can remove a meter/sensor via "decommission" on top of admin_meter, as state in help

megamarco83
Posts: 102
Joined: Tue Apr 14, 2015 9:25 am

Re: meterN 1.0

Post by megamarco83 » Tue Jan 21, 2020 12:59 pm

jeanmarc wrote:
Tue Jan 21, 2020 11:59 am
Hi Marco,
Sure i have corrected it too, it will be ok in next update. Sorry for the inconvenience.
...."sorry"?!!? hey JM come on, don't joke:-) you are amazing on supporting and creting metern and 123solar, who as to say THANK YOU is me and the comunity that use yout software, your suggestions, and your help everytime to support us!!!!
jeanmarc wrote:
Tue Jan 21, 2020 11:59 am
What i don't like about virtmet and eflow, is that they reads past data in CSV. (Like i previously did years ago)
It's better to use the houseenergy/com_daemon approach and read real live data. The authors should work on that, imho ;)
understand, what i can say is that virtmet is very usefull to split the energy coming from grid to split it by different cost during the day.
i do not know if this difference during what we pay in the night and in the day is implemented only in italy....[/quote]
jeanmarc wrote:
Tue Jan 21, 2020 11:59 am
I have change the index, "---" won't show if there is no live command (for next update too), or read that post.
Also, you can remove a meter/sensor via "decommission" on top of admin_meter, as state in help
but, i use decommissioning about my meter: "volt"
but the only effect is to delete the data recorded inside csv, but the sensor volt is display again inside dashboard
and also inside the csv data are not recorded but the space is occupated by a double ,,

jeanmarc
Posts: 1917
Joined: Thu Aug 29, 2013 7:16 am

Re: meterN 1.0

Post by jeanmarc » Tue Jan 21, 2020 1:16 pm

thanks for your kinds words :)

I understand the aim of virtmet, i have already think of writing such com app but sadly there is too many differents electricity's billings (country/contract) to make one that fit all needs.

Decommissioning is indeed to remove data, you'll get ,, in csv. For the display, you can use this as index.php code.

megamarco83
Posts: 102
Joined: Tue Apr 14, 2015 9:25 am

Re: meterN 1.0

Post by megamarco83 » Tue Jan 21, 2020 1:51 pm

yes, i see the index.php posted days ago, do you introduce it in the next release togheter with metern.php fix?
thanks again

jeanmarc
Posts: 1917
Joined: Thu Aug 29, 2013 7:16 am

Re: meterN 1.0

Post by jeanmarc » Tue Jan 21, 2020 2:09 pm

yep

jeanmarc
Posts: 1917
Joined: Thu Aug 29, 2013 7:16 am

Re: meterN 1.0

Post by jeanmarc » Sun Feb 02, 2020 5:20 pm

Hello,

mN1.2.3 is out :

Bug : Index, missing live commands
Bug : Index, don't show live value and indicator if commands are empty
Bug : Last days and readings, avoid 1/1/1970 date
New : Instant notification, ditched Rpinotify for Telegram bot
Usual clean-up

Cheers

metus88
Posts: 10
Joined: Tue Nov 05, 2019 3:14 pm

Re: meterN 1.0

Post by metus88 » Sat Feb 08, 2020 6:40 pm

Hello, I just update to meterN 1.2.3 Thanks a lot for Telegram bot notify!
However I hava a question about it... I have a virtual meter to know how much energy I buy (consumption minus production). I use "eflow whinmet" command. I set 4200W notification warning.... I don't know if it is a problem of telegram but when I reboot my raspberry I receive a telegram notification that tell me that I used *****W (where **** is more that my limit 4200W). So I understand why the notification started (because the program thinks I use more energy what my limit) but I don't understand why the program think I use that energy (that is no true).
Below my standar eflow.php .

Code: Select all

#!/usr/bin/php
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
// This script will output --virtuals and estimated-- Wh in/out and self-consumption counters into a meterN compatible format
// It is simply based on your household's production and consumption real meters. The values will be averaged during a 5 min period and will lag from 5 min.
// The self-consumption estimation is only valid if the consumption and production is on the same phase.
// ln -s /var/www/comapps/eflow.php /usr/bin/eflow
// eflow [ whout | whin | selfc ]
// Modificato:.....Cesare Moretti
// Date:...........14/09/2016

// Setup your virtual meters identification numbers :
$whinmet  = 3; // Meter ID Prelievi (Whin)
$whoutmet = 4; // Meter ID Immissioni (Whout) 
$selfcmet = 5; // Meter ID Autoconsumo (selfc)

// No edit is needed below
if (!isset($argv[1])) {
$argv[1]=null;
}
if ($argv[1]== 'whout' || $argv[1]=='whin' || $argv[1]=='selfc') {
    
    $prodlist = array();
    $conslist = array();
    
    define('checkaccess', TRUE);
    include('/var/www/metern/config/config_main.php');
    date_default_timezone_set($DTZ);
    
    for ($i = 1; $i <= $NUMMETER; $i++) { // detect the production/consumption meter
        include("/var/www/metern/config/config_met$i.php");
        if (${'PROD' . $i} == 1) {
            $prodlist[] = $i;
        }
        if (${'PROD' . $i} == 2) {
            $conslist[] = $i;
        }
    }
  
    $dir    = '/var/www/metern/data/csv';
    $output = array();
    $output = glob($dir . '/*.csv');
    sort($output);
    $cnt = count($output);
    
    if (file_exists($output[$cnt - 1])) {
        $file       = file($output[$cnt - 1]); // today
        $contalines = count($file);

        if ($contalines > 1) {
            $prevarray = preg_split("/,/", $file[$contalines - 1]);
            
            $year  = substr($output[$cnt - 1], -12, 4);
            $month = substr($output[$cnt - 1], -8, 2);
            $day   = substr($output[$cnt - 1], -6, 2);
        } elseif ($contalines == 1 && file_exists($output[$cnt - 2])) { // yesterday, only header
            $file       = file($output[$cnt - 2]);
            $contalines = count($file);
            
            $prevarray = preg_split("/,/", $file[$contalines - 1]);
            
            $year  = substr($output[$cnt - 2], -12, 4);
            $month = substr($output[$cnt - 2], -8, 2);
            $day   = substr($output[$cnt - 2], -6, 2);
        } else {
            $year  = 0;
            $month = 0;
            $day   = 0;
        }
        
        $hour    = substr($prevarray[0], 0, 2);
        $min     = substr($prevarray[0], 3, 2);
        $UTCdate = strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $min);
        
        $nowutc = strtotime(date('Ymd H:i:s'));
        
        if ($nowutc - $UTCdate < 86400) { // (valore standard 330 - modificato a 86400)
            $cnt = count($prodlist);
            for ($i = 0; $i < $cnt; $i++) {
                $prodmet = $prodlist[$i];
                // Now retrieve the current value
                $prod = file_get_contents("/dev/shm/produzione$prodmet.txt");

                $datareturn = $prod;
                $datareturn = trim($datareturn);
                $datareturn = preg_replace("/^${'ID'.$prodmet}\(/i", '', $datareturn); // VALUE*UNIT)
                $prod_val_last = preg_replace("/\*[a-z0-9]+\)$/i", '', $datareturn); // VALUE
                #echo "$prod_val_last\n";

                $prod_val_first = trim($prevarray[$prodmet]);
                settype($prod_val_first, 'float');
                settype($prod_val_last, 'float');
                
                if ($prod_val_first <= $prod_val_last) {
                    $prod_val_last -= $prod_val_first;
                } else { // counter pass over
                    $prod_val_last += ${'PASSO' . $prodmet} - $prod_val_first;
                }
                settype($housep, 'float');
                $housep += $prod_val_last; //PRODUZIONE.
				
            }
            
            $cnt = count($conslist);
            for ($i = 0; $i < $cnt; $i++) {
                $consmet = $conslist[$i];
                // Now retrieve the current value
                $cons = file_get_contents("/dev/shm/consumi$consmet.txt");
            
                $datareturn = $cons;
                $datareturn = trim($datareturn);
                $datareturn = preg_replace("/^${'ID'.$consmet}\(/i", '', $datareturn); // VALUE*UNIT)
                $cons_val_last = preg_replace("/\*[a-z0-9]+\)$/i", '', $datareturn); // VALUE
                #echo "$cons_val_last\n";
                
                $cons_val_first = trim($prevarray[$consmet]);
                settype($cons_val_first, 'float');
                settype($cons_val_last, 'float');
                
                if ($cons_val_first <= $cons_val_last) {
                    $cons_val_last -= $cons_val_first;
                } else { // counter pass over
                    $cons_val_last += ${'PASSO' . $consmet} - $cons_val_first;
                }
                settype($housec, 'float');
                $housec += $cons_val_last; //CONSUMI
				
            }
                if ($argv[1] == 'whout') { // IMMISSIONI
                    $val = $housep - $housec;
                    if ($val < 0) {
                        $val = 0;
                    }
                    $val += $prevarray[$whoutmet];
                    if ($val > ${'PASSO' . $whoutmet}) {
                        $val -= ${'PASSO' . $whoutmet};
                    }
                    $id = ${'ID' . $whoutmet};
                }
            
                if ($argv[1] == 'whin') { // PRELIEVI
                    $val = $housec - $housep;
                    if ($val < 0) {
                        $val = 0;
                    }
                    $val += $prevarray[$whinmet];
                    if ($val > ${'PASSO' . $whinmet}) {
                        $val -= ${'PASSO' . $whinmet};
                    }
                    $id = ${'ID' . $whinmet};
                }
                
                if ($argv[1] == 'selfc') { // AUTOCONSUMO
                    if ($housep > $housec) {
                        $val = $housec;
                    } else {
                        $val = $housep;
                    }
                    $val += $prevarray[$selfcmet];
                    if ($val > ${'PASSO' . $selfcmet}) {
                        $val -= ${'PASSO' . $selfcmet};
                    }
                    $id = ${'ID' . $selfcmet};
                }
            settype($val, 'float');
        } else {
            if ($argv[1] == 'whout') {
                $id = ${'ID' . $whoutmet};
            }
            if ($argv[1] == 'whin') {
                $id = ${'ID' . $whinmet};
            }
            if ($argv[1] == 'selfc') {
                $id = ${'ID' . $selfcmet};
            }
            $val = null;
        }
    } else {
        $val = null;
    }
    
    $str = utf8_decode("$id($val*Wh)\n");
    echo "$str";
} else {
    die("Usage: eflow { whout | whin | selfc }\n");
}
?>
This is my metern setting:
Image

With Rpinotify and/or old metern version it did not uppen... Do you have some idea? Thanks

jeanmarc
Posts: 1917
Joined: Thu Aug 29, 2013 7:16 am

Re: meterN 1.0

Post by jeanmarc » Sat Feb 08, 2020 7:26 pm

Hi,
I'am sorry but you better contact the author of this eflow script ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests