EN/API/ControlPointsAndMeasurement

From Smart Biogas Wiki
Jump to navigation Jump to search

◀ Back to API Menu

List of Plant Control Points

Authentication must be specified in the request header

X-API-TOKEN: {128-character key provided for the specific plant}

Each plant has a set of standardized control points; there may be differences between biogas and biomethane plants. Each control point can, in turn, have multiple measurements.

For each measurement, readings can be entered at variable frequencies. These frequencies are described in each measurement, but are not binding.

Data for a measurement can be:

  • single point readings
  • progressive values (counters)
  • sampling of a period with an average value.

These characteristics can be found in the master data of the measurements themselves.

Each control point has a code of this type:

a.bb

which is followed by measurements with an additional code:

in total, a measurement will be defined by a code that includes the control point and the measurement itself.

Example:

2.04.a

2.04 -> control point

a -> measurement


Control Points List

GET https://smartbiogas.it/api/v1/controlpoints

Result: Json with an array of results

[
	{
		"plant_control_points_id": controlPointId,
		"f_cod": "Textual code (n.mm format)",
		"f_json_description": "{\"it\":\"descrizione in italiano\",\"en\":\"Description in English\",\"es\":\"...\",\"fr\":\"...\"}"
	},
	{
		"plant_control_points_id": 10401,
		"f_cod": "2.08",
		"f_json_description": "{\"it\":\"BG alla caldaia\",\"en\":\"Biogas to the boiler\",\"es\":\"Biogas to the boiler\",\"fr\":\"Biogas to the boiler\"}"
	},
	...
]


Control Point Data and Linked Measurements

Multiple measurements can be associated with each control point. Each measurement will have a history of readings, which represent the actual data over time.

GET https://smartbiogas.it/api/v1/controlpoints/{controlPointId}

Example: https://smartbiogas.it/api/v1/controlpoints/10335

Result: Same Json as above for a single control point containing a list called "misure".

[
	{
		"plant_control_points_id": controlPointId,
		"f_cod": "Textual code (n.mm format)",
		"f_json_description": "{\"it\":\"descrizione in italiano\",\"en\":\"Description in English\",\"es\":\"...\",\"fr\":\"...\"}",
		"measures": [
			{
				"plant_control_points_misure_id": measureId (linked to this plant / control point),
				"f_description": "Textual description",
				"frequency_unita_misura_id": unitOfMeasurementId (of the sampling frequency: from the Time group),
				"f_frequency": frequency value,
				"measure_unita_misura_id": unitOfMeasurementId (of the measurement values),
				"measure_type_id": measureTypeId (see Measurement types),
				"f_cod_misura": "Complete code of control point and measurement"
			},
			{
				"plant_control_points_misure_id": 21042,
				"f_description": "EE PV1 Production",
				"frequency_unita_misura_id": 32,
				"f_frequency": "1.0000",
				"measure_unita_misura_id": 25,
				"measure_type_id": 1,
				"f_cod_misura": "2.12.a"
			},


Search Control Points

GET https://smartbiogas.it/api/v1/controlpoints?f_cod={code or part of the code}

Example: https://smartbiogas.it/api/v1/controlpoints?f_cod=2.13


Inserting a Reading

Once a measurement (plant_control_points_misure_id) and its related control point (plant_control_points_id) have been identified, a reading can be inserted into the history.

The unit of measurement of the reading sent by the sensor must be decided beforehand and configured on SB. It is possible to identify the current unit of measurement via the API in the data of the measurement for which the reading is being inserted.

POST https://smartbiogas.it/api/v1/controlpoints/{controlPointId}/measures/{measureId}/readings

Example: https://smartbiogas.it/api/v1/controlpoints/10431/measures/20583/readings

In addition to the X-API-TOKEN authentication, the call must have a JSON formatted as follows:

{
	"f_data_lettura_inizio_campione": DATETIME (nullable) "date/time in ISO format",
	"f_data_lettura": DATETIME "date/time in ISO format",
	"f_rilevatore": TEXT "Operator identification",
	"f_lettura": DECIMAL "numerical measurement",
	"f_note": TEXT "Any notes",
	"plant_inspections_id": INT "Visit ID (leave as -1 or do not include the field at all if the measurement is not entered for visits/inspections)",
	"analisi_id": INT "Analysis ID (leave as -1 or do not include the field at all if the measurement is not from an analysis)"
}

Example of measurement over a 1-hour period:

{
	"f_data_lettura_inizio_campione": "2006-01-01 00:00:00",
	"f_data_lettura": "2026-01-01 01:00:00",
	"f_rilevatore": "test api",
	"f_lettura": 15.42,
	"f_note": "15.42 kW in one hour",
	"analisi_id": -1
}

Example of a point measurement:

{
	"f_data_lettura_inizio_campione": "",
	"f_data_lettura": "2026-01-01 23:59:59",
	"f_rilevatore": "",
	"f_lettura": 15.42,
	"f_note": "At the end of the day, the meter showed 15.42 kW",
	"analisi_id": -1
}

The system should return a JSON as a result:

{
	"error_code": see API error codes,
	"reading_id": readingId (returns the ID just inserted),
	"message": "Message to understand any error"
}