forked from SkullKill/Fronius_PVOutput_Uploader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fronius_sensor.php
41 lines (35 loc) · 1.14 KB
/
fronius_sensor.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
<?php
// Configuration Options
$sqlFile = ""; // SQLite database file
// Open database
class PVOutputDB extends SQLite3 {
function __construct($sqlFile) {
$this->open($sqlFile);
}
}
$db = new PVOutputDB($sqlFile);
if(!$db) {
echo $db->lastErrorMsg();
} else {
#echo "Opened database successfully\n";
}
// Query latest previous statistics
$results = $db->query('SELECT * FROM pvoutput ORDER BY date desc, time desc LIMIT 1');
$row = $results->fetchArray();
// Output sensor details in JSON format
$vals = array(
'date' => $row['date'],
'time' => $row['time'],
'inverter_energy_day_total' => $row['iEnergyDayTotal'],
'inverter_power_live' => $row['iPowerLive'],
'inverter_voltage_live' => $row['iVoltageLive'],
'consumption_energy_day_total' => $row['cEnergyDayTotal'],
'consumption_power_live' => $row['cPowerLive'],
'meter_export_day_total' => $row['mExportDayTotal'],
'meter_import_day_total' => $row['mImportDayTotal'],
'meter_power_live' => $row['mPowerLive'],
'meter_power_live_export' => $row['mPowerLiveExport'],
'meter_power_live_import' => $row['mPowerLiveImport']
);
echo json_encode($vals);
?>