Doplnenie grafov teploty, tlaku, vlhkosti
This commit is contained in:
@@ -5,8 +5,26 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class MeasurementController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(Request $request)
|
||||
{
|
||||
$type = $request->input('type', 'temperature');
|
||||
$q = sprintf("select time,value from bme280_value where host='balkon' and type='%s' and time > now()-1d",$type);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
$a = [];
|
||||
foreach ($points as $p) {
|
||||
$a[] = [ Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC'), $p["value"]];
|
||||
}
|
||||
return response()->json($a);
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user