Doplnenie grafov teploty, tlaku, vlhkosti

This commit is contained in:
2021-01-12 11:28:13 +01:00
parent 2604e77dc6
commit a6a0b7e3b7
9 changed files with 317 additions and 6 deletions

View File

@@ -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.
*