Fixes historian service for accumulated vars
This commit is contained in:
@@ -178,7 +178,8 @@ public class HistorianService {
|
||||
|
||||
return normalized.contains("radiacao")
|
||||
|| normalized.contains("radiação")
|
||||
|| normalized.contains("radiation");
|
||||
|| normalized.contains("radiation")
|
||||
|| normalized.equals("climate.sensor_16");
|
||||
}
|
||||
|
||||
private double integrateWhPerSquareMeter(List<HistorianSample> samples) {
|
||||
@@ -197,7 +198,9 @@ public class HistorianService {
|
||||
double previousValue = previous.getNumericValue();
|
||||
double currentValue = current.getNumericValue();
|
||||
|
||||
double averageWm2 = (previousValue + currentValue) / 2.0;
|
||||
if (previousValue < 0 || currentValue < 0 || previousValue > 1400 || currentValue > 1400) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double elapsedHours =
|
||||
java.time.Duration.between(
|
||||
@@ -205,16 +208,16 @@ public class HistorianService {
|
||||
current.getSampledAt()
|
||||
).toMillis() / 1000.0 / 60.0 / 60.0;
|
||||
|
||||
if (elapsedHours <= 0) {
|
||||
if (elapsedHours <= 0 || elapsedHours > 0.25) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double averageWm2 = (previousValue + currentValue) / 2.0;
|
||||
total += averageWm2 * elapsedHours;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private Instant bucketStart(Instant instant, String bucket) {
|
||||
java.time.ZonedDateTime date = instant.atZone(java.time.ZoneId.of("Europe/Lisbon"));
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class MeteoModuleService {
|
||||
return name.contains("exterior")
|
||||
|| name.contains("vento")
|
||||
|| name.contains("radiacao")
|
||||
|| name.contains("co")
|
||||
|| name.contains("chuva");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user