Sensor thresholds are the rules that tell theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt
Use this file to discover all available pages before exploring further.
AnomalyDetectionService when a reading is abnormal. Each sensor can have at most one threshold record. When a reading arrives via POST /api/readings, GreenhouseMonitor.processSensorReading() looks up the threshold for the sensor and evaluates four conditions: value out of range, no data received for too long, value stuck at the same level, and sudden spike. Sensors without an active threshold are silently skipped by the anomaly pipeline.
Anomaly detection only runs for sensors that have an active threshold (
active: true). Creating a threshold via PUT always sets active to true. To suspend monitoring for a sensor without deleting its threshold, delete the threshold record and recreate it when needed.Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/sensors/{id}/threshold | Retrieve the threshold for a sensor |
PUT | /api/sensors/{id}/threshold | Create or update the threshold for a sensor (upsert) |
DELETE | /api/sensors/{id}/threshold | Remove the threshold for a sensor |
GET /api/sensors//threshold
Returns the threshold record for the given sensor. Returns404 if no threshold has been configured.
Path parameters
The sensor ID whose threshold to retrieve.
Response
curl example
PUT /api/sensors//threshold
Creates the threshold if one does not yet exist, or updates the existing record. This is a full upsert — only fields present in the request body are changed; omitted fields retain their stored values. Theactive flag is always set to true on every save.
Path parameters
The sensor ID to configure a threshold for.
Body parameters
Lower bound for acceptable readings. When a reading falls below this value, an anomaly event is raised. Set to
null to disable the lower-bound check.Upper bound for acceptable readings. When a reading exceeds this value, an anomaly event is raised. Set to
null to disable the upper-bound check.Number of minutes without any reading before the service raises a “no data” anomaly. Use this to detect sensor disconnections or network outages.
Number of minutes during which the sensor reports the same value before the service raises a “stuck value” anomaly. Catches frozen sensors or broken ADC circuits.
Percentage change between consecutive readings that qualifies as a spike. For example,
50.0 means a jump of more than 50 % from the previous value triggers a spike anomaly.Response fields
Auto-generated threshold record identifier.
The sensor this threshold applies to.
Lower acceptable bound.
null when the check is disabled.Upper acceptable bound.
null when the check is disabled.No-data timeout in minutes.
Stuck-value window in minutes.
Spike detection threshold as a percentage of the previous reading.
Always
true after a PUT. Delete the record to suspend anomaly detection.ISO-8601 datetime of the last update, set server-side on every save.
curl examples
DELETE /api/sensors//threshold
Removes the threshold record for the sensor. After deletion, the sensor is excluded from all anomaly detection checks until a new threshold is created withPUT.
Path parameters
The sensor ID whose threshold to delete.