flexmeasures icon indicating copy to clipboard operation
flexmeasures copied to clipboard

API endpoints to add annotation to account, asset or sensor

Open nhoening opened this issue 1 year ago • 2 comments

Annotations are simple notes with metadata about our time series data, and they can be attached to sensors, assets and accounts. Their value lies in enriching the IoT data ― they store what users might say about data (also useful for machine learning potential) and show contextual information, e.g. about national holidays and such, for better understanding of plots.

They are already shown on sensor charts, which uses the /api/dev/sensor/<id>/chart endpoint to read them.

Here, we'd like to support adding them via the API. We'd like to have these three endpoints, placed in /api/dev/annotations.py:

POST /accounts/<id>/annotations
POST /assets/<id>/annotations
POST /sensors/<id>/annotations

Obviously, the user needs the update permission on the entity (using @permission_required_for_context) to use the endpoint. We also need some tests. Other API endpoints (see /api/v3_0) can serve as inspiration.

Let's start with POST /sensors/<id>/annotations.

nhoening avatar Jul 28 '22 11:07 nhoening

Maybe better to start with POST /assets/<id>/annotations, because asset annotations you can see straightaway in the UI (on the sensor page).

Reason for that is that so far, all of our clients' annotations have been on the asset level rather than on the sensor level.

Flix6x avatar Aug 12 '22 12:08 Flix6x

Two ideas:

  • Maybe we don't need the permission to update the entity (e.g. asset), but the create-children permission is more appropriate. We can also discuss which role we can think of that gets the right permission (annotator?) If you send data about a sensor, you should also be able to send annotations, right?
  • A first use case I'd see is that in our V2G demo, I'd like to see certain user events which are not in sensor data, e.g. that FlexMeasures' schedule was overwritten by the HEMS.

nhoening avatar Dec 15 '22 13:12 nhoening