rest.api should for route /sensor/:id should take metric type into account
Closed this issue · 0 comments
do3meli commented
the route /sensor/:id
in rest.php
is currently only taking the id
attribute into account:
$app->get('/sensor/:id', function($id) use ($app) {
$res=getSensorById($id);
$app->render(200,o2h($res));
});
actually this can lead to a problem if one does have two or more metric types availalbe at 1 single sensor. for example the call to http://home.dominicschlegel.ch/api/sensor/26.A1E97B000000 is only returning 1 row but i have to sensor at this id.
my suggestion is to change the route to /sensor/:id/:metric
. this would allow to use the metric value for the lookup by getSensorById
:
$app->get('/sensor/:id/:metric', function($id,$metric) use ($app) {
$res=getSensorById($id,$metric);
$app->render(200,o2h($res));
});