-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGoSungrow.php
50 lines (48 loc) · 893 Bytes
/
GoSungrow.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$cmd = $cwd . "GoSungrow api get queryMutiPointDataList '" . json_encode($sg_opt) . "'";
debug($cmd);
ob_start();
passthru($cmd);
$ret = ob_get_clean();
// Check data
$out = json_decode($ret, true);
debug($out);
$sg_data = $out['data'];
/*
array(1) {
["2023-02-02T12:00:00Z"]=>
array(3) {
["timestamp"]=>
string(14) "20230202120000"
["ps_key"]=>
string(13) "5132189_1_1_1"
["points"]=>
array(7) {
["p1"]=>
int(2400)
["p14"]=>
int(574)
["p4"]=>
float(34.6)
["p5"]=>
float(423.4)
["p6"]=>
float(0.3)
["p7"]=>
float(466.5)
["p8"]=>
float(0.9)
}
}
}
*/
if(!is_array($sg_data)) {
echo 'No valid data from GoSungrow!' . PHP_EOL;
var_dump($ret);
die;
}
$data = array();
foreach($sg_data as $ts => $sg_status) {
$data[$sg_status['timestamp']] = $sg_status['points'];
}
?>