Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Added exception to log in AgentService Added few attributes to ElectricityStorageAsset Changed attribute types of WeatherAsset

Michael Rademakere62845bf9a07
diff --git a/manager/src/main/java/org/openremote/manager/agent/AgentService.java b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
index 49abd4eda..3e1f28703 100644
--- a/manager/src/main/java/org/openremote/manager/agent/AgentService.java
+++ b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
@@ -442,7 +442,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Asse
} catch (Exception e) {
protocolInstanceMap.remove(agent.getId());
- LOG.log(Level.SEVERE, "Failed to start protocol instance for agent: " + agent);
+ LOG.log(Level.SEVERE, "Failed to start protocol instance for agent: " + agent, e);
sendAttributeEvent(new AttributeEvent(agent.getId(), Agent.STATUS.getName(), ConnectionStatus.ERROR));
}
});
diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java
index 05987d538..d8e38f017 100644
--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricityStorageAsset.java
@@ -71,6 +71,14 @@ public class ElectricityStorageAsset extends Asset<ElectricityStorageAsset> {
new MetaItem<>(MetaItemType.READ_ONLY)
);
+ public static final AttributeDescriptor<Integer> CHARGE_EFFICIENCY = new AttributeDescriptor<>("chargeEfficiency", ValueType.POSITIVE_INTEGER)
+ .withUnits(UNITS_PERCENTAGE).withConstraints(new ValueConstraint.Min(0), new ValueConstraint.Max(100));
+
+ public static final AttributeDescriptor<Double> FINANCIAL_WALLET = new AttributeDescriptor<>("financialWallet", ValueType.POSITIVE_NUMBER).withUnits("EUR");
+ public static final AttributeDescriptor<Integer> CARBON_WALLET = new AttributeDescriptor<>("carbonWallet", ValueType.POSITIVE_INTEGER,
+ new MetaItem<>(MetaItemType.READ_ONLY)
+ ).withUnits(UNITS_KILO, UNITS_GRAM);
+
public static final AssetDescriptor<ElectricityStorageAsset> DESCRIPTOR = new AssetDescriptor<>("battery-charging", "1B7C89", ElectricityStorageAsset.class);
/**
@@ -139,4 +147,46 @@ public class ElectricityStorageAsset extends Asset<ElectricityStorageAsset> {
public Optional<Integer> getChargeCycles() {
return getAttributes().getValue(CHARGE_CYCLES);
}
+
+ public Optional<Double> getFinancialWallet() {
+ return getAttributes().getValue(FINANCIAL_WALLET);
+ }
+
+ public Optional<Integer> getCarbonWallet() {
+ return getAttributes().getValue(CARBON_WALLET);
+ }
+
+ public Optional<Integer> getChargeEfficiency() {
+ return getAttributes().getValue(CHARGE_EFFICIENCY);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends ElectricityStorageAsset> T setEnergyLevelPercentage(Integer value) {
+ getAttributes().getOrCreate(ENERGY_LEVEL_PERCENTAGE).setValue(value);
+ return (T)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends ElectricityStorageAsset> T setEnergyLevel(Double value) {
+ getAttributes().getOrCreate(ENERGY_LEVEL).setValue(value);
+ return (T)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends ElectricityStorageAsset> T setEnergyTotalImport(Double value) {
+ getAttributes().getOrCreate(ENERGY_TOTAL_IMPORT).setValue(value);
+ return (T)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends ElectricityStorageAsset> T setEnergyTotalExport(Double value) {
+ getAttributes().getOrCreate(ENERGY_TOTAL_EXPORT).setValue(value);
+ return (T)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends ElectricityStorageAsset> T setPowerTotal(Double value) {
+ getAttributes().getOrCreate(POWER_TOTAL).setValue(value);
+ return (T)this;
+ }
}
diff --git a/model/src/main/java/org/openremote/model/asset/impl/WeatherAsset.java b/model/src/main/java/org/openremote/model/asset/impl/WeatherAsset.java
index 3a9434b9f..5e6e9125a 100644
--- a/model/src/main/java/org/openremote/model/asset/impl/WeatherAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/impl/WeatherAsset.java
@@ -38,20 +38,20 @@ public class WeatherAsset extends Asset<WeatherAsset> {
public static final AttributeDescriptor<Double> TEMPERATURE = new AttributeDescriptor<>("temperature", ValueType.NUMBER,
new MetaItem<>(MetaItemType.READ_ONLY)
).withUnits(UNITS_CELSIUS);
- public static final AttributeDescriptor<Integer> UV_INDEX = new AttributeDescriptor<>("uVIndex", ValueType.POSITIVE_INTEGER,
+ public static final AttributeDescriptor<Double> UV_INDEX = new AttributeDescriptor<>("uVIndex", ValueType.POSITIVE_NUMBER,
new MetaItem<>(MetaItemType.LABEL, "UV index"),
new MetaItem<>(MetaItemType.READ_ONLY)
);
public static final AttributeDescriptor<Double> SUN_IRRADIANCE = new AttributeDescriptor<>("sunIrradiance", ValueType.POSITIVE_NUMBER,
new MetaItem<>(MetaItemType.READ_ONLY)
);
- public static final AttributeDescriptor<Integer> SUN_AZIMUTH = new AttributeDescriptor<>("sunAzimuth", ValueType.POSITIVE_INTEGER,
+ public static final AttributeDescriptor<Double> SUN_AZIMUTH = new AttributeDescriptor<>("sunAzimuth", ValueType.POSITIVE_NUMBER,
new MetaItem<>(MetaItemType.READ_ONLY)
);
- public static final AttributeDescriptor<Integer> SUN_ZENITH = new AttributeDescriptor<>("sunZenith", ValueType.POSITIVE_INTEGER,
+ public static final AttributeDescriptor<Double> SUN_ZENITH = new AttributeDescriptor<>("sunZenith", ValueType.POSITIVE_NUMBER,
new MetaItem<>(MetaItemType.READ_ONLY)
);
- public static final AttributeDescriptor<Integer> SUN_ALTITUDE = new AttributeDescriptor<>("sunAltitude", ValueType.POSITIVE_INTEGER,
+ public static final AttributeDescriptor<Double> SUN_ALTITUDE = new AttributeDescriptor<>("sunAltitude", ValueType.POSITIVE_NUMBER,
new MetaItem<>(MetaItemType.READ_ONLY)
);
public static final AttributeDescriptor<Double> WIND_SPEED = new AttributeDescriptor<>("windSpeed", ValueType.POSITIVE_NUMBER,
@@ -84,7 +84,7 @@ public class WeatherAsset extends Asset<WeatherAsset> {
return getAttributes().getValue(TEMPERATURE);
}
- public Optional<Integer> getUVIndex() {
+ public Optional<Double> getUVIndex() {
return getAttributes().getValue(UV_INDEX);
}
@@ -92,15 +92,15 @@ public class WeatherAsset extends Asset<WeatherAsset> {
return getAttributes().getValue(SUN_IRRADIANCE);
}
- public Optional<Integer> getSunAzimuth() {
+ public Optional<Double> getSunAzimuth() {
return getAttributes().getValue(SUN_AZIMUTH);
}
- public Optional<Integer> getSunZenith() {
+ public Optional<Double> getSunZenith() {
return getAttributes().getValue(SUN_ZENITH);
}
- public Optional<Integer> getSunAltitude() {
+ public Optional<Double> getSunAltitude() {
return getAttributes().getValue(SUN_ALTITUDE);
}