Netgative counting

Talks about metering
mstuetz
Posts: 108
Joined: Sun Dec 29, 2013 1:20 pm

Re: Netgative counting

Post by mstuetz » Sun Feb 02, 2020 2:33 pm

ok, added housIO with a sensor. Let's see, if this shows what I want.
It's a SDM630 power meter. In the past I calculated actual KWHT with (imported-exported)*1000).

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

Re: Netgative counting

Post by jeanmarc » Sun Feb 02, 2020 3:02 pm

Hope it will be ok. Also take a look at houseenergy with com_daemon.

mstuetz
Posts: 108
Joined: Sun Dec 29, 2013 1:20 pm

Re: Netgative counting

Post by mstuetz » Wed Apr 22, 2020 5:06 am

You mentioned that I should use pool123s for getting data from 123solar.
My problem for havin a 24h meter for house production: During night time there are no KWHT counters in LIVEMEMORY.

Code: Select all

root@HPHOST:/var/www/html/metern/data/csv# date
Mi Apr 22 05:39:28 CEST 2020
root@HPHOST:/var/www/html/metern/data/csv# cat /dev/shm/123s_LIVEMEMORY.json
{"SDTE1":1587526681,"I1V1":0,"I1A1":0,"I1P1":0,"I2V1":0,"I2A1":0,"I2P1":0,"I3V1":0,"I3A1":0,"I3P1":0,"I4V1":0,"I4A1":0,"I4P1":0,"G1V1":0,"G1A1":0,"G1P1":0,"G2V1":0,"G2A1":0,"G2P1":0,"G3V1":0,"G3A1":0,"G3P1":0,"FRQ1":0,"EFF1":0,"INVT1":0,"BOOT1":0,"SSR1":0,"SDTE2":1587526681,"I1V2":0,"I1A2":0,"I1P2":0,"I2V2":0,"I2A2":0,"I2P2":0,"I3V2":0,"I3A2":0,"I3P2":0,"I4V2":0,"I4A2":0,"I4P2":0,"G1V2":0,"G1A2":0,"G1P2":0,"G2V2":0,"G2A2":0,"G2P2":0,"G3V2":0,"G3A2":0,"G3P2":0,"FRQ2":0,"EFF2":0,"INVT2":0,"BOOT2":0,"SSR2":0,"SDTE3":1587526681,"I1V3":0,"I1A3":0,"I1P3":0,"I2V3":0,"I2A3":0,"I2P3":0,"I3V3":0,"I3A3":0,"I3P3":0,"I4V3":0,"I4A3":0,"I4P3":0,"G1V3":0,"G1A3":0,"G1P3":0,"G2V3":0,"G2A3":0,"G2P3":0,"G3V3":0,"G3A3":0,"G3P3":0,"FRQ3":0,"EFF3":0,"INVT3":0,"BOOT3":0,"SSR3":0,"SDTE4":1587526681,"I1V4":0,"I1A4":0,"I1P4":0,"I2V4":0,"I2A4":0,"I2P4":0,"I3V4":0,"I3A4":0,"I3P4":0,"I4V4":0,"I4A4":0,"I4P4":0,"G1V4":0,"G1A4":0,"G1P4":0,"G2V4":0,"G2A4":0,"G2P4":0,"G3V4":0,"G3A4":0,"G3P4":0,"FRQ4":0,"EFF4":0,"INVT4":0,"BOOT4":0,"SSR4":0}
root@HPHOST:/var/www/html/metern/data/csv# /var/www/html/comapps/pool123sAll.php -power
solar(0*W)
root@HPHOST:/var/www/html/metern/data/csv# /var/www/html/comapps/pool123sAll.php -energy
Abording: KWHT not defined
root@HPHOST:/var/www/html/metern/data/csv#
Then later, 1st inverter is up:

Code: Select all

root@HPHOST:/var/www/html/metern/data/csv# date
Mi Apr 22 06:00:29 CEST 2020
root@HPHOST:/var/www/html/metern/data/csv# cat /dev/shm/123s_LIVEMEMORY.json
{"SDTE3":1587528035,"I1V3":120,"I1A3":0,"I1P3":0,"I2V3":null,"I2A3":null,"I2P3":null,"I3V3":null,"I3A3":null,"I3P3":null,"I4V3":null,"I4A3":null,"I4P3":null,"G1V3":232.3,"G1A3":0,"G1P3":0,"G2V3":null,"G2A3":null,"G2P3":null,"G3V3":null,"G3A3":null,"G3P3":null,"FRQ3":49.9,"EFF3":0.02,"INVT3":42,"BOOT3":null,"SSR3":null,"KWHT3":3634.546632}
root@HPHOST:/var/www/html/metern/data/csv# /var/www/html/comapps/pool123sAll.php -energy
PHP Notice:  Undefined index: KWHT2 in /var/www/html/comapps/pool123sAll.php on line 41
solar(37037588*Wh)
root@HPHOST:/var/www/html/metern/data/csv#
Do you have an idea of how I could solve the "missing KWHT counter" issue best?

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

Re: Netgative counting

Post by jeanmarc » Wed Apr 22, 2020 6:10 am

I have to check but latest 123s keep kWh value when sleeping, obviously you may not reboot by night with current pool123s.
Latest mN should also retrieve latest counter values from csv data if no value where returns.

Do you use older versions ?
Could you past your pool123sAll.php script ?

mstuetz
Posts: 108
Joined: Sun Dec 29, 2013 1:20 pm

Re: Netgative counting

Post by mstuetz » Thu Apr 23, 2020 6:56 am

Upgraded 123s from 1.8.3.3 to 1.8.4.1 last night.
Had to modify pool123sAll.php script to handle all 4 inverters I'm running. I'm convinced that the bug with the missing KWHT counter during sleep was causing the issue.
We'll see tonight, if it keeps the data and I'll post the result.

mstuetz
Posts: 108
Joined: Sun Dec 29, 2013 1:20 pm

Re: Netgative counting

Post by mstuetz » Fri Apr 24, 2020 9:46 am

Unfortunatly the counters are gone as soon as 123s falls asleep.

Code: Select all

root@HPHOST:/var/www/html/comapps# cat /dev/shm/123s_LIVEMEMORY.json
{"SDTE1":1587670681,"I1V1":0,"I1A1":0,"I1P1":0,"I2V1":0,"I2A1":0,"I2P1":0,"I3V1":0,"I3A1":0,"I3P1":0,"I4V1":0,"I4A1":0,"I4P1":0,"G1V1":0,"G1A1":0,"G1P1":0,"G2V1":0,"G2A1":0,"G2P1":0,"G3V1":0,"G3A1":0,"G3P1":0,"FRQ1":0,"EFF1":0,"INVT1":0,"BOOT1":0,"SSR1":0,"SDTE2":1587670681,"I1V2":0,"I1A2":0,"I1P2":0,"I2V2":0,"I2A2":0,"I2P2":0,"I3V2":0,"I3A2":0,"I3P2":0,"I4V2":0,"I4A2":0,"I4P2":0,"G1V2":0,"G1A2":0,"G1P2":0,"G2V2":0,"G2A2":0,"G2P2":0,"G3V2":0,"G3A2":0,"G3P2":0,"FRQ2":0,"EFF2":0,"INVT2":0,"BOOT2":0,"SSR2":0,"SDTE3":1587670681,"I1V3":0,"I1A3":0,"I1P3":0,"I2V3":0,"I2A3":0,"I2P3":0,"I3V3":0,"I3A3":0,"I3P3":0,"I4V3":0,"I4A3":0,"I4P3":0,"G1V3":0,"G1A3":0,"G1P3":0,"G2V3":0,"G2A3":0,"G2P3":0,"G3V3":0,"G3A3":0,"G3P3":0,"FRQ3":0,"EFF3":0,"INVT3":0,"BOOT3":0,"SSR3":0,"SDTE4":1587670681,"I1V4":0,"I1A4":0,"I1P4":0,"I2V4":0,"I2A4":0,"I2P4":0,"I3V4":0,"I3A4":0,"I3P4":0,"I4V4":0,"I4A4":0,"I4P4":0,"G1V4":0,"G1A4":0,"G1P4":0,"G2V4":0,"G2A4":0,"G2P4":0,"G3V4":0,"G3A4":0,"G3P4":0,"FRQ4":0,"EFF4":0,"INVT4":0,"BOOT4":0,"SSR4":0}
root@HPHOST:/var/www/html/comapps# date
Do Apr 23 21:39:37 CEST 2020
root@HPHOST:/var/www/html/comapps# ./pool123sAll.php -energy
Abording: KWHT not defined
Here the code from "my" pool123sAll:

Code: Select all

#!/usr/bin/php
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
// 123solar config
$pathto123s = '/var/www/html/123solar';
$invtnum    = 1;
// meterN config
$METERID    = 'solar';
// No edit is needed below
if (isset($argv[1])) {
    include("$pathto123s/config/memory.php");
    $KWHT = null;
    if (file_exists($LIVEMEMORY)) {
        $data     = file_get_contents($LIVEMEMORY);
        $memarray = json_decode($data, true);
        $nowUTC   = strtotime(date("Ymd H:i:s"));
        if ($argv[1] == '-power') {
            if ($nowUTC - $memarray["SDTE$invtnum"] < 300) {
                $GPa = $memarray["G1P1"] + $memarray["G2P1"] + $memarray["G3P1"];
                $GPb = $memarray["G1P2"] + $memarray["G2P2"] + $memarray["G3P2"];
                $GPc = $memarray["G1P3"] + $memarray["G2P3"] + $memarray["G3P3"];
                $GPd = $memarray["G1P4"] + $memarray["G2P4"] + $memarray["G3P4"];
                $GPall=$GPa+$GPb+$GPc+$GPd;
                $GP = round($GPall, 1);
            } else { // Too old
                die("Abording: Too late value\n");
            }
            echo "$METERID($GP*W)\n";
        } elseif ($argv[1] == '-energy') {
            if ($nowUTC - $memarray["SDTE$invtnum"] < 600) {
                if (isset($memarray["KWHT$invtnum"])) {
                    $KWHTa = round($memarray["KWHT1"] * 1000); // Wh
                    $KWHTb = round($memarray["KWHT2"] * 1000); // Wh
                    $KWHTc = round($memarray["KWHT3"] * 1000); // Wh
                    $KWHTd = round($memarray["KWHT4"] * 1000); // Wh
                    $KWHT=$KWHTa+$KWHTb+$KWHTc+$KWHTd;
                    echo "$METERID($KWHT*Wh)\n";
                } else {
                die("Abording: KWHT not defined\n");
                }
            } else {
                die("Abording: Too late value\n");
            }
        } else {
            die("Aborting: no valid argument given\n");
        }
    } else { // 123s ain't running
        die("Abording: Empty SHM\n");
    }
} else {
    die("Usage: pool123s { -power | -energy }\n");
}
?>
Is there something wrong with my editing in pool123sAll or is it really the missing KWHT counters in the livememory?

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

Re: Netgative counting

Post by jeanmarc » Fri Apr 24, 2020 10:12 am

hmm ok.. i believe it's because you have several inverters, maybe change 123solar.php with this at line 111 but i haven't test yet

Code: Select all

..
$livememarray["SSR$i"]  = 0;
$livememarray["KWHT$i"] = $livememarray["KWHT$i"];
$memarray["invtstat$i"] = '';
..
I also advice you take a look at pooltot.php available in misc of comapps example. It make a virtual meters with reals meters, at worst it search values in csv.

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

Re: Netgative counting

Post by jeanmarc » Fri Apr 24, 2020 8:04 pm

Seem to work with 1 inverter :

Code: Select all

[root@i3 scripts]# more /dev/shm/123s_LIVEMEMORY.json 
{"SDTE1":1587754950,"I1V1":0,"I1A1":0,"I1P1":0,"I2V1":0,"I2A1":0,"I2P1":0,"I3V1":0,"I3A1":0,"I3P1":0,"I4V1":0,"I4A1":0,"
I4P1":0,"G1V1":0,"G1A1":0,"G1P1":0,"G2V1":0,"G2A1":0,"G2P1":0,"G3V1":0,"G3A1":0,"G3P1":0,"FRQ1":0,"EFF1":0,"INVT1":0,"BO
OT1":0,"SSR1":0,"KWHT1":31819.937}
[root@i3 scripts]# more /dev/shm/123s_MEMORY.json 
{"awake":false,"First1":"31799.545\r\n","pmotd1":3245.3,"pmotdt1":1587720960,"pmotdmulti":0,"pmotdtmulti":0,"status":"12
3Solar ZzzZ","invtstat1":"","5minflag1":false,"msgq1":1587563340,"AWt1":1587754440,"AWriso1":20.05,"AWileak1":0,"peakotd
1":3169.6,"peakoat1":4613.7,"Last1":31819.937}

mstuetz
Posts: 108
Joined: Sun Dec 29, 2013 1:20 pm

Re: Netgative counting

Post by mstuetz » Fri Apr 24, 2020 8:42 pm

No, not here. :?
After 123s falls asleep the counters are "null".

Code: Select all

root@HPHOST:/var/www/html/comapps#  cat /dev/shm/123s_LIVEMEMORY.json
{"SDTE1":1587756961,"I1V1":0,"I1A1":0,"I1P1":0,"I2V1":0,"I2A1":0,"I2P1":0,"I3V1":0,"I3A1":0,"I3P1":0,"I4V1":0,"I4A1":0,"I4P1":0,"G1V1":0,"G1A1":0,"G1P1":0,"G2V1":0,"G2A1":0,"G2P1":0,"G3V1":0,"G3A1":0,"G3P1":0,"FRQ1":0,"EFF1":0,"INVT1":0,"BOOT1":0,"SSR1":0,"KWHT1":null,"SDTE2":1587756961,"I1V2":0,"I1A2":0,"I1P2":0,"I2V2":0,"I2A2":0,"I2P2":0,"I3V2":0,"I3A2":0,"I3P2":0,"I4V2":0,"I4A2":0,"I4P2":0,"G1V2":0,"G1A2":0,"G1P2":0,"G2V2":0,"G2A2":0,"G2P2":0,"G3V2":0,"G3A2":0,"G3P2":0,"FRQ2":0,"EFF2":0,"INVT2":0,"BOOT2":0,"SSR2":0,"KWHT2":null,"SDTE3":1587756961,"I1V3":0,"I1A3":0,"I1P3":0,"I2V3":0,"I2A3":0,"I2P3":0,"I3V3":0,"I3A3":0,"I3P3":0,"I4V3":0,"I4A3":0,"I4P3":0,"G1V3":0,"G1A3":0,"G1P3":0,"G2V3":0,"G2A3":0,"G2P3":0,"G3V3":0,"G3A3":0,"G3P3":0,"FRQ3":0,"EFF3":0,"INVT3":0,"BOOT3":0,"SSR3":0,"KWHT3":null,"SDTE4":1587756961,"I1V4":0,"I1A4":0,"I1P4":0,"I2V4":0,"I2A4":0,"I2P4":0,"I3V4":0,"I3A4":0,"I3P4":0,"I4V4":0,"I4A4":0,"I4P4":0,"G1V4":0,"G1A4":0,"G1P4":0,"G2V4":0,"G2A4":0,"G2P4":0,"G3V4":0,"G3A4":0,"G3P4":0,"FRQ4":0,"EFF4":0,"INVT4":0,"BOOT4":0,"SSR4":0,"KWHT4":null}
root@HPHOST:/var/www/html/comapps# ./pool123sAll.php -energy
Abording: KWHT not defined
root@HPHOST:/var/www/html/comapps# php pooltot.php -power

Power #10 PV_Überschuss : 000003 W

Power #11 PV_Erzeugung : 0 W
total(3*W)
root@HPHOST:/var/www/html/comapps# php pooltot.php -energy
Previous KWHtot value : 1872 kWh

Getting latest energy for #10 (PV_Überschuss) : 21997857 kWh
Previous value: 21988449 kWh
The difference is 9408, saving as prev value 21997857 for #10 (PV_Überschuss)

Getting latest energy for #11 (PV_Erzeugung) :  kWh

Saving total #1 (total) : 11280 kWh
--
total(11280*Wh)
root@HPHOST:/var/www/html/comapps#

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

Re: Netgative counting

Post by jeanmarc » Sat Apr 25, 2020 7:21 am

Did you change line 111 ? What inverter are you using (maybe they report 0 kwh) ?
Using pooltot -energy in verbose should say "Getting latest energy for #10 .. " If you have trouble setting it, can you PM me a temporary ssh access ?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests