Zakladna migracia na viacej senzorov
This commit is contained in:
@@ -21,6 +21,10 @@ class MeasurementController extends Controller
|
||||
$startdate = $request->input('startdate',NULL);
|
||||
$enddate = $request->input('enddate',NULL);
|
||||
$host = $request->input('host','balkon');
|
||||
$model = $request->input('model','bme280');
|
||||
|
||||
if (preg_match("/^[a-zA-Z0-9_]+/", $model) == 0) $model = 'bme280';
|
||||
|
||||
if (!in_array($type,$types)) $type = $types[0];
|
||||
if ($startdate == NULL || $startdate == '') $startdate = "now()-1d";
|
||||
else $startdate = sprintf("'%s'",Carbon::parse($startdate)->toDateTimeString());
|
||||
@@ -28,7 +32,7 @@ class MeasurementController extends Controller
|
||||
if ($enddate == NULL || $enddate == '') $enddate = "now()";
|
||||
else $enddate = sprintf("'%s'",Carbon::parse($enddate)->toDateTimeString());
|
||||
|
||||
$q = sprintf("select time,value from bme280_value where host='%s' and type='%s' and time >= %s and time <= %s",$host,$type,$startdate,$enddate);
|
||||
$q = sprintf("select time,value from %s_value where host='%s' and type='%s' and time >= %s and time <= %s",$model,$host,$type,$startdate,$enddate);
|
||||
\Debugbar::info($q);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
@@ -49,8 +53,13 @@ class MeasurementController extends Controller
|
||||
// for t in ('temperature','humidity','pressure')
|
||||
$a = [];
|
||||
$host = $request->input('host','balkon');
|
||||
$model = $request->input('model','bme280');
|
||||
|
||||
if (preg_match("/^[a-zA-Z0-9_]+/", $model) == 0) $model = 'bme280';
|
||||
|
||||
|
||||
foreach (['temperature','humidity','pressure'] as $type) {
|
||||
$q = sprintf("select * from bme280_value where host='%s' and type='%s' order by time desc limit 1",$host,$type);
|
||||
$q = sprintf("select * from %s_value where host='%s' and type='%s' order by time desc limit 1",$model,$host,$type);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
foreach ($points as $p) {
|
||||
@@ -58,7 +67,7 @@ class MeasurementController extends Controller
|
||||
$a["time"] = Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC')->toATOMString();
|
||||
}
|
||||
}
|
||||
$q = sprintf("select * from esp32_value where host='%s' and type='voltage' order by time desc limit 1",$host,$type);
|
||||
$q = sprintf("select * from %s_value where host='%s' and type='voltage' order by time desc limit 1",$model,$host,$type);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
foreach ($points as $p) {
|
||||
|
||||
Reference in New Issue
Block a user