FlexMeasures / flexmeasures

The intelligent & developer-friendly EMS to support real-time energy flexibility apps, rapidly and scalable.
https://flexmeasures.io
Apache License 2.0
145 stars 36 forks source link

API endpoints to add annotation to account, asset or sensor #470

Open nhoening opened 2 years ago

nhoening commented 2 years ago

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.

Flix6x commented 2 years ago

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.

nhoening commented 1 year ago

Two ideas: