metern with 2 raspberry

Talks about metering
Post Reply
SiRe
Posts: 4
Joined: Thu Nov 23, 2017 12:31 pm

metern with 2 raspberry

Post by SiRe » Thu Nov 23, 2017 12:53 pm

Hello everyone,
I just joined the forum!
Usage 2 Raspberry one detects production data from the Aurora inverter through 123solar loggers the other detects consumption by an SDM120C and registers them on the meter.
I wanted to extract the production data of the first raspberry and integrate them on metern in the 2nd raspberry how can i do it?
Thank you!

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

Re: metern with 2 raspberry

Post by jeanmarc » Thu Nov 23, 2017 3:40 pm

Hi,
Try this remotepool123s

Code: Select all

#!/usr/bin/php
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
// This script will output a 123solar counter into a meterN compatible format
// Configure, then ln -s /srv/http/comapps/remotepool123s.php /usr/bin/remotepool123s
// Request Main command with 'remotepool123s -energy' and live command 'remotepool123s -power'

// 123solar config
$invtnum    = 1;
$remotedata = file_get_contents("http://192.168.0.10/123solar/programs/programlive.php?invtnum=$invtnum");
//print_r($remotedata);
// meterN config
$METERID    = 'solar';

// No edit is needed below
if (isset($argv[1])) {
    $KWHT = null;
    if (!empty($remotedata)) {
        $memarray = json_decode($remotedata, true);
        $nowUTC   = strtotime(date("Ymd H:i:s"));
        if ($argv[1] == '-power') {
            if ($nowUTC - $memarray["SDTE"] < 30) {
                $GP = $memarray["G1P"] + $memarray["G2P"] + $memarray["G3P"];
                $GP = round($GP, 1);
            } else { // Too old
                $GP = 0;
            }
            echo "$METERID($GP*W)\n";
        } elseif ($argv[1] == '-energy') {
            if ($nowUTC - $memarray["SDTE"] < 600) {
                if (isset($memarray["KWHT"])) {
                    $KWHT = round($memarray["KWHT"] * 1000); // Wh
                    echo "$METERID($KWHT*Wh)\n";
                } else {
                die("Abording: KWHT not defined\n");
		}
            } else {
                die("Abording: Too late value\n");
            }
        } else {
            die("Abording: no valid argument given\n");
        }
    } else { // 123s ain't running
        die("Abording: Empty SHM\n");
    }
} else {
    die("Usage: pool123s { power | energy }\n");
}
?>

SiRe
Posts: 4
Joined: Thu Nov 23, 2017 12:31 pm

Re: metern with 2 raspberry

Post by SiRe » Thu Nov 23, 2017 6:59 pm

Thanks jeanmarc, but I have this problem:
I replaced the file pool123s with what you posted by modifying the IP address but I get this error:

root@raspberrypi:/home/pi# pool123s energy
Abording: no valid argument given
root@raspberrypi:/home/pi#

help me !

thank you

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

Re: metern with 2 raspberry

Post by jeanmarc » Thu Nov 23, 2017 7:43 pm

remotepool123s -power
remotepool123s -energy
;)

SiRe
Posts: 4
Joined: Thu Nov 23, 2017 12:31 pm

Re: metern with 2 raspberry

Post by SiRe » Thu Nov 23, 2017 10:51 pm

you are right!
but now I get this:

root@raspberrypi:/home/pi# remotepool123s -energy
Abording: KWHT not defined
root@raspberrypi:/home/pi# remotepool123s -power
1(0*W)
root@raspberrypi:/home/pi# :?

SiRe
Posts: 4
Joined: Thu Nov 23, 2017 12:31 pm

Re: metern with 2 raspberry

Post by SiRe » Fri Nov 24, 2017 9:11 am

wonderful!
it works....
when I did the test, the inverter was off
thank you very much, without your help I would never have done it.
I have provided your script on the Italian forum.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest