Analytics endpoints for time-series sensor payloads used by the Rasa Action Server and other clients.
- With Docker (recommended): service
microservicesin a building compose file (e.g.docker-compose.bldg1.ymlordocker-compose.bldg2.yml).- Typical host: http://localhost:6001 (host → container 6000)
- Alternate (some bldg3 variants or isolation strategy): http://localhost:6002
- Health: GET
/health - Runner: POST
/analytics/run - See root
README.mdfor port matrix and isolation guidance.
- POST
/analytics/run- Body:
analysis_type(string, required)- Sensor data: either flat or nested payload
- Flat:
{ sensorName: [ {timestamp|datetime, reading_value}, ... ] } - Nested:
{ groupId: { innerKey: { timeseries_data: [ {datetime, reading_value}, ... ] } } }
- Flat:
- Optional params per analysis (e.g.,
acceptable_range,thresholds,method)
- Returns:
{ analysis_type, timestamp, results }
- Body:
Example request (nested):
{
"analysis_type": "analyze_temperatures",
"1": {
"Air_Temperature_Sensor": {
"timeseries_data": [
{"datetime": "2025-02-10 05:31:59", "reading_value": 22.5},
{"datetime": "2025-02-10 05:33:00", "reading_value": 23.0}
]
}
}
}- Environmental:
analyze_temperatures,analyze_humidity,analyze_co2_levels,analyze_pm_levels,analyze_noise_levels,analyze_formaldehyde_levels,analyze_air_quality,compute_air_quality_index - HVAC/air:
analyze_supply_return_temp_difference,analyze_air_flow_variation,analyze_pressure_trend,analyze_air_quality_trends,analyze_hvac_anomalies - Generic:
correlate_sensors,aggregate_sensor_data,analyze_sensor_trend,detect_anomalies,detect_potential_failures,forecast_downtimes - Ops:
analyze_device_deviation,analyze_failure_trends,analyze_recalibration_frequency
Notes:
- All functions accept flat or nested payloads and normalize timestamps.
- Results include human units and UK indoor defaults (where applicable): °C, %RH, ppm, µg/m³, etc.
- Anomaly detection supports
method: zscoreoriqr(robust).
Embedded UK-oriented guidelines include:
- Temperature: 18–24 °C; Humidity: 40–60 %RH
- CO2: good 400–1000 ppm; max 1500 ppm
- PM2.5: 35 µg/m³; PM10: 50 µg/m³
- Formaldehyde (HCHO): 0.1 mg/m³; Noise: ~55 dB(A)
You can override thresholds/ranges in the request. Responses include unit, acceptable_range, or acceptable_max metadata where relevant.
- Action Server calls this service via internal URL
http://microservices:6000/analytics/run(seerasa-ui/actions). - Decider Service optionally selects which
analysis_typeto run for a user question.
- Sensor naming: key detection is robust (e.g., matches "temperature" and "temp" while avoiding "attempt"). Prefer human-readable names in payloads.
- Thresholds: pass
acceptable_rangeorthresholdsper request to tailor to building standards. - New analyses: add a new function in
blueprints/analytics_service.pyand register it in the analysis registry used by/analytics/run.
- Health: open http://localhost:6001/health
- Smoke test:
python microservices/test_analytics_smoke.py— exercises all registered analyses with dummy data and prints a summary.