add Voltage and Power fields

This commit is contained in:
2026-01-06 18:43:23 +03:30
parent f75d85dbb7
commit 9334e3e4c2
9 changed files with 2548 additions and 23 deletions

View File

@@ -25,22 +25,11 @@ public class TelemetryController : ControllerBase
}
[HttpGet("AddData")]
public async Task<ActionResult<int>> Create(int deviceId, decimal temperatureC, decimal humidityPercent,
decimal soilPercent, int gasPPM, decimal lux, CancellationToken cancellationToken)
public async Task<ActionResult<int>> Create([FromQuery] TelemetryDto telementry, CancellationToken cancellationToken)
{
TelemetryDto dto = new TelemetryDto
{
//DeviceName = deviceName.ToString() == "dr110"? "dr110":"",
DeviceId = deviceId,
TemperatureC = temperatureC,
HumidityPercent = humidityPercent,
SoilPercent = soilPercent,
GasPPM = gasPPM,
Lux = lux,
TimestampUtc = DateTime.UtcNow
};
var id = await telemetryService.AddAsync(dto, cancellationToken);
telementry.TimestampUtc = DateTime.UtcNow;
var id = await telemetryService.AddAsync(telementry, cancellationToken);
// Check and send alerts if needed (fire and forget)
_ = Task.Run(async () =>
@@ -48,10 +37,10 @@ public class TelemetryController : ControllerBase
try
{
// Get deviceId from the saved telemetry record
var deviceId = dto.DeviceId;
var deviceId = telementry.DeviceId;
if (deviceId > 0)
{
await alertService.CheckAndSendAlertsAsync(deviceId, dto, cancellationToken);
await alertService.CheckAndSendAlertsAsync(deviceId, telementry, cancellationToken);
}
}
catch