Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 1.83 KB

File metadata and controls

73 lines (50 loc) · 1.83 KB

This documents lists and gives examples for each route the backend should implement.

From sensor to backend

HTTP POST /ingress/windturbine

Complexity: medium

Used by wind turbine sensors to push data to the server. The request payload is a JSON string with the following structure:

{
    "windturbine": 1, // turbine ID in database
    "timestamp": 1741334062, // date of the measure
    "data": {
        "speed": 123.4, // speed of the turbine blade in rpm
        "power": 123.4  // generated power by the turbine in W
    }
}

Route should process the json, save its data. Note that you also should compute the new total_energy_produced value based on the power reported (you can assume the interval between two datapoints to always be 60 seconds).

If there is no wind turbine with the id provided route must respond with a 404 error. If there is an error in the json payload route must respond with a 500 error.

If everything is correct, route must respond with the following JSON:

{
    "status": "success"
}

UDP 12345 entrypoint

Complexity: medium

Used by solar panel sensors to push data to the server.

The payload is a : separated string with the following structure: id:temperature:power:timestamp.

For instance, 2:25.4:523.6:1741334062 is parsed in:

  • solar panel ID: 2
  • temperature: 25.4°C
  • power: 523.6W
  • timestamp: 1741334062

Similarly to the wind turbine, you should also create a new datapoint for total_energy_produced.

Sensors do not expect any response.

GET /grid/:id/production and /grid/:id/consumption

Complexity: hard

Returns the total production / consumption of the grid.

Exemple of /grid/1/production:

4439476.1618367

Example of /grid/1/consumption:

1605381.1528419708

Returns 404 if no grid with the id is found, Returns the value otherwise.