Simulation mode generates realistic greenhouse sensor data for development and testing purposes.
Simulation mode should NEVER be enabled in production environments. It generates fake data instead of reading from actual sensors.
Get Simulation Status
GET /api/v1/simulation/status
Returns the current simulation configuration and status.
Response
Whether simulation mode is currently enabled
Greenhouse ID being simulated (default: “001”)
Interval in milliseconds between simulated readings (default: 5000)
Whether the simulation scheduler is actively running
Example
curl -X GET "https://api.example.com/api/v1/simulation/status" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
{
"enabled": true,
"greenhouseId": "001",
"interval": 5000,
"running": true
}
Start Simulation
Start the simulation scheduler.
POST /api/v1/simulation/start
Simulation must be enabled in configuration (greenhouse.simulation.enabled: true in application.yaml) before it can be started.
Example
curl -X POST "https://api.example.com/api/v1/simulation/start" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Stop Simulation
Stop the simulation scheduler.
POST /api/v1/simulation/stop
Example
curl -X POST "https://api.example.com/api/v1/simulation/stop" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Generate Single Reading
Generate a single simulated sensor reading without starting the scheduler.
POST /api/v1/simulation/generate
This endpoint is useful for testing data processing without continuous simulation.
Response
Returns a RealDataDto object with 22 simulated sensor fields:
ISO 8601 timestamp of the simulated reading
TEMPERATURA INVERNADERO 01
Simulated temperature for greenhouse 1 (15-30°C)
Simulated humidity for greenhouse 1 (40-80%)
Simulated sector 1 status (0 or 1)
Show All 22 Simulated Fields
- Temperature fields (6): TEMPERATURA INVERNADERO 01-03
- Humidity fields (6): HUMEDAD INVERNADERO 01-03
- Sector fields (12): INVERNADERO_01_SECTOR_01 through INVERNADERO_03_SECTOR_04
- Extractor fields (3): INVERNADERO_01_EXTRACTOR through INVERNADERO_03_EXTRACTOR
- Metadata: timestamp, greenhouseId
Example
curl -X POST "https://api.example.com/api/v1/simulation/generate" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
{
"timestamp": "2025-03-03T22:15:30Z",
"TEMPERATURA INVERNADERO 01": 23.5,
"HUMEDAD INVERNADERO 01": 65.2,
"TEMPERATURA INVERNADERO 02": 24.1,
"HUMEDAD INVERNADERO 02": 62.8,
"TEMPERATURA INVERNADERO 03": 22.9,
"HUMEDAD INVERNADERO 03": 68.5,
"INVERNADERO_01_SECTOR_01": 1,
"INVERNADERO_01_SECTOR_02": 0,
"INVERNADERO_01_SECTOR_03": 1,
"INVERNADERO_01_SECTOR_04": 1,
"INVERNADERO_02_SECTOR_01": 0,
"INVERNADERO_02_SECTOR_02": 1,
"INVERNADERO_02_SECTOR_03": 0,
"INVERNADERO_02_SECTOR_04": 1,
"INVERNADERO_03_SECTOR_01": 1,
"INVERNADERO_03_SECTOR_02": 1,
"INVERNADERO_03_SECTOR_03": 0,
"INVERNADERO_03_SECTOR_04": 0,
"INVERNADERO_01_EXTRACTOR": 0,
"INVERNADERO_02_EXTRACTOR": 1,
"INVERNADERO_03_EXTRACTOR": 0,
"RESERVA": 0,
"greenhouseId": "001"
}
Configuration
Simulation is configured in application.yaml:
greenhouse:
simulation:
enabled: true # Enable/disable simulation
greenhouse-id: "001" # Default greenhouse ID
interval: 5000 # Milliseconds between readings
Set greenhouse.simulation.enabled: false in production to ensure real sensor data is used.
Simulated Data Characteristics
The simulation generates realistic data:
- Temperature: Gradual changes (±0.5°C per cycle) within 15-30°C range
- Humidity: Gradual changes (±1% per cycle) within 40-80% range
- Sectors: Random binary states (0=OFF, 1=ON)
- Extractors: Random binary states with lower ON probability
Simulated values use smooth transitions rather than random jumps to mimic real sensor behavior.
Use Cases
- Development: Test without physical greenhouse hardware
- Integration Testing: Verify MQTT → Redis → TimescaleDB → WebSocket pipeline
- Load Testing: Generate predictable data patterns for performance testing
- Demonstrations: Show the system working without sensor dependencies