Purtroppo se attacco come in figura
non si riarma il differenziale.....
non si riarma il differenziale.....
$CMD_RETURN = exec($CMD_POOLING, $errornum);
#!/usr/bin/php if (isset($_SERVER['REMOTE_ADDR'])) { die('Direct access not permitted'); } // This script will output a 123solar counter into a meterN compatible format // ln -s /var/www/metern/comapps/pool123s.php /usr/bin/pool123s // then request Main command with 'pool123s energy' and live command 'pool123s power' // You'll need to setup the path to 123, your inverter number and your meter id $pathto123s = '/var/www/123solar'; $invtnum = 1; $METERID = '1'; $KWHTC = -89376; // Contatore iniziale in caso di azzeramento o sostituzione inverter // No edit is needed below if (isset($argv[1])) { define('checkaccess', TRUE); include("$pathto123s/config/config_main.php"); include("$pathto123s/config/config_invt$invtnum.php"); include("$pathto123s/scripts/memory.php"); date_default_timezone_set($DTZ); $KWHT = 0; @$shmid = shmop_open($LIVEMEMORY, 'a', 0, 0); if (!empty($shmid)) { $size = shmop_size($shmid); shmop_close($shmid); @$shmid = shmop_open($LIVEMEMORY, 'c', 0644, $size); if (!empty($shmid)) { $data = shmop_read($shmid, 0, $size); shmop_close($shmid); $memarray = json_decode($data, true); if ($argv[1] == 'power') { $nowUTC = strtotime(date("Ymd H:i:s")); if ($nowUTC - $memarray["SDTE$invtnum"] < 30) { $GP = $memarray["G1P$invtnum"] + $memarray["G2P$invtnum"] + $memarray["G3P$invtnum"]; if ($GP > 1000) { $GP = round($GP, 0); } else { $GP = round($GP, 1); } } else { // Too old $GP = 0; } } elseif ($argv[1] == 'energy') { $KWHT = round(($memarray["KWHT$invtnum"] * ${'CORRECTFACTOR' . $invtnum} * 1000), 0); //in Wh } } } if ($argv[1] == 'energy' && (empty($shmid) || $KWHT == 0)) { // 123s ain't running at night retrieve the value in csv $dir = $pathto123s . '/data/invt' . $invtnum . '/csv'; $output = glob($dir . "/*.csv"); sort($output); $xdays = count($output); if ($xdays > 1) { $lastlog = $output[$xdays - 1]; $lines = file($lastlog); $contalines = count($lines); $array_last = preg_split('/,/', $lines[$contalines - 1]); $KWHT = round(($array_last[27] * ${'CORRECTFACTOR' . $invtnum} * 1000), 0); //in Wh } else { $KWHT = 0; } } $KWHT += $KWHTC; if ($argv[1] == 'power' && empty($shmid)) { // 123s ain't running $GP = 0; } if ($argv[1] == 'power') { echo "$METERID($GP*W)\n"; } elseif ($argv[1] == 'energy') { file_put_contents("/run/shm/produzione$METERID.txt", "$METERID($KWHT*Wh)\n"); echo "$METERID($KWHT*Wh)\n"; } else { die("Abording: no valid argument given\n"); } } else { die("Usage: pool123s { power | energy }\n"); } ?>
Commenta