100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fix for setting actual value of Solar or Wind producer
Michael Rademaker59ac770d0141
diff --git a/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.java b/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.javaindex f1b91a4dc..a724ecaa4 100644--- a/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.java+++ b/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.java@@ -191,7 +191,7 @@ public class ForecastSolarService extends RouteBuilder implements ContainerServi}}- if (attributeEvent.getAttributeName().equals(ElectricityProducerSolarAsset.SET_ACTUAL_VALUE_WITH_FORECAST.getName())) {+ if (attributeEvent.getAttributeName().equals(ElectricityProducerSolarAsset.SET_ACTUAL_SOLAR_VALUE_WITH_FORECAST.getName())) {// Get latest asset from storageElectricityProducerSolarAsset asset = (ElectricityProducerSolarAsset) assetStorageService.find(attributeEvent.getAssetId());@@ -247,7 +247,7 @@ public class ForecastSolarService extends RouteBuilder implements ContainerServi// Forecast date time is ISO8601 without 'T' so needs special formatterLocalDateTime now = LocalDateTime.ofInstant(Instant.ofEpochMilli(timerService.getCurrentTimeMillis()), ZoneId.systemDefault());LocalDateTime previousTimestamp = null;- boolean setActualValuePower = electricityProducerSolarAsset.isSetActualValueWithForecast().orElse(false);+ boolean setActualValuePower = electricityProducerSolarAsset.isSetActualSolarValueWithForecast().orElse(false);boolean setActualValueForecastPower = true;for (Map.Entry<String, Double> wattItem : responseModel.result.watts.entrySet()) {diff --git a/manager/src/main/java/org/openremote/manager/energy/ForecastWindService.java b/manager/src/main/java/org/openremote/manager/energy/ForecastWindService.javaindex 23eca168c..56bb77c7c 100644--- a/manager/src/main/java/org/openremote/manager/energy/ForecastWindService.java+++ b/manager/src/main/java/org/openremote/manager/energy/ForecastWindService.java@@ -15,7 +15,6 @@ import org.openremote.manager.rules.RulesService;import org.openremote.model.Container;import org.openremote.model.ContainerService;import org.openremote.model.asset.impl.ElectricityProducerAsset;-import org.openremote.model.asset.impl.ElectricityProducerSolarAsset;import org.openremote.model.asset.impl.ElectricityProducerWindAsset;import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.query.AssetQuery;@@ -230,7 +229,7 @@ public class ForecastWindService extends RouteBuilder implements ContainerServic}}- if (attributeEvent.getAttributeName().equals(ElectricityProducerSolarAsset.SET_ACTUAL_VALUE_WITH_FORECAST.getName())) {+ if (attributeEvent.getAttributeName().equals(ElectricityProducerWindAsset.SET_ACTUAL_WIND_VALUE_WITH_FORECAST.getName())) {// Get latest asset from storageElectricityProducerWindAsset asset = (ElectricityProducerWindAsset) assetStorageService.find(attributeEvent.getAssetId());@@ -284,7 +283,7 @@ public class ForecastWindService extends RouteBuilder implements ContainerServicassetProcessingService.sendAttributeEvent(new AttributeEvent(electricityProducerWindAsset.getId(), ElectricityProducerAsset.POWER_FORECAST.getName(), -currentPower));- if (electricityProducerWindAsset.isSetActualValueWithForecast().orElse(false)) {+ if (electricityProducerWindAsset.isSetActualWindValueWithForecast().orElse(false)) {assetProcessingService.sendAttributeEvent(new AttributeEvent(electricityProducerWindAsset.getId(), ElectricityProducerAsset.POWER.getName(), -currentPower));}diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerSolarAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerSolarAsset.javaindex f613d4f89..f3d7d0f6b 100644--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerSolarAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerSolarAsset.java@@ -54,7 +54,7 @@ public class ElectricityProducerSolarAsset extends ElectricityProducerAsset {public static final AttributeDescriptor<Boolean> INCLUDE_FORECAST_SOLAR_SERVICE = new AttributeDescriptor<>("includeForecastSolarService", BOOLEAN);- public static final AttributeDescriptor<Boolean> SET_ACTUAL_VALUE_WITH_FORECAST = new AttributeDescriptor<>("setActualValueWithForecast", BOOLEAN);+ public static final AttributeDescriptor<Boolean> SET_ACTUAL_SOLAR_VALUE_WITH_FORECAST = new AttributeDescriptor<>("setActualSolarValueWithForecast", BOOLEAN);public static final AssetDescriptor<ElectricityProducerSolarAsset> DESCRIPTOR = new AssetDescriptor<>("white-balance-sunny", "EABB4D", ElectricityProducerSolarAsset.class);@@ -76,8 +76,8 @@ public class ElectricityProducerSolarAsset extends ElectricityProducerAsset {return getAttribute(INCLUDE_FORECAST_SOLAR_SERVICE).flatMap(AbstractNameValueHolder::getValue);}- public Optional<Boolean> isSetActualValueWithForecast() {- return getAttribute(SET_ACTUAL_VALUE_WITH_FORECAST).flatMap(AbstractNameValueHolder::getValue);+ public Optional<Boolean> isSetActualSolarValueWithForecast() {+ return getAttribute(SET_ACTUAL_SOLAR_VALUE_WITH_FORECAST).flatMap(AbstractNameValueHolder::getValue);}public ElectricityProducerSolarAsset setPanelOrientation(PanelOrientation value) {@@ -108,8 +108,8 @@ public class ElectricityProducerSolarAsset extends ElectricityProducerAsset {return this;}- public ElectricityProducerSolarAsset setSetActualValueWithForecast(boolean value) {- getAttributes().getOrCreate(SET_ACTUAL_VALUE_WITH_FORECAST).setValue(value);+ public ElectricityProducerSolarAsset setSetActualSolarValueWithForecast(boolean value) {+ getAttributes().getOrCreate(SET_ACTUAL_SOLAR_VALUE_WITH_FORECAST).setValue(value);return this;}diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.javaindex 92001b17d..2f078440b 100644--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.java@@ -47,7 +47,7 @@ public class ElectricityProducerWindAsset extends ElectricityProducerAsset {public static final AttributeDescriptor<Boolean> INCLUDE_FORECAST_WIND_SERVICE = new AttributeDescriptor<>("includeForecastWindService", BOOLEAN);- public static final AttributeDescriptor<Boolean> SET_ACTUAL_VALUE_WITH_FORECAST = new AttributeDescriptor<>("setActualValueWithForecast", BOOLEAN);+ public static final AttributeDescriptor<Boolean> SET_ACTUAL_WIND_VALUE_WITH_FORECAST = new AttributeDescriptor<>("setWindActualValueWithForecast", BOOLEAN);public static final AssetDescriptor<ElectricityProducerWindAsset> DESCRIPTOR = new AssetDescriptor<>("wind-turbine", "4B87EA", ElectricityProducerWindAsset.class);@@ -77,8 +77,8 @@ public class ElectricityProducerWindAsset extends ElectricityProducerAsset {return getAttribute(INCLUDE_FORECAST_WIND_SERVICE).flatMap(AbstractNameValueHolder::getValue);}- public Optional<Boolean> isSetActualValueWithForecast() {- return getAttribute(SET_ACTUAL_VALUE_WITH_FORECAST).flatMap(AbstractNameValueHolder::getValue);+ public Optional<Boolean> isSetActualWindValueWithForecast() {+ return getAttribute(SET_ACTUAL_WIND_VALUE_WITH_FORECAST).flatMap(AbstractNameValueHolder::getValue);}@Override@@ -263,8 +263,8 @@ public class ElectricityProducerWindAsset extends ElectricityProducerAsset {return this;}- public ElectricityProducerWindAsset setSetActualValueWithForecast(boolean value) {- getAttributes().getOrCreate(SET_ACTUAL_VALUE_WITH_FORECAST).setValue(value);+ public ElectricityProducerWindAsset setSetActualWindValueWithForecast(boolean value) {+ getAttributes().getOrCreate(SET_ACTUAL_WIND_VALUE_WITH_FORECAST).setValue(value);return this;}}diff --git a/test/src/main/java/org/openremote/test/setup/ManagerTestSetup.java b/test/src/main/java/org/openremote/test/setup/ManagerTestSetup.javaindex 0025faace..02aea7a66 100644--- a/test/src/main/java/org/openremote/test/setup/ManagerTestSetup.java+++ b/test/src/main/java/org/openremote/test/setup/ManagerTestSetup.java@@ -229,7 +229,7 @@ public class ManagerTestSetup extends ManagerSetup {electricitySolarAsset.setEfficiencyExport(100);electricitySolarAsset.setPowerExportMax(2.5);electricitySolarAsset.setLocation(new GeoJSONPoint(9.195285, 48.787418));- electricitySolarAsset.setSetActualValueWithForecast(true);+ electricitySolarAsset.setSetActualSolarValueWithForecast(true);electricitySolarAsset.setIncludeForecastSolarService(true);electricitySolarAsset = assetStorageService.merge(electricitySolarAsset);electricitySolarAssetId = electricitySolarAsset.getId();@@ -246,7 +246,7 @@ public class ManagerTestSetup extends ManagerSetup {electricityWindAsset.setEfficiencyExport(100);electricityWindAsset.setPowerExportMax(2.5);electricityWindAsset.setLocation(new GeoJSONPoint(9.195285, 48.787418));- electricityWindAsset.setSetActualValueWithForecast(true);+ electricityWindAsset.setSetActualWindValueWithForecast(true);electricityWindAsset.setIncludeForecastWindService(true);electricityWindAsset = assetStorageService.merge(electricityWindAsset);electricityWindAssetId = electricityWindAsset.getId();diff --git a/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovy b/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovyindex 81b6d4971..0df79723a 100644--- a/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovy@@ -162,7 +162,7 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainernewSolarAsset.setEfficiencyExport(100);newSolarAsset.setPowerExportMax(2.5);newSolarAsset.setLocation(new GeoJSONPoint(9.195295, 48.787418));- newSolarAsset.setSetActualValueWithForecast(true);+ newSolarAsset.setSetActualSolarValueWithForecast(true);newSolarAsset.setIncludeForecastSolarService(true);newSolarAsset = assetStorageService.merge(newSolarAsset)@@ -185,7 +185,7 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainernewSolarAsset2.setEfficiencyExport(100);newSolarAsset2.setPowerExportMax(2.5);newSolarAsset2.setLocation(new GeoJSONPoint(9.195275, 48.787418));- newSolarAsset2.setSetActualValueWithForecast(false);+ newSolarAsset2.setSetActualSolarValueWithForecast(false);newSolarAsset2.setIncludeForecastSolarService(false);newSolarAsset2 = assetStorageService.merge(newSolarAsset2)@@ -208,7 +208,7 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainer}when: "an asset updated it's setActualValueWithForecast to true"- assetProcessingService.sendAttributeEvent(new AttributeEvent(newSolarAsset2.getId(), ElectricityProducerSolarAsset.SET_ACTUAL_VALUE_WITH_FORECAST.name, true))+ assetProcessingService.sendAttributeEvent(new AttributeEvent(newSolarAsset2.getId(), ElectricityProducerSolarAsset.SET_ACTUAL_SOLAR_VALUE_WITH_FORECAST.name, true))then: "it power should be updated too"conditions.eventually {diff --git a/test/src/test/groovy/org/openremote/test/energy/ForecastWindServiceTest.groovy b/test/src/test/groovy/org/openremote/test/energy/ForecastWindServiceTest.groovyindex f4ab25fa1..7c6f624cf 100644--- a/test/src/test/groovy/org/openremote/test/energy/ForecastWindServiceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/energy/ForecastWindServiceTest.groovy@@ -674,7 +674,7 @@ class ForecastWindServiceTest extends Specification implements ManagerContainerTnewWindAsset.setEfficiencyExport(100);newWindAsset.setPowerExportMax(2.5);newWindAsset.setLocation(new GeoJSONPoint(9.195295, 48.787418));- newWindAsset.setSetActualValueWithForecast(true);+ newWindAsset.setSetActualWindValueWithForecast(true);newWindAsset.setIncludeForecastWindService(true);newWindAsset = assetStorageService.merge(newWindAsset)@@ -698,7 +698,7 @@ class ForecastWindServiceTest extends Specification implements ManagerContainerTnewWindAsset2.setEfficiencyExport(100);newWindAsset2.setPowerExportMax(2.5);newWindAsset2.setLocation(new GeoJSONPoint(9.195275, 48.787418));- newWindAsset2.setSetActualValueWithForecast(false);+ newWindAsset2.setSetActualWindValueWithForecast(false);newWindAsset2.setIncludeForecastWindService(false);newWindAsset2 = assetStorageService.merge(newWindAsset2)@@ -721,7 +721,7 @@ class ForecastWindServiceTest extends Specification implements ManagerContainerT}when: "an asset updated it's setActualValueWithForecast to true"- assetProcessingService.sendAttributeEvent(new AttributeEvent(newWindAsset2.getId(), ElectricityProducerWindAsset.SET_ACTUAL_VALUE_WITH_FORECAST.name, true))+ assetProcessingService.sendAttributeEvent(new AttributeEvent(newWindAsset2.getId(), ElectricityProducerWindAsset.SET_ACTUAL_WIND_VALUE_WITH_FORECAST.name, true))then: "it power should be updated too"conditions.eventually {@@ -746,7 +746,7 @@ class ForecastWindServiceTest extends Specification implements ManagerContainerTnewWindAsset3.setWindSpeedReference(12d);newWindAsset3.setEfficiencyExport(100);newWindAsset3.setPowerExportMax(2.5);- newWindAsset3.setSetActualValueWithForecast(true);+ newWindAsset3.setSetActualWindValueWithForecast(true);newWindAsset3.setIncludeForecastWindService(true);newWindAsset3 = assetStorageService.merge(newWindAsset3)