add Voltage and Power fields
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user