upload test, viac senzorov
This commit is contained in:
@@ -20,6 +20,7 @@ class MeasurementController extends Controller
|
||||
$type = $request->input('type', $types[0]);
|
||||
$startdate = $request->input('startdate',NULL);
|
||||
$enddate = $request->input('enddate',NULL);
|
||||
$host = $request->input('host','balkon');
|
||||
if (!in_array($type,$types)) $type = $types[0];
|
||||
if ($startdate == NULL || $startdate == '') $startdate = "now()-1d";
|
||||
else $startdate = sprintf("'%s'",Carbon::parse($startdate)->toDateTimeString());
|
||||
@@ -27,7 +28,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='balkon' and type='%s' and time >= %s and time <= %s",$type,$startdate,$enddate);
|
||||
$q = sprintf("select time,value from bme280_value where host='%s' and type='%s' and time >= %s and time <= %s",$host,$type,$startdate,$enddate);
|
||||
\Debugbar::info($q);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
@@ -43,12 +44,13 @@ class MeasurementController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
// for t in ('temperature','humidity','pressure')
|
||||
$a = [];
|
||||
$host = $request->input('host','balkon');
|
||||
foreach (['temperature','humidity','pressure'] as $type) {
|
||||
$q = sprintf("select * from bme280_value where host='balkon' and type='%s' order by time desc limit 1",$type);
|
||||
$q = sprintf("select * from bme280_value where host='%s' and type='%s' order by time desc limit 1",$host,$type);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
foreach ($points as $p) {
|
||||
@@ -56,7 +58,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='balkon' and type='voltage' order by time desc limit 1",$type);
|
||||
$q = sprintf("select * from esp32_value where host='%s' and type='voltage' order by time desc limit 1",$host,$type);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
foreach ($points as $p) {
|
||||
|
||||
Reference in New Issue
Block a user