Deze gebruik ik om mijn data naar pvoutput.org te uploaden. Weliswaar gebaseerd op mijn eigen datamodel en niet heel erg youless georienteerd, maar het moet een goede start vormen:
In het kort: het php script creeert een shell script en dat shell script voer je uit. Op zich is het ook prima mogelijk om curl vanuit php te draaien, maar da's iets ingewikkelder. Had ik even geen zin in.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| function pvo_daily(){
//Daily output for pvoutput.org. date, production, Maxac, maxactime,
$sql = 'select date, production, maxac, maxactime
from (select date_format(timestamp, "%Y%m%d") date
, round(1000*(max(kWhCalibrated) - min(kWhCalibrated)), 0) production
from pvtotals
where timestamp > curdate()
) a
, (select realtimepower maxac
,time(timestamp) maxactime
from pvfacts
where timestamp > curdate()
and realtimepower = (select max(realtimepower)
from pvfacts
where timestamp > curdate()
)
limit 1
) b';
$result=mysql_query($sql);
$date = mysql_result($result, 0,0);
$production = mysql_result($result, 0,1);
$maxac = mysql_result($result, 0,2);
$maxactime = mysql_result($result, 0,3);
$hostcmd = 'curl -d "d=' . $date . '"'
. ' -d "g=' . $production . '"'
. ' -d "pp=' . $maxac . '"'
. ' -d "pt=' . $maxactime . '"'
. ' -H "X-Pvoutput-Apikey: <jouwapikey>"'
. ' -H "X-Pvoutput-SystemId: <jouwsystemid>"'
. ' http://pvoutput.org/service/r2/addoutput.jsp';
$fp=fopen('/tmp/pvo.sh','w+');
fwrite($fp, $hostcmd);
fclose($fp);
} |
In het kort: het php script creeert een shell script en dat shell script voer je uit. Op zich is het ook prima mogelijk om curl vanuit php te draaien, maar da's iets ingewikkelder. Had ik even geen zin in.
code:
1
2
3
| #pvreporter.php will output .js files and a pvo.sh /opt/bin/pvreporter.php sh /tmp/pvo.sh |






