Skip to content

armgit / core

Public Imported from GitHub
0

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

UI updates: Various bug fixes (fixes #201, fixes #210, fixes #211)

Rich Turnera3b03f712d33
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
index 035ffe70f..0cacdbef2 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
@@ -29,7 +29,7 @@ import org.openremote.model.value.Values;
import java.util.*;
import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
-import static org.openremote.model.Constants.UNITS_TEMPERATURE_CELCIUS;
+import static org.openremote.model.Constants.UNITS_TEMPERATURE_CELSIUS;
import static org.openremote.model.Constants.UNITS_TIME_MINUTES;
public class ThermostatProcessor extends FeatureProcessor {
@@ -153,15 +153,15 @@ public class ThermostatProcessor extends FeatureProcessor {
new PropertyDescriptor("heatDayMins", "Heat Day (mins)", "TEMP_MODE_HEAT_DAY_MINS", AttributeValueType.DURATION.withUnitType(UNITS_TIME_MINUTES)),
new PropertyDescriptor("heatNightMins", "Heat Night (mins)", "TEMP_MODE_HEAT_NIGHT_MINS", AttributeValueType.DURATION.withUnitType(UNITS_TIME_MINUTES)),
new PropertyDescriptor("heatSafeMins", "Heat Safe (mins)", "TEMP_MODE_HEAT_SAFE_MINS", AttributeValueType.DURATION.withUnitType(UNITS_TIME_MINUTES)),
- new PropertyDescriptor("tempTargetCurrent", "Temp Target Current", "TEMP_TARGET_CURRENT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetCoolComfort", "Temp Target Cool Comfort", "TEMP_TARGET_COOL_COMFORT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetCoolDay", "Temp Target Cool Day", "TEMP_TARGET_COOL_DAY", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetCoolNight", "Temp Target Cool Night", "TEMP_TARGET_COOL_NIGHT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetCoolSafe", "Temp Target Cool Safe", "TEMP_TARGET_COOL_SAFE", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetHeatComfort", "Temp Target Heat Comfort", "TEMP_TARGET_HEAT_COMFORT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetHeatDay", "Temp Target Heat Day", "TEMP_TARGET_HEAT_DAY", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetHeatNight", "Temp Target Heat Night", "TEMP_TARGET_HEAT_NIGHT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS)),
- new PropertyDescriptor("tempTargetHeatSafe", "Temp Target Heat Safe", "TEMP_TARGET_HEAT_SAFE", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELCIUS))
+ new PropertyDescriptor("tempTargetCurrent", "Temp Target Current", "TEMP_TARGET_CURRENT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetCoolComfort", "Temp Target Cool Comfort", "TEMP_TARGET_COOL_COMFORT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetCoolDay", "Temp Target Cool Day", "TEMP_TARGET_COOL_DAY", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetCoolNight", "Temp Target Cool Night", "TEMP_TARGET_COOL_NIGHT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetCoolSafe", "Temp Target Cool Safe", "TEMP_TARGET_COOL_SAFE", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetHeatComfort", "Temp Target Heat Comfort", "TEMP_TARGET_HEAT_COMFORT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetHeatDay", "Temp Target Heat Day", "TEMP_TARGET_HEAT_DAY", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetHeatNight", "Temp Target Heat Night", "TEMP_TARGET_HEAT_NIGHT", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS)),
+ new PropertyDescriptor("tempTargetHeatSafe", "Temp Target Heat Safe", "TEMP_TARGET_HEAT_SAFE", AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS))
);
@Override
diff --git a/agent/src/main/java/org/openremote/agent/protocol/zwave/TypeMapper.java b/agent/src/main/java/org/openremote/agent/protocol/zwave/TypeMapper.java
index b0a2d0bfa..58dfed771 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/zwave/TypeMapper.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/zwave/TypeMapper.java
@@ -26,13 +26,12 @@ import org.openremote.model.attribute.MetaItem;
import org.openremote.model.attribute.MetaItemType;
import org.openremote.protocol.zwave.model.commandclasses.channel.ChannelType;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.logging.Logger;
+import static org.openremote.model.Constants.UNITS_TEMPERATURE_CELSIUS;
+import static org.openremote.model.Constants.UNITS_TEMPERATURE_FAHRENHEIT;
+
public class TypeMapper {
private static final Logger LOG = Logger.getLogger(TypeMapper.class.getName());
@@ -53,8 +52,8 @@ public class TypeMapper {
// COMMAND_CLASS_SENSOR_MULTILEVEL
- typeMap.put(ChannelType.TEMPERATURE_CELSIUS, AttributeValueType.TEMPERATURE);
- typeMap.put(ChannelType.TEMPERATURE_FAHRENHEIT, AttributeValueType.TEMPERATURE);
+ typeMap.put(ChannelType.TEMPERATURE_CELSIUS, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS));
+ typeMap.put(ChannelType.TEMPERATURE_FAHRENHEIT, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_FAHRENHEIT));
typeMap.put(ChannelType.PERCENTAGE, AttributeValueType.PERCENTAGE);
typeMap.put(ChannelType.LUMINANCE_PERCENTAGE, AttributeValueType.PERCENTAGE);
typeMap.put(ChannelType.LUMINANCE_LUX, AttributeValueType.BRIGHTNESS);
@@ -68,8 +67,8 @@ public class TypeMapper {
typeMap.put(ChannelType.PRESSURE_KPA, AttributeValueType.NUMBER);
typeMap.put(ChannelType.PRESSURE_IN_HG, AttributeValueType.NUMBER);
typeMap.put(ChannelType.SOLAR_RADIATION_WATT_M2, AttributeValueType.NUMBER);
- typeMap.put(ChannelType.DEW_POINT_CELSIUS, AttributeValueType.TEMPERATURE);
- typeMap.put(ChannelType.DEW_POINT_FAHRENHEIT, AttributeValueType.TEMPERATURE);
+ typeMap.put(ChannelType.DEW_POINT_CELSIUS, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS));
+ typeMap.put(ChannelType.DEW_POINT_FAHRENHEIT, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_FAHRENHEIT));
typeMap.put(ChannelType.RAINFALL_MMPH, AttributeValueType.RAINFALL);
typeMap.put(ChannelType.RAINFALL_INPH, AttributeValueType.NUMBER);
typeMap.put(ChannelType.TIDE_LEVEL_M, AttributeValueType.DISTANCE);
@@ -94,10 +93,10 @@ public class TypeMapper {
typeMap.put(ChannelType.ANGLE_POSITION_DEGREE_SOUTH_POLE, AttributeValueType.DIRECTION);
typeMap.put(ChannelType.ROTATION_HZ, AttributeValueType.NUMBER);
typeMap.put(ChannelType.ROTATION_RPM, AttributeValueType.NUMBER);
- typeMap.put(ChannelType.WATER_TEMPERATURE_CELSIUS, AttributeValueType.TEMPERATURE);
- typeMap.put(ChannelType.WATER_TEMPERATURE_FAHRENHEIT, AttributeValueType.TEMPERATURE);
- typeMap.put(ChannelType.SOIL_TEMPERATURE_CELSIUS, AttributeValueType.TEMPERATURE);
- typeMap.put(ChannelType.SOIL_TEMPERATURE_FAHRENHEIT, AttributeValueType.TEMPERATURE);
+ typeMap.put(ChannelType.WATER_TEMPERATURE_CELSIUS, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS));
+ typeMap.put(ChannelType.WATER_TEMPERATURE_FAHRENHEIT, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_FAHRENHEIT));
+ typeMap.put(ChannelType.SOIL_TEMPERATURE_CELSIUS, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS));
+ typeMap.put(ChannelType.SOIL_TEMPERATURE_FAHRENHEIT, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_FAHRENHEIT));
typeMap.put(ChannelType.SEISMIC_INTENSITY_MERCALLI, AttributeValueType.NUMBER);
typeMap.put(ChannelType.SEISMIC_INTENSITY_EU_MACROSEISMIC, AttributeValueType.NUMBER);
typeMap.put(ChannelType.SEISMIC_INTENSITY_LIEDU, AttributeValueType.NUMBER);
@@ -118,8 +117,8 @@ public class TypeMapper {
typeMap.put(ChannelType.FREQUENCY_HZ, AttributeValueType.NUMBER);
typeMap.put(ChannelType.FREQUENCY_KHZ, AttributeValueType.NUMBER);
typeMap.put(ChannelType.TIME_SECONDS, AttributeValueType.TIMESTAMP);
- typeMap.put(ChannelType.TARGET_TEMPERATUE_CELSIUS, AttributeValueType.TEMPERATURE);
- typeMap.put(ChannelType.TARGET_TEMPERATUE_FAHRENHEIT, AttributeValueType.TEMPERATURE);
+ typeMap.put(ChannelType.TARGET_TEMPERATUE_CELSIUS, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_CELSIUS));
+ typeMap.put(ChannelType.TARGET_TEMPERATUE_FAHRENHEIT, AttributeValueType.TEMPERATURE.withUnitType(UNITS_TEMPERATURE_FAHRENHEIT));
typeMap.put(ChannelType.PARTICULATE_MATTER_2_5_MOLPCM, AttributeValueType.NUMBER);
typeMap.put(ChannelType.PARTICULATE_MATTER_2_5_MCGPCM, AttributeValueType.NUMBER);
typeMap.put(ChannelType.FORMALDEHYDE_LEVEL_MOLPCM, AttributeValueType.NUMBER);
@@ -226,7 +225,7 @@ public class TypeMapper {
ChannelType.TEMPERATURE_CELSIUS,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELCIUS)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f C"))
}
)
@@ -275,7 +274,7 @@ public class TypeMapper {
ChannelType.SPEED_MS,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_SPEED_MPS)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_SPEED_METRES_SECOND)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.3f m/s"))
}
)
@@ -293,7 +292,7 @@ public class TypeMapper {
ChannelType.DIRECTION_DECIMAL_DEGREES,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_DIRECTION_DEGREES)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_ANGLE_DEGREES)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f deg"))
}
)
@@ -305,7 +304,7 @@ public class TypeMapper {
ChannelType.DEW_POINT_CELSIUS,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELCIUS)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f C"))
}
)
@@ -314,7 +313,7 @@ public class TypeMapper {
ChannelType.DEW_POINT_FAHRENHEIT,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue("FAHRENHEIT")),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_FAHRENHEIT)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f F"))
}
)
@@ -399,7 +398,7 @@ public class TypeMapper {
ChannelType.ANGLE_POSITION_DEGREE_NORTH_POLE,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_DIRECTION_DEGREES)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_ANGLE_DEGREES)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f deg"))
}
)
@@ -408,7 +407,7 @@ public class TypeMapper {
ChannelType.ANGLE_POSITION_DEGREE_SOUTH_POLE,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_DIRECTION_DEGREES)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_ANGLE_DEGREES)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f deg"))
}
)
@@ -419,7 +418,7 @@ public class TypeMapper {
ChannelType.WATER_TEMPERATURE_CELSIUS,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELCIUS)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f C"))
}
)
@@ -428,7 +427,7 @@ public class TypeMapper {
ChannelType.WATER_TEMPERATURE_FAHRENHEIT,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue("FAHRENHEIT")),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_FAHRENHEIT)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f F"))
}
)
@@ -437,7 +436,7 @@ public class TypeMapper {
ChannelType.SOIL_TEMPERATURE_CELSIUS,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELCIUS)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f C"))
}
)
@@ -446,7 +445,7 @@ public class TypeMapper {
ChannelType.SOIL_TEMPERATURE_FAHRENHEIT,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue("FAHRENHEIT")),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_FAHRENHEIT)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f F"))
}
)
@@ -499,7 +498,7 @@ public class TypeMapper {
ChannelType.TARGET_TEMPERATUE_CELSIUS,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELCIUS)),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f C"))
}
)
@@ -508,7 +507,7 @@ public class TypeMapper {
ChannelType.TARGET_TEMPERATUE_FAHRENHEIT,
Arrays.asList(
new MetaItem[] {
- new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue("FAHRENHEIT")),
+ new MetaItem(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_FAHRENHEIT)),
new MetaItem(MetaItemType.FORMAT.withInitialValue("%0.1f F"))
}
)
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index 478eeaf6a..acec64c15 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -232,27 +232,46 @@
"submit": "Submit",
"password": "Password",
"units": {
+ "CELSIUS": "°C",
+ "FAHRENHEIT": "°F",
+ "HOURS": "hr",
+ "MINUTES": "min",
+ "SECONDS": "s",
+ "MILLISECONDS": "ms",
+ "SPEED_KNOTS": "kn",
+ "SPEED_KMPH": "km/h",
+ "SPEED_MIPH": "mi/h",
+ "SPEED_MPS": "m/s",
+ "DECIBELS": "dB",
+ "DISTANCE_KM": "km",
+ "DISTANCE_MI": "mi",
+ "DISTANCE_M": "m",
+ "DISTANCE_CM": "cm",
+ "DISTANCE_MM": "mm",
+ "FLOW_LPM": "L/m",
+ "EUR_PER_KWH": "€/kWh",
+ "EUR_PER_MONTH": "€/month",
+ "GBP_PER_KWH": "£/kWh",
+ "GBP_PER_MONTH": "£/month",
"EUR": "€",
"GBP": "£",
- "KILOWATT": "kW",
- "KILOWATT_PEAK": "kWp",
- "KILOWATT_PER_HOUR": "kWh",
- "MILLIMETER_PER_SQUARE_METER": "mm/m²",
- "MILLIS": "ms",
- "SECONDS": "s",
- "MINUTES": "min",
- "KILOGRAM_CARBON_PER_KILOWATT_HOUR": "kg CO₂/kWh",
- "KILOGRAM": "kg",
- "CELSIUS": "°C",
- "KILOMETERS_PER_HOUR": "km/h",
- "METERS_PER_HOUR": "m/h",
- "DEGREES": "°",
+ "POWER_KW": "kW",
+ "POWER_W": "W",
+ "POWER_KWP": "kWp",
+ "POWER_PER_SQUARE_M": "W/m²",
+ "ENERGY_KWH": "kWh",
+ "KG_CARBON_PER_KWH": "kg CO₂/kWh",
+ "MASS_KG": "kg",
+ "ANGLE_DEGREES": "°",
+ "ANGLE_RADIANS": "rad",
"PERCENTAGE": "%",
- "METERS_PER_SECOND": "m/s",
- "EUR_PER_KILOWATT_HOUR": "€/kWh",
- "EUR_PER_MONTH": "€/month",
- "GBP_PER_KILOWATT_HOUR": "£/kWh",
- "GBP_PER_MONTH": "£/month"
+ "DENSITY_KG_M3": "kg/m³",
+ "DENSITY_UG_M3": "µg/m³",
+ "ON_OFF": "On/Off",
+ "PRESSED_RELEASED": "Pressed/Released",
+ "COUNT_PER_HOUR": "/h",
+ "COUNT_PER_MINUTE": "/min",
+ "COUNT_PER_SECOND": "/s"
},
"noChildAssets": "No child assets",
"account": "Account",
diff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
index 8162389c2..1aea78e0a 100644
--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
@@ -48,6 +48,8 @@ import java.util.function.Supplier;
import static org.openremote.agent.protocol.macro.MacroProtocol.META_MACRO_ACTION_INDEX;
import static org.openremote.agent.protocol.timer.TimerConfiguration.initTimerConfiguration;
import static org.openremote.agent.protocol.timer.TimerProtocol.META_TIMER_VALUE_LINK;
+import static org.openremote.model.Constants.UNITS_DENSITY_MICROGRAMS_CUBIC_M;
+import static org.openremote.model.Constants.UNITS_TEMPERATURE_CELSIUS;
import static org.openremote.model.attribute.MetaItemType.*;
import static org.openremote.model.asset.AssetType.*;
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
@@ -224,7 +226,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
new MetaItem(READ_ONLY, Values.create(true)),
new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),
- new MetaItem(UNIT_TYPE, Values.create("CELSIUS")),
+ new MetaItem(UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(FORMAT, Values.create("%0.1f° C")),
new MetaItem(STORE_DATA_POINTS)
).addMeta(shouldBeLinked ? agentLinker.get() : null)
@@ -242,7 +244,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),
new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),
- new MetaItem(UNIT_TYPE, Values.create("CELSIUS")),
+ new MetaItem(UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELSIUS)),
new MetaItem(FORMAT, Values.create("%0f° C")),
new MetaItem(STORE_DATA_POINTS)
).addMeta(shouldBeLinked ? agentLinker.get() : null)
@@ -523,265 +525,160 @@ public abstract class AbstractManagerSetup implements Setup {
}
protected Asset createDemoPeopleCounterAsset(String name, Asset area, GeoJSON location, Supplier<MetaItem[]> agentLinker) {
- Asset peopleCounterAsset = new Asset(name, PEOPLE_COUNTER, area);
- peopleCounterAsset.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD),
- new AssetAttribute("peopleCountIn", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("People Count In")),
- new MetaItem(DESCRIPTION, Values.create("Cumulative number of people going into area")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("peopleCountOut", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("People Count Out")),
- new MetaItem(DESCRIPTION, Values.create("Cumulative number of people leaving area")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("peopleCountInMinute", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("People Count In Minute")),
- new MetaItem(DESCRIPTION, Values.create("Number of people going into area per minute")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("peopleCountOutMinute", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("People Count Out Minute")),
- new MetaItem(DESCRIPTION, Values.create("Number of people leaving area per minute")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("peopleCountTotal", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("People Count Total")),
- new MetaItem(DESCRIPTION, Values.create("cameraCountIn - cameraCountOut")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("peopleCountGrowth", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("People Count Growth")),
- new MetaItem(DESCRIPTION, Values.create("cameraCountIn - cameraCountOut")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- )
+ Asset peopleCounterAsset = new Asset(name, PEOPLE_COUNTER, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
);
+ peopleCounterAsset.getAttribute("peopleCountIn").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ peopleCounterAsset.getAttribute("peopleCountOut").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ peopleCounterAsset.getAttribute("peopleCountInMinute").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ peopleCounterAsset.getAttribute("peopleCountOutMinute").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ peopleCounterAsset.getAttribute("peopleCountTotal").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ peopleCounterAsset.getAttribute("peopleCountGrowth").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
return peopleCounterAsset;
}
protected Asset createDemoMicrophoneAsset(String name, Asset area, GeoJSON location, Supplier<MetaItem[]> agentLinker) {
- Asset microphoneAsset = new Asset(name, MICROPHONE, area);
- microphoneAsset.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD),
- new AssetAttribute("microphoneLevel", SOUND)
- .setMeta(
- new MetaItem(LABEL, Values.create("Microphone Level")),
- new MetaItem(DESCRIPTION, Values.create("dB")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get())
+ Asset microphoneAsset = new Asset(name, MICROPHONE, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
);
+ microphoneAsset.getAttribute("microphoneLevel").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+
return microphoneAsset;
}
protected Asset createDemoSoundEventAsset(String name, Asset area, GeoJSON location, Supplier<MetaItem[]> agentLinker) {
- Asset soundEventAsset = new Asset(name, SOUND_EVENT, area);
- soundEventAsset.setAttributes(
- new AssetAttribute("lastAgression", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last Aggression event")),
- new MetaItem(DESCRIPTION, Values.create("Input from microphone")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("lastGunshot", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last Gunshot event")),
- new MetaItem(DESCRIPTION, Values.create("Input from microphone")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("lastBreakingGlass", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last Breaking Glass event")),
- new MetaItem(DESCRIPTION, Values.create("Input from microphone")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("lastIntensity", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last Intensity event")),
- new MetaItem(DESCRIPTION, Values.create("Input from microphone")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("lastEvent", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last event")),
- new MetaItem(DESCRIPTION, Values.create("Input from microphone")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- )
+ Asset soundEventAsset = new Asset(name, SOUND_EVENT, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
);
+ soundEventAsset.getAttribute("lastAggressionEvent").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ soundEventAsset.getAttribute("lastGunshotEvent").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ soundEventAsset.getAttribute("lastBreakingGlassEvent").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ soundEventAsset.getAttribute("lastIntensityEvent").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ soundEventAsset.getAttribute("lastEvent").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+
return soundEventAsset;
}
protected Asset createDemoEnvironmentAsset(String name, Asset area, GeoJSON location, Supplier<MetaItem[]> agentLinker) {
- Asset environmentAsset = new Asset(name, ENVIRONMENT_SENSOR, area);
- environmentAsset.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD),
- new AssetAttribute("temperature", TEMPERATURE)
- .setMeta(
- new MetaItem(LABEL, Values.create("Temperature Level")),
- new MetaItem(DESCRIPTION, Values.create("oC")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(UNIT_TYPE, Values.create("CELSIUS")),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("nO2", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("Nitrogen Level")),
- new MetaItem(DESCRIPTION, Values.create("µg/m3")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("relHumidity", PERCENTAGE)
- .setMeta(
- new MetaItem(LABEL, Values.create("Humidity")),
- new MetaItem(DESCRIPTION, Values.create("Humidity in area")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("ozone", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("Ozone Level")),
- new MetaItem(DESCRIPTION, Values.create("µg/m3")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("particlesPM1", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("Particles PM 1")),
- new MetaItem(DESCRIPTION, Values.create("Particles PM 1")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("particlesPM2_5", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("Particles PM 2.5")),
- new MetaItem(DESCRIPTION, Values.create("Particles PM 2.5")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get()),
- new AssetAttribute("particlesPM10", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("Particles PM 10")),
- new MetaItem(DESCRIPTION, Values.create("Particles PM 10")),
- new MetaItem(READ_ONLY, Values.create(true)),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ).addMeta(agentLinker.get())
+ Asset environmentAsset = new Asset(name, ENVIRONMENT_SENSOR, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
);
+ environmentAsset.getAttribute("temperature").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
+ environmentAsset.getAttribute("nO2").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
+ environmentAsset.getAttribute("relHumidity").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
+ environmentAsset.getAttribute("ozone").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
+ environmentAsset.getAttribute("particlesPM1").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
+ environmentAsset.getAttribute("particlesPM2_5").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
+ environmentAsset.getAttribute("particlesPM10").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ).addMeta(agentLinker.get()));
return environmentAsset;
}
protected Asset createDemoLightAsset(String name, Asset area, GeoJSON location) {
- Asset lightAsset = new Asset(name, LIGHT, area);
- lightAsset.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD),
- new AssetAttribute("lightStatus", BOOLEAN)
- .setMeta(
- new MetaItem(LABEL, Values.create("Light Status")),
- new MetaItem(DESCRIPTION, Values.create("On or off")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("lightDimLevel", PERCENTAGE)
- .setMeta(
- new MetaItem(LABEL, Values.create("Light Dim Level")),
- new MetaItem(DESCRIPTION, Values.create("The level of dimming of the light")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("colorRGBW", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Color RGBW")),
- new MetaItem(DESCRIPTION, Values.create("The RGBW color of the light")),
- new MetaItem(RULE_STATE),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("groupNumber", NUMBER)
- .setMeta(
- new MetaItem(LABEL, Values.create("Group number")),
- new MetaItem(DESCRIPTION, Values.create("Which group this lights belongs to")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("scenario", STRING)
- .setMeta(
- new MetaItem(LABEL, Values.create("Scenario")),
- new MetaItem(DESCRIPTION, Values.create("The scenario this light is setup to"))
- )
+ Asset lightAsset = new Asset(name, LIGHT, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue())
+ .addMeta(SHOW_ON_DASHBOARD)
);
+ lightAsset.getAttribute("lightStatus").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("lightDimLevel").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("colorRGBW").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("groupNumber").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("scenario").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE)
+ ));
return lightAsset;
}
protected Asset createDemoLightControllerAsset(String name, Asset area, GeoJSON location) {
- Asset lightAsset = new Asset(name, LIGHT_CONTROLLER, area);
- lightAsset.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, location.toValue()),
- new AssetAttribute("lightAllStatus", BOOLEAN)
- .setMeta(
- new MetaItem(LABEL, Values.create("Light Status")),
- new MetaItem(DESCRIPTION, Values.create("On or off")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("lightAllDimLevel", PERCENTAGE)
- .setMeta(
- new MetaItem(LABEL, Values.create("Light Dim Level")),
- new MetaItem(DESCRIPTION, Values.create("The level of dimming of all the lights")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("colorAllRGBW", OBJECT)
- .setMeta(
- new MetaItem(LABEL, Values.create("Color RGBW")),
- new MetaItem(DESCRIPTION, Values.create("The RGBW color of all the lights")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(STORE_DATA_POINTS)
- ),
- new AssetAttribute("scenario", STRING)
- .setMeta(
- new MetaItem(LABEL, Values.create("Scenario")),
- new MetaItem(DESCRIPTION, Values.create("The scenario the lights are setup to")),
- new MetaItem(RULE_STATE, Values.create(true))
- )
+ Asset lightAsset = new Asset(name, LIGHT_CONTROLLER, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue())
);
+ lightAsset.getAttribute("lightAllStatus").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("lightAllDimLevel").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("colorAllRGBW").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE),
+ new MetaItem(STORE_DATA_POINTS)
+ ));
+ lightAsset.getAttribute("scenario").ifPresent(assetAttribute -> assetAttribute.addMeta(
+ new MetaItem(RULE_STATE)
+ ));
return lightAsset;
}
diff --git a/model/src/main/java/org/openremote/model/Constants.java b/model/src/main/java/org/openremote/model/Constants.java
index dded00169..bda732c45 100644
--- a/model/src/main/java/org/openremote/model/Constants.java
+++ b/model/src/main/java/org/openremote/model/Constants.java
@@ -65,30 +65,44 @@ public interface Constants {
String SETUP_EMAIL_FROM_DEFAULT = "[email protected]";
String REQUEST_HEADER_REALM = "Auth-Realm";
- String UNITS_TEMPERATURE_CELCIUS = "CELCIUS";
+ String UNITS_TEMPERATURE_CELSIUS = "CELSIUS";
+ String UNITS_TEMPERATURE_FAHRENHEIT = "FAHRENHEIT";
+ String UNITS_TIME_HOURS = "HOURS";
String UNITS_TIME_MINUTES = "MINUTES";
String UNITS_TIME_SECONDS = "SECONDS";
- String UNITS_SPEED_KNOTS = "KNOTS";
- String UNITS_SPEED_KPH = "SPEED_KPH";
- String UNITS_SPEED_MPS = "SPEED_MPS";
+ String UNITS_TIME_MILLISECONDS = "MILLISECONDS";
+ String UNITS_SPEED_KNOTS = "SPEED_KNOTS";
+ String UNITS_SPEED_KILOMETERS_HOUR = "SPEED_KMPH";
+ String UNITS_SPEED_MILES_HOUR = "SPEED_MIPH";
+ String UNITS_SPEED_METRES_SECOND = "SPEED_MPS";
String UNITS_SOUND_DECIBELS = "DECIBELS";
- String UNITS_DISTANCE_M = "METRES";
- String UNITS_DISTANCE_CM = "CENTIMETRES";
- String UNITS_DISTANCE_MM = "MILLIMETRES";
- String UNITS_DIRECTION_DEGREES = "DEGREES";
+ String UNITS_DISTANCE_KILOMETRES = "DISTANCE_KM";
+ String UNITS_DISTANCE_MILES = "DISTANCE_MI";
+ String UNITS_DISTANCE_METRES = "DISTANCE_M";
+ String UNITS_DISTANCE_CENTIMETRES = "DISTANCE_CM";
+ String UNITS_DISTANCE_MILLIMETRES = "DISTANCE_MM";
String UNITS_FLOW_LPM = "FLOW_LPM";
String UNITS_EUR_PER_KILOWATT_HOUR = "EUR_PER_KWH";
String UNITS_EUR_PER_MONTH = "EUR_PER_MONTH";
String UNITS_GBP_PER_KILOWATT_HOUR = "GBP_PER_KWH";
String UNITS_GBP_PER_MONTH = "GBP_PER_MONTH";
- String UNITS_KILOWATT_PER_HOUR = "KW_PER_HOUR";
- String UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR = "KG_CARBON_PER_KWH";
+ String UNITS_CURRENCY_EUR = "CURRENCY_EUR";
+ String UNITS_CURRENCY_GBP = "CURRENCY_GBP";
String UNITS_POWER_KILOWATT = "POWER_KW";
String UNITS_POWER_WATT = "POWER_W";
+ String UNITS_POWER_KILOWATT_PEAK = "POWER_KWP";
+ String UNITS_POWER_PER_SQUARE_M = "POWER_PER_M2";
+ String UNITS_ENERGY_KILOWATT_HOUR = "ENERGY_KWH";
+ String UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR = "KG_CARBON_PER_KWH";
String UNITS_MASS_KILOGRAM = "MASS_KG";
- String UNITS_CURRENCY_EUR = "CURRENCY_EUR";
- String UNITS_CURRENCY_GBP = "CURRENCY_GBP";
String UNITS_ANGLE_DEGREES = "ANGLE_DEGREES";
String UNITS_ANGLE_RADIANS = "ANGLE_RADIANS";
- String UNITS_ANGLE_DEGREES_MINS_SECONDS = "ANGLE_DMS";
+ String UNITS_PERCENTAGE = "PERCENTAGE";
+ String UNITS_DENSITY_KILOGRAMS_CUBIC_M = "DENSITY_KG_M3";
+ String UNITS_DENSITY_MICROGRAMS_CUBIC_M = "DENSITY_UG_M3";
+ String UNITS_ON_OFF = "ON_OFF";
+ String UNITS_PRESSED_RELEASED = "PRESSED_RELEASED";
+ String UNITS_COUNT_PER_HOUR = "COUNT_PER_HOUR";
+ String UNITS_COUNT_PER_MINUTE = "COUNT_PER_MINUTE";
+ String UNITS_COUNT_PER_SECOND = "COUNT_PER_SECOND";
}
diff --git a/model/src/main/java/org/openremote/model/asset/AssetType.java b/model/src/main/java/org/openremote/model/asset/AssetType.java
index 756376131..d5e66b973 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetType.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetType.java
@@ -66,194 +66,143 @@ public enum AssetType implements AssetDescriptor {
CONSOLE(ASSET_NAMESPACE + ":console", "monitor-cellphone", null),
MICROPHONE(ASSET_NAMESPACE + ":microphone", "microphone", "47A5FF",
- new AttributeDescriptorImpl("microphoneLevel", SOUND, Values.create(0),
+ new AttributeDescriptorImpl("microphoneLevel", SOUND, null,
LABEL.withInitialValue(Values.create("Microphone Level")),
- DESCRIPTION.withInitialValue(Values.create("DB")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
)
),
SOUND_EVENT(ASSET_NAMESPACE + ":soundEvent", "surround-sound", "5BBBD1",
- new AttributeDescriptorImpl("alarmEvent", OBJECT, null,
- LABEL.withInitialValue(Values.create("Alarm event")),
- READ_ONLY,
- DESCRIPTION.withInitialValue(Values.create("Alarm event"))),
- new AttributeDescriptorImpl("aggressionEvent", OBJECT, null,
- LABEL.withInitialValue(Values.create("Aggression event")),
- READ_ONLY,
- DESCRIPTION.withInitialValue(Values.create("Aggression event"))),
- new AttributeDescriptorImpl("breakingGlassEvent", OBJECT, null,
- LABEL.withInitialValue(Values.create("Breaking glass event")),
- READ_ONLY,
- DESCRIPTION.withInitialValue(Values.create("LBreaking glass event"))),
- new AttributeDescriptorImpl("gunshotEvent", OBJECT, null,
- LABEL.withInitialValue(Values.create("Gunshot event")),
- READ_ONLY,
- DESCRIPTION.withInitialValue(Values.create("Gunshot event"))),
- new AttributeDescriptorImpl("intensityEvent", OBJECT, null,
- LABEL.withInitialValue(Values.create("Intensity event")),
- READ_ONLY,
- DESCRIPTION.withInitialValue(Values.create("Intensity event"))),
+ new AttributeDescriptorImpl("lastAlarmEvent", OBJECT, null,
+ LABEL.withInitialValue(Values.create("Last alarm event")),
+ READ_ONLY),
+ new AttributeDescriptorImpl("lastAggressionEvent", OBJECT, null,
+ LABEL.withInitialValue(Values.create("Last aggression event")),
+ READ_ONLY),
+ new AttributeDescriptorImpl("lastBreakingGlassEvent", OBJECT, null,
+ LABEL.withInitialValue(Values.create("Last breaking glass event")),
+ READ_ONLY),
+ new AttributeDescriptorImpl("lastGunshotEvent", OBJECT, null,
+ LABEL.withInitialValue(Values.create("Last gunshot event")),
+ READ_ONLY),
+ new AttributeDescriptorImpl("lastIntensityEvent", OBJECT, null,
+ LABEL.withInitialValue(Values.create("Last intensity event")),
+ READ_ONLY),
new AttributeDescriptorImpl("lastEvent", OBJECT, null,
LABEL.withInitialValue(Values.create("Last event")),
- READ_ONLY,
- DESCRIPTION.withInitialValue(Values.create("Last event")))
+ READ_ONLY)
),
ENVIRONMENT_SENSOR(ASSET_NAMESPACE + ":enviroment", "periodic-table-co2", "f18546",
- new AttributeDescriptorImpl("temperature", TEMPERATURE, Values.create(0),
+ new AttributeDescriptorImpl("temperature", TEMPERATURE, null,
LABEL.withInitialValue(Values.create("Temperature")),
- DESCRIPTION.withInitialValue(Values.create("Temperature in celcius")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
),
- new AttributeDescriptorImpl("nO2", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("nO2", DENSITY, null,
LABEL.withInitialValue(Values.create("Nitrogen Level")),
- DESCRIPTION.withInitialValue(Values.create("µg/m3")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ UNIT_TYPE.withInitialValue(Values.create(UNITS_DENSITY_MICROGRAMS_CUBIC_M)),
+ READ_ONLY
),
- new AttributeDescriptorImpl("relHumidity", PERCENTAGE, Values.create(0),
+ new AttributeDescriptorImpl("relHumidity", PERCENTAGE, null,
LABEL.withInitialValue(Values.create("Humidity")),
- DESCRIPTION.withInitialValue(Values.create("Humidity in area")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
),
- new AttributeDescriptorImpl("ozone", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("ozone", DENSITY, null,
LABEL.withInitialValue(Values.create("Ozone Level")),
- DESCRIPTION.withInitialValue(Values.create("µg/m3")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ UNIT_TYPE.withInitialValue(Values.create(UNITS_DENSITY_MICROGRAMS_CUBIC_M)),
+ READ_ONLY
),
- new AttributeDescriptorImpl("particlesPM1", NUMBER, Values.create(0),
- LABEL.withInitialValue(Values.create("Particles PM 1")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ new AttributeDescriptorImpl("particlesPM1", DENSITY, null,
+ LABEL.withInitialValue(Values.create("Particles PM1")),
+ UNIT_TYPE.withInitialValue(Values.create(UNITS_DENSITY_MICROGRAMS_CUBIC_M)),
+ READ_ONLY
),
- new AttributeDescriptorImpl("particlesPM2_5", NUMBER, Values.create(0),
- LABEL.withInitialValue(Values.create("Particles PM 2.5")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ new AttributeDescriptorImpl("particlesPM2_5", DENSITY, null,
+ LABEL.withInitialValue(Values.create("Particles PM2.5")),
+ UNIT_TYPE.withInitialValue(Values.create(UNITS_DENSITY_MICROGRAMS_CUBIC_M)),
+ READ_ONLY
),
- new AttributeDescriptorImpl("particlesPM10", NUMBER, Values.create(0),
- LABEL.withInitialValue(Values.create("Particles PM 10")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ new AttributeDescriptorImpl("particlesPM10", DENSITY, null,
+ LABEL.withInitialValue(Values.create("Particles PM10")),
+ UNIT_TYPE.withInitialValue(Values.create(UNITS_DENSITY_MICROGRAMS_CUBIC_M)),
+ READ_ONLY
)
),
LIGHT(ASSET_NAMESPACE + ":light", "lightbulb", "e6688a",
- new AttributeDescriptorImpl("lightStatus", BOOLEAN, Values.create(false),
+ new AttributeDescriptorImpl("lightStatus", SWITCH_TOGGLE, null,
LABEL.withInitialValue(Values.create("Light status")),
- DESCRIPTION.withInitialValue(Values.create("Indicates if the light is on or off")),
- RULE_STATE,
- STORE_DATA_POINTS
+ DESCRIPTION.withInitialValue(Values.create("Indicates if the light is on or off"))
),
- new AttributeDescriptorImpl("lightDimLevel", PERCENTAGE, Values.create(0),
+ new AttributeDescriptorImpl("lightDimLevel", PERCENTAGE, null,
LABEL.withInitialValue(Values.create("Light Dim Level")),
- DESCRIPTION.withInitialValue(Values.create("The level of dimming of the light")),
- RULE_STATE,
- STORE_DATA_POINTS
+ DESCRIPTION.withInitialValue(Values.create("The level of dimming of the light"))
),
- new AttributeDescriptorImpl("colorGBW", OBJECT, Values.createObject(),
+ new AttributeDescriptorImpl("colorRGBW", COLOR_RGBW, null,
LABEL.withInitialValue(Values.create("Color RGBW")),
- DESCRIPTION.withInitialValue(Values.create("The RGBW color of the light")),
- RULE_STATE,
- STORE_DATA_POINTS
+ DESCRIPTION.withInitialValue(Values.create("The RGBW color of the light"))
),
new AttributeDescriptorImpl("groupNumber", NUMBER, null,
LABEL.withInitialValue(Values.create("Group number")),
- DESCRIPTION.withInitialValue(Values.create("Which group this light belongs to")),
- RULE_STATE
+ DESCRIPTION.withInitialValue(Values.create("Which group this light belongs to"))
),
- new AttributeDescriptorImpl("Scenario", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("Scenario", STRING, null,
LABEL.withInitialValue(Values.create("Scenario")),
- DESCRIPTION.withInitialValue(Values.create("The scenario the light are setup to")),
- RULE_STATE
+ DESCRIPTION.withInitialValue(Values.create("The scenario the light are setup to"))
)
),
LIGHT_CONTROLLER(ASSET_NAMESPACE + ":lightController", "light-switch", "9e5de2",
- new AttributeDescriptorImpl("lightAllStatus", BOOLEAN, Values.create(false),
+ new AttributeDescriptorImpl("lightAllStatus", SWITCH_TOGGLE, null,
LABEL.withInitialValue(Values.create("Light all status")),
- DESCRIPTION.withInitialValue(Values.create("Indicates if all lights are on or off")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ DESCRIPTION.withInitialValue(Values.create("Indicates if all lights are on or off"))
),
- new AttributeDescriptorImpl("lightAllDimLevel", PERCENTAGE, Values.create(0),
+ new AttributeDescriptorImpl("lightAllDimLevel", PERCENTAGE, null,
LABEL.withInitialValue(Values.create("Light Dim Level")),
- DESCRIPTION.withInitialValue(Values.create("The level of dimming of all the lights")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ DESCRIPTION.withInitialValue(Values.create("The level of dimming of all the lights"))
),
- new AttributeDescriptorImpl("colorAllRGBW", OBJECT, Values.createObject(),
+ new AttributeDescriptorImpl("colorAllRGBW", COLOR_RGBW, null,
LABEL.withInitialValue(Values.create("Color RGBW")),
- DESCRIPTION.withInitialValue(Values.create("The RGBW color of all the lights")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ DESCRIPTION.withInitialValue(Values.create("The RGBW color of all the lights"))
),
- new AttributeDescriptorImpl("Scenario", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("Scenario", STRING, null,
LABEL.withInitialValue(Values.create("Scenario")),
- DESCRIPTION.withInitialValue(Values.create("The scenario the lights are setup to")),
- READ_ONLY,
- RULE_STATE
+ DESCRIPTION.withInitialValue(Values.create("The scenario the lights are setup to"))
)
),
PEOPLE_COUNTER(ASSET_NAMESPACE + ":peopleCounter", "account-multiple", "4b5966", false,
- new AttributeDescriptorImpl("peopleCountIn", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("peopleCountIn", INTEGER, null,
LABEL.withInitialValue(Values.create("People Count In")),
DESCRIPTION.withInitialValue(Values.create("Cumulative number of people going into area")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
),
- new AttributeDescriptorImpl("peopleCountOut", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("peopleCountOut", INTEGER, null,
LABEL.withInitialValue(Values.create("People Count Out")),
DESCRIPTION.withInitialValue(Values.create("Cumulative number of people leaving area")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
),
- new AttributeDescriptorImpl("peopleCountInMinute", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("peopleCountInMinute", INTEGER, null,
LABEL.withInitialValue(Values.create("People Count In Minute")),
DESCRIPTION.withInitialValue(Values.create("Number of people going into area per minute")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ UNIT_TYPE.withInitialValue(UNITS_COUNT_PER_MINUTE),
+ READ_ONLY
),
- new AttributeDescriptorImpl("peopleCountOutMinute", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("peopleCountOutMinute", INTEGER, null,
LABEL.withInitialValue(Values.create("People Count Out Minute")),
DESCRIPTION.withInitialValue(Values.create("Number of people leaving area per minute")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ UNIT_TYPE.withInitialValue(UNITS_COUNT_PER_MINUTE),
+ READ_ONLY
),
- new AttributeDescriptorImpl("peopleCountTotal", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("peopleCountTotal", INTEGER, null,
LABEL.withInitialValue(Values.create("People Count Total")),
DESCRIPTION.withInitialValue(Values.create("cameraCountIn - cameraCountOut")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
),
- new AttributeDescriptorImpl("peopleCountGrowth", NUMBER, Values.create(0),
+ new AttributeDescriptorImpl("peopleCountGrowth", INTEGER, null,
LABEL.withInitialValue(Values.create("People Count Growth")),
DESCRIPTION.withInitialValue(Values.create("cameraCountIn - cameraCountOut")),
- READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS
+ READ_ONLY
)
),
@@ -274,7 +223,7 @@ public enum AssetType implements AssetDescriptor {
DESCRIPTION.withInitialValue(Values.create("Connection status of the gateway")),
READ_ONLY
),
- new AttributeDescriptorImpl("disabled", BOOLEAN, Values.create(false))
+ new AttributeDescriptorImpl("disabled", BOOLEAN, null)
),
GROUP(ASSET_NAMESPACE + ":group", "folder", "B3B3B3",
@@ -299,53 +248,35 @@ public enum AssetType implements AssetDescriptor {
ALLOWED_VALUES.withInitialValue(Values.createArray().addAll(Arrays.stream(ElectricityConsumerDemandResponseType.values()).map(Enum::name).toArray(String[]::new)))),
new AttributeDescriptorImpl("energyTariffImport", CURRENCY, null,
LABEL.withInitialValue("Energy tariff import"),
- RULE_STATE,
- STORE_DATA_POINTS,
UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("energyTariffExport", CURRENCY, null,
LABEL.withInitialValue("Energy tariff export"),
- RULE_STATE,
- STORE_DATA_POINTS,
UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("energyCarbonImport", ENERGY, null,
LABEL.withInitialValue("Energy carbon import"),
- UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR),
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("energyCarbonExport", ENERGY, null,
LABEL.withInitialValue("Energy carbon export"),
- UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR),
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("totalPower", POWER, null,
LABEL.withInitialValue("Total power"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("forecastPowerDeviation", NUMBER, null,
+ READ_ONLY),
+ new AttributeDescriptorImpl("forecastPowerDeviation", POWER, null,
LABEL.withInitialValue("Forecast power deviation"),
READ_ONLY),
- new AttributeDescriptorImpl("setPointPower", NUMBER, null,
+ new AttributeDescriptorImpl("setPointPower", POWER, null,
LABEL.withInitialValue("Setpoint power"),
- DESCRIPTION.withInitialValue("Positive is consuming, negative is delivering to network"),
- STORE_DATA_POINTS,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("availableMaxPower", NUMBER, null,
+ DESCRIPTION.withInitialValue("Positive is consuming, negative is delivering to network")),
+ new AttributeDescriptorImpl("availableMaxPower", POWER, null,
LABEL.withInitialValue("Available max power"),
- READ_ONLY,
- STORE_DATA_POINTS,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("availableMinPower", NUMBER, null,
+ READ_ONLY),
+ new AttributeDescriptorImpl("availableMinPower", POWER, null,
LABEL.withInitialValue("Available min power"),
- READ_ONLY,
- STORE_DATA_POINTS,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("totalEnergy", ENERGY, Values.create(0),
+ READ_ONLY),
+ new AttributeDescriptorImpl("totalEnergy", ENERGY, null,
LABEL.withInitialValue("Total energy"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE)
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY)
),
ELECTRICITY_PRODUCER(ASSET_NAMESPACE + ":electricityProducer", "white-balance-sunny", "CC9423", false,
@@ -359,29 +290,20 @@ public enum AssetType implements AssetDescriptor {
LABEL.withInitialValue("Status"),
DESCRIPTION.withInitialValue("Status system"),
READ_ONLY),
- new AttributeDescriptorImpl("installedCapacity", NUMBER, Values.create(10000),
+ new AttributeDescriptorImpl("installedCapacity", POWER, null,
LABEL.withInitialValue("Installed capacity"),
- DESCRIPTION.withInitialValue("Power delivered at normalised eg. sun intensity, wind speeds"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- RULE_STATE),
+ DESCRIPTION.withInitialValue("Power delivered at normalised eg. sun intensity, wind speeds")),
new AttributeDescriptorImpl("systemEfficiency", PERCENTAGE, null,
- LABEL.withInitialValue("System efficiency"),
- RULE_STATE),
- new AttributeDescriptorImpl("totalPower", POWER, Values.create(0),
+ LABEL.withInitialValue("System efficiency")),
+ new AttributeDescriptorImpl("totalPower", POWER, null,
LABEL.withInitialValue("Total power"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS,
READ_ONLY),
new AttributeDescriptorImpl("forecastPowerDeviation", NUMBER, null,
LABEL.withInitialValue("Forecast power deviation"),
READ_ONLY),
- new AttributeDescriptorImpl("totalEnergy", ENERGY, Values.create(0),
+ new AttributeDescriptorImpl("totalEnergy", ENERGY, null,
LABEL.withInitialValue("Total energy"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- STORE_DATA_POINTS,
- RULE_STATE,
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
READ_ONLY)
),
@@ -398,77 +320,55 @@ public enum AssetType implements AssetDescriptor {
READ_ONLY),
new AttributeDescriptorImpl("installedCapacity", NUMBER, null,
LABEL.withInitialValue("Installed capacity"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR)),
new AttributeDescriptorImpl("levelledCostOfStorage", CURRENCY, null,
LABEL.withInitialValue("Levelised cost of storage"),
- UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR),
- RULE_STATE),
- new AttributeDescriptorImpl("maxCharge", NUMBER, null,
+ UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR)),
+ new AttributeDescriptorImpl("maxCharge", POWER, null,
LABEL.withInitialValue("Max charge"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
READ_ONLY),
new AttributeDescriptorImpl("maxDischarge", NUMBER, null,
LABEL.withInitialValue("Max discharge"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
READ_ONLY),
new AttributeDescriptorImpl("chargeState", PERCENTAGE, null,
LABEL.withInitialValue("Charge state"),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE),
+ READ_ONLY),
new AttributeDescriptorImpl("chargedCapacity", CHARGE, null,
LABEL.withInitialValue("Charged capacity"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY),
new AttributeDescriptorImpl("freeCapacity", CHARGE, null,
LABEL.withInitialValue("Free capacity"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY),
new AttributeDescriptorImpl("totalPower", POWER, null,
LABEL.withInitialValue("Total power"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("setPointPower", NUMBER, null,
LABEL.withInitialValue("Setpoint power"),
- DESCRIPTION.withInitialValue("Positive is consuming, negative is delivering to network"),
- STORE_DATA_POINTS),
+ DESCRIPTION.withInitialValue("Positive is consuming, negative is delivering to network")),
new AttributeDescriptorImpl("command", NUMBER, null,
LABEL.withInitialValue("Command"),
- DESCRIPTION.withInitialValue("0 = No command, 1 = Start, 2 = Stop"),
- STORE_DATA_POINTS),
+ DESCRIPTION.withInitialValue("0 = No command, 1 = Start, 2 = Stop")),
new AttributeDescriptorImpl("energyCharged", CHARGE, null,
LABEL.withInitialValue("Energy charged"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY),
new AttributeDescriptorImpl("energyDischarged", CHARGE, null,
LABEL.withInitialValue("Energy discharged"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY),
new AttributeDescriptorImpl("chargeCycle", INTEGER, null,
LABEL.withInitialValue("Charge cycle"),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE),
+ READ_ONLY),
new AttributeDescriptorImpl("financialWallet", CURRENCY, null,
LABEL.withInitialValue("Financial wallet"),
READ_ONLY,
- UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR),
- STORE_DATA_POINTS,
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR)),
new AttributeDescriptorImpl("carbonWallet", CO2, null,
LABEL.withInitialValue("Carbon wallet"),
UNIT_TYPE.withInitialValue(UNITS_MASS_KILOGRAM),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE)
+ READ_ONLY)
),
ELECTRICITY_SUPPLIER(ASSET_NAMESPACE + ":electricitySupplier", "upload-network", "9257A9", false,
@@ -482,15 +382,11 @@ public enum AssetType implements AssetDescriptor {
LABEL.withInitialValue("Status"),
DESCRIPTION.withInitialValue("Status system (operational)")),
new AttributeDescriptorImpl("connectionPower", POWER, null,
- LABEL.withInitialValue("Connection power"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- STORE_DATA_POINTS,
- RULE_STATE),
+ LABEL.withInitialValue("Connection power")),
new AttributeDescriptorImpl("setpointEdrPower", OBJECT, null,
LABEL.withInitialValue("Setpoint EDR power"),
UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- READ_ONLY,
- RULE_STATE),
+ READ_ONLY),
new AttributeDescriptorImpl("edrPrimaryReserve", POWER, null,
LABEL.withInitialValue("EDR primary reserve"),
UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT)),
@@ -500,9 +396,6 @@ public enum AssetType implements AssetDescriptor {
new AttributeDescriptorImpl("energyTariffImport", CURRENCY, null,
LABEL.withInitialValue("Energy tariff import"),
READ_ONLY,
- RULE_STATE,
- STORE_DATA_POINTS,
- HAS_PREDICTED_DATA_POINTS,
UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("forecastEnergyTariffImportDeviation", NUMBER, null,
LABEL.withInitialValue("Forecast energy tariff import deviation"),
@@ -510,9 +403,6 @@ public enum AssetType implements AssetDescriptor {
new AttributeDescriptorImpl("energyTariffExport", CURRENCY, null,
LABEL.withInitialValue("Energy tariff export"),
READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS,
UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("forecastEnergyTariffExportDeviation", NUMBER, null,
LABEL.withInitialValue("Forecast energy tariff export deviation"),
@@ -520,141 +410,86 @@ public enum AssetType implements AssetDescriptor {
new AttributeDescriptorImpl("energyTax", CURRENCY, null,
LABEL.withInitialValue("Energy tax"),
READ_ONLY,
- RULE_STATE,
UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
new AttributeDescriptorImpl("gridCosts", CURRENCY, null,
LABEL.withInitialValue("Grid costs"),
- UNIT_TYPE.withInitialValue(UNITS_EUR_PER_MONTH),
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_EUR_PER_MONTH)),
new AttributeDescriptorImpl("gridConnectCosts", CURRENCY, null,
LABEL.withInitialValue("Grid connection costs"),
- UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR),
- RULE_STATE),
+ UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR)),
new AttributeDescriptorImpl("energyCarbonImport", ENERGY, null,
LABEL.withInitialValue("Energy carbon import"),
UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR),
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS,
- STORE_DATA_POINTS,
READ_ONLY),
new AttributeDescriptorImpl("energyCarbonExport", ENERGY, null,
LABEL.withInitialValue("Energy carbon export"),
UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR),
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS,
- STORE_DATA_POINTS,
READ_ONLY),
- new AttributeDescriptorImpl("totalPower", POWER, Values.create(0),
+ new AttributeDescriptorImpl("totalPower", POWER, null,
LABEL.withInitialValue("Total power"),
- UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE),
+ READ_ONLY),
new AttributeDescriptorImpl("forecastPowerDeviation", NUMBER, null,
LABEL.withInitialValue("Forecast power deviation"),
- READ_ONLY,
- RULE_EVENT),
- new AttributeDescriptorImpl("totalEnergyImport", ENERGY, Values.create(0),
+ READ_ONLY),
+ new AttributeDescriptorImpl("totalEnergyImport", ENERGY, null,
LABEL.withInitialValue("Total energy import"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE),
- new AttributeDescriptorImpl("totalEnergyExport", ENERGY, Values.create(0),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY),
+ new AttributeDescriptorImpl("totalEnergyExport", ENERGY, null,
LABEL.withInitialValue("Total energy export"),
- UNIT_TYPE.withInitialValue(UNITS_KILOWATT_PER_HOUR),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE),
- new AttributeDescriptorImpl("totalEnergyImportCosts", CURRENCY, Values.create(0),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY),
+ new AttributeDescriptorImpl("totalEnergyImportCosts", CURRENCY, null,
LABEL.withInitialValue("Total energy import costs"),
READ_ONLY,
- UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR),
- STORE_DATA_POINTS,
- RULE_STATE),
- new AttributeDescriptorImpl("totalEnergyExportIncome", CURRENCY, Values.create(0),
+ UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR)),
+ new AttributeDescriptorImpl("totalEnergyExportIncome", CURRENCY, null,
LABEL.withInitialValue("Total energy export income"),
READ_ONLY,
- UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR),
- STORE_DATA_POINTS,
- RULE_STATE),
- new AttributeDescriptorImpl("totalCarbonCosts", CO2, Values.create(0),
+ UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR)),
+ new AttributeDescriptorImpl("totalCarbonCosts", CO2, null,
LABEL.withInitialValue("Total carbon costs"),
UNIT_TYPE.withInitialValue(UNITS_MASS_KILOGRAM),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE)
+ READ_ONLY)
),
WEATHER(ASSET_NAMESPACE + ":weather", "weather-partly-cloudy", "49B0D8", false,
new AttributeDescriptorImpl("userNotes", STRING, null,
LABEL.withInitialValue("User notes")),
- new AttributeDescriptorImpl("temperature", TEMPERATURE, Values.create(0),
+ new AttributeDescriptorImpl("temperature", TEMPERATURE, null,
LABEL.withInitialValue("Temperature"),
- UNIT_TYPE.withInitialValue(UNITS_TEMPERATURE_CELCIUS),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("sunUvIndex", NUMBER, null,
+ READ_ONLY),
+ new AttributeDescriptorImpl("sunUvIndex", INTEGER, null,
LABEL.withInitialValue("UV Index of the sun"),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("sunIrradiance", NUMBER, null,
LABEL.withInitialValue("Irradiance of the sun"),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("sunAzimuth", NUMBER, null,
+ UNIT_TYPE.withInitialValue(UNITS_POWER_PER_SQUARE_M),
+ READ_ONLY),
+ new AttributeDescriptorImpl("sunAzimuth", INTEGER, null,
LABEL.withInitialValue("Azimuth of the sun"),
UNIT_TYPE.withInitialValue(UNITS_ANGLE_DEGREES),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
- new AttributeDescriptorImpl("sunZenith", NUMBER, null,
+ READ_ONLY),
+ new AttributeDescriptorImpl("sunZenith", INTEGER, null,
LABEL.withInitialValue("Zenith of the sun"),
UNIT_TYPE.withInitialValue(UNITS_ANGLE_DEGREES),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("sunAltitude", NUMBER, null,
LABEL.withInitialValue("Altitude of the sun"),
UNIT_TYPE.withInitialValue(UNITS_ANGLE_DEGREES),
- READ_ONLY,
- STORE_DATA_POINTS,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("windSpeed", SPEED, null,
LABEL.withInitialValue("Wind speed"),
- UNIT_TYPE.withInitialValue(UNITS_SPEED_MPS),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("windDirection", DIRECTION, null,
LABEL.withInitialValue("Wind direction"),
- UNIT_TYPE.withInitialValue(UNITS_ANGLE_DEGREES),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("precipitation", RAINFALL, null,
LABEL.withInitialValue("Precipitation"),
- UNIT_TYPE.withInitialValue(UNITS_DISTANCE_MM),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS),
+ READ_ONLY),
new AttributeDescriptorImpl("humidity", PERCENTAGE, null,
LABEL.withInitialValue("Humidity"),
- READ_ONLY,
- STORE_DATA_POINTS,
- RULE_STATE,
- HAS_PREDICTED_DATA_POINTS)
+ READ_ONLY)
);
final protected String type;
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
index 943213d65..9ff3d76e1 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
@@ -29,10 +29,10 @@ import org.openremote.model.value.ValueType;
import org.openremote.model.value.Values;
import java.util.Arrays;
-import java.util.List;
import java.util.Optional;
import java.util.function.Function;
+import static org.openremote.model.Constants.*;
import static org.openremote.model.attribute.AttributeValueType.AttributeValueTypeFailureReason.ATTRIBUTE_TYPE_VALUE_DOES_NOT_MATCH;
import static org.openremote.model.attribute.MetaItemType.*;
@@ -54,9 +54,9 @@ public enum AttributeValueType implements AttributeValueDescriptor {
BOOLEAN("toggle-on", ValueType.BOOLEAN),
- SWITCH_TOGGLE("toggle-on", ValueType.BOOLEAN),
+ SWITCH_TOGGLE("toggle-on", ValueType.BOOLEAN, UNIT_TYPE.withInitialValue(UNITS_ON_OFF)),
- SWITCH_MOMENTARY("toggle-on", ValueType.BOOLEAN),
+ SWITCH_MOMENTARY("toggle-on", ValueType.BOOLEAN, UNIT_TYPE.withInitialValue(UNITS_PRESSED_RELEASED)),
OBJECT("cube", ValueType.OBJECT),
@@ -69,6 +69,7 @@ public enum AttributeValueType implements AttributeValueDescriptor {
RANGE_MIN.withInitialValue(Values.create(0)),
RANGE_MAX.withInitialValue(Values.create(100)),
STEP.withInitialValue(Values.create(1)),
+ UNIT_TYPE.withInitialValue(UNITS_PERCENTAGE),
FORMAT.withInitialValue(Values.create("%3d %%"))
),
@@ -94,6 +95,12 @@ public enum AttributeValueType implements AttributeValueDescriptor {
.map(array -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID_COLOR_FORMAT))
),
+ COLOR_RGBW("palette", ValueType.ARRAY, value -> Values.getArray(value)
+ .filter(array -> array.length() != 4)
+ .map(array -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID_COLOR_FORMAT)),
+ UNIT_TYPE.withInitialValue("")
+ ),
+
COLOR_ARGB("palette", ValueType.ARRAY, value -> Values.getArray(value)
.filter(array -> array.length() != 4)
.map(array -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID_COLOR_FORMAT))
@@ -114,27 +121,27 @@ public enum AttributeValueType implements AttributeValueDescriptor {
TEMPERATURE("temperature-high", ValueType.NUMBER, value -> Values.getNumber(value)
.filter(n -> n < -273.15)
.map(n -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_TEMPERATURE_OUT_OF_RANGE)),
- UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELCIUS),
+ UNIT_TYPE.withInitialValue(Constants.UNITS_TEMPERATURE_CELSIUS),
FORMAT.withInitialValue(Values.create("%0.1f C")
)
),
CURRENCY("money", ValueType.NUMBER),
- RAINFALL("water", ValueType.NUMBER),
+ RAINFALL("water", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_DISTANCE_MILLIMETRES)),
BRIGHTNESS("lightbulb", ValueType.NUMBER,
STEP.withInitialValue(Values.create(1))),
- DISTANCE("ruler", ValueType.NUMBER),
+ DISTANCE("ruler", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_DISTANCE_METRES)),
- SPEED("circle", ValueType.NUMBER),
+ SPEED("circle", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_SPEED_METRES_SECOND)),
CO2("leaf", ValueType.NUMBER),
HUMIDITY("water", ValueType.NUMBER),
- POWER("bolt", ValueType.NUMBER),
+ POWER("bolt", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT)),
CHARGE("battery-half", ValueType.NUMBER, value -> Values.getNumber(value)
.filter(number -> number < 0 || number > 100)
@@ -147,7 +154,7 @@ public enum AttributeValueType implements AttributeValueDescriptor {
FLOW("dot-circle", ValueType.NUMBER),
- DIRECTION("compass", ValueType.NUMBER),
+ DIRECTION("compass", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_ANGLE_DEGREES)),
GEO_JSON_POINT("map-marker-alt", ValueType.OBJECT),
@@ -165,7 +172,13 @@ public enum AttributeValueType implements AttributeValueDescriptor {
EXECUTION_STATUS("play-circle", ValueType.STRING, new MetaItemDescriptorImpl(ALLOWED_VALUES, Values.createArray(Arrays.stream(AttributeExecuteStatus.values()).map(executeStatus -> Values.create(executeStatus.name())).toArray(Value[]::new)))),
- CONNECTION_STATUS("lan-connect", ValueType.STRING, new MetaItemDescriptorImpl(ALLOWED_VALUES, Values.createArray(Arrays.stream(ConnectionStatus.values()).map(connectionStatus -> Values.create(connectionStatus.name())).toArray(Value[]::new))));
+ CONNECTION_STATUS("lan-connect", ValueType.STRING, new MetaItemDescriptorImpl(ALLOWED_VALUES, Values.createArray(Arrays.stream(ConnectionStatus.values()).map(connectionStatus -> Values.create(connectionStatus.name())).toArray(Value[]::new)))),
+
+ MASS("weight", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_MASS_KILOGRAM)),
+
+ DENSITY("cube", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_DENSITY_KILOGRAMS_CUBIC_M)),
+
+ RATE("guage", ValueType.NUMBER, UNIT_TYPE.withInitialValue(UNITS_COUNT_PER_SECOND));
public enum AttributeValueTypeFailureReason implements ValidationFailure.Reason {
ATTRIBUTE_TYPE_VALUE_DOES_NOT_MATCH
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
index eea022e9a..02d394a5f 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -3,6 +3,7 @@ package org.openremote.test.assets
import org.openremote.manager.setup.SetupService
import org.openremote.manager.setup.builtin.KeycloakDemoSetup
import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.model.Constants
import org.openremote.model.asset.AssetResource
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
@@ -660,7 +661,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
resultMeta.stream().filter(isMetaNameEqualTo(STORE_DATA_POINTS)).findFirst().get().getValueAsBoolean().get()
resultMeta.stream().filter(isMetaNameEqualTo(SHOW_ON_DASHBOARD)).findFirst().get().getValueAsBoolean().get()
resultMeta.stream().filter(isMetaNameEqualTo(FORMAT)).findFirst().get().getValueAsString().get() == "%0.1f° C"
- resultMeta.stream().filter(isMetaNameEqualTo(UNIT_TYPE)).findFirst().get().getValueAsString().get() == "CELSIUS"
+ resultMeta.stream().filter(isMetaNameEqualTo(UNIT_TYPE)).findFirst().get().getValueAsString().get() == Constants.UNITS_TEMPERATURE_CELSIUS
when: "an asset is retrieved by ID in a foreign realm"
assetResource.get(null, managerDemoSetup.thingId)
diff --git a/ui/app/or-app/src/pages/page-map.ts b/ui/app/or-app/src/pages/page-map.ts
index fb0c29630..aeea7e184 100644
--- a/ui/app/or-app/src/pages/page-map.ts
+++ b/ui/app/or-app/src/pages/page-map.ts
@@ -112,13 +112,15 @@ const subscribeAssets = (): ThunkAction<void, MapStateKeyed, unknown, Action<str
asset => asset.id
);
- await manager.events.subscribeAssetEvents(ids, true, (event) => {
+ const assetSubscriptionId = await manager.events.subscribeAssetEvents(ids, true, (event) => {
dispatch(assetEventReceived(event));
});
+ dispatch(setAssetSubscriptionId(assetSubscriptionId));
- await manager.events.subscribeAttributeEvents(ids, false, (event) => {
+ const attributeSubscriptionId = await manager.events.subscribeAttributeEvents(ids, false, (event) => {
dispatch(attributeEventReceived(event));
});
+ dispatch(setAttributeSubscriptionId(attributeSubscriptionId));
}
} catch (e) {
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 57fa79c4c..16363f1e5 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -13,7 +13,8 @@ import {
AttributeValueDescriptor,
MetaItemDescriptor,
User,
- Role
+ Role,
+ Attribute
} from "@openremote/model";
import * as Util from "./util";
import orIconSet from "./or-icon-set";
@@ -289,6 +290,39 @@ export class AssetModelUtil {
}
}
+ public static getAttributeAndValueDescriptors(assetType: string | undefined, attributeOrNameOrDescriptor: Attribute | string | AttributeDescriptor | undefined): [AttributeDescriptor | undefined, AttributeValueDescriptor | undefined] {
+ let attributeDescriptor: AttributeDescriptor | undefined;
+ let attributeValueDescriptor: AttributeValueDescriptor | undefined;
+ let attributeName: string | undefined;
+ let attributeTypeOrDescriptor: string | AttributeValueDescriptor | undefined;
+
+ if (typeof attributeOrNameOrDescriptor === "string") {
+ attributeName = attributeOrNameOrDescriptor;
+ attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(attributeOrNameOrDescriptor, assetType);
+ attributeTypeOrDescriptor = attributeDescriptor ? attributeDescriptor.valueDescriptor : undefined;
+ } else if (attributeOrNameOrDescriptor) {
+ if ((attributeOrNameOrDescriptor as Attribute).type) {
+ attributeName = (attributeOrNameOrDescriptor as Attribute).name!;
+ attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(attributeName, assetType);
+ attributeTypeOrDescriptor = (attributeOrNameOrDescriptor as Attribute).type;
+ } else {
+ attributeName = (attributeOrNameOrDescriptor as AttributeDescriptor).attributeName!;
+ attributeDescriptor = attributeOrNameOrDescriptor as AttributeDescriptor;
+ attributeTypeOrDescriptor = (attributeOrNameOrDescriptor as AttributeDescriptor).valueDescriptor;
+ }
+ }
+
+ if (attributeTypeOrDescriptor) {
+ if (typeof attributeTypeOrDescriptor === "string") {
+ attributeValueDescriptor = AssetModelUtil.getAttributeValueDescriptorFromAsset(attributeTypeOrDescriptor, assetType, attributeName);
+ } else {
+ attributeValueDescriptor = attributeTypeOrDescriptor;
+ }
+ }
+
+ return [attributeDescriptor, attributeValueDescriptor];
+ }
+
public static getMetaItemDescriptor(urn?: string): MetaItemDescriptor | undefined {
if (!urn) {
return;
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.ts
index f4b3a4b3a..6eeeccc0c 100644
--- a/ui/component/core/src/util.ts
+++ b/ui/component/core/src/util.ts
@@ -299,14 +299,28 @@ export function getMetaValue(metaItemUrn: string | MetaItemDescriptor, attribute
}
}
-export function getAttributeLabel(attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, fallback?: string): string {
+export function getAttributeLabel(attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, showUnits: boolean, fallback?: string): string {
if (!attribute && !descriptor) {
return fallback || "";
}
- const labelMetaValue = getMetaValue(MetaItemType.LABEL, attribute, descriptor);
+ const label = getMetaValue(MetaItemType.LABEL, attribute, descriptor, valueDescriptor) as string;
+ let units = showUnits ? getMetaValue(MetaItemType.UNIT_TYPE, attribute, descriptor, valueDescriptor) as string : undefined;
+ units = units ? i18next.t(["units." + units, units]) : undefined;
const name = attribute ? attribute.name : descriptor!.attributeName;
- return i18next.t([name, fallback || labelMetaValue || name]);
+ const keys = [];
+ if (name) {
+ keys.push("attribute." + name);
+ keys.push(name);
+ }
+ if (label) {
+ keys.push(label);
+ }
+ if (fallback) {
+ keys.push(fallback);
+ }
+
+ return i18next.t(keys) + (units ? " (" + units + ")" : "");
}
export function getAttributeValueFormat(attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined): string | undefined {
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 0af75d19c..b3c322da2 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -201,13 +201,9 @@ export function getPanelContent(panelName: string, asset: Asset, attributes: Ass
};
const options = historyAttrs.map((attr) => {
- const attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(attr.name!);
- let label = Util.getAttributeLabel(attr, attributeDescriptor);
- const unit = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor);
- if(unit) {
- label = label + " ("+i18next.t(unit)+")";
- }
- return [attr.name, label]
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset.type, attr);
+ const label = Util.getAttributeLabel(attr, descriptors[0], descriptors[1], true);
+ return [attr.name, label];
});
const attrName: string = historyAttrs[0].name!;
onRenderComplete.addCallback(() => attributeChanged(attrName));
@@ -282,7 +278,7 @@ export function getPanelContent(panelName: string, asset: Asset, attributes: Ass
if (attribute) {
content = html`
<div class="field">
- <or-attribute-input .assetType="${asset.type}" .attribute="${attribute}"></or-attribute-input>
+ <or-attribute-input .assetType="${asset.type}" .attribute="${attribute}" readonly disableButton></or-attribute-input>
</div>
`;
}
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 298850a28..f54d78041 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -484,7 +484,10 @@ export class OrAttributeCard extends LitElement {
if (attributes && attributes.length > 0) {
attributes = attributes
.filter((attr: AssetAttribute) => Util.getFirstMetaItem(attr, MetaItemType.STORE_DATA_POINTS.urn!));
- const options = attributes.map((attr: AssetAttribute) => [attr.name, Util.getAttributeLabel(attr, undefined)]);
+ const options = attributes.map((attr: AssetAttribute) => {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.asset!.type, attr);
+ return [attr.name, Util.getAttributeLabel(attr, descriptors[0], descriptors[1], false)];
+ });
return options;
}
}
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 3916612a1..c4855beed 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -9,7 +9,8 @@ import {
AttributeValueType,
MetaItemType,
ValueType,
- SharedEvent
+ SharedEvent,
+ Attribute
} from "@openremote/model";
import manager, {AssetModelUtil, subscribe, Util, DefaultColor4} from "@openremote/core";
import "@openremote/or-input";
@@ -432,19 +433,20 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
this._attributeValueDescriptor = undefined;
this._attributeDescriptor = undefined;
- if (this.attributeDescriptor) {
+ if (this.attributeDescriptor && this.attributeValueDescriptor) {
this._attributeDescriptor = this.attributeDescriptor;
- } else if (this.attribute || this.attributeRef) {
- const attrName = this.attribute ? this.attribute.name! : this.attributeRef!.attributeName!;
- this._attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(attrName, this.assetType);
- }
-
- if (this.attribute) {
- this._attributeValueDescriptor = AssetModelUtil.getAttributeValueDescriptorFromAsset(this.attribute ? this.attribute.type as string : undefined, this.assetType, this._attributeDescriptor ? this._attributeDescriptor!.attributeName : undefined);
- } else if (this.attributeValueDescriptor) {
this._attributeValueDescriptor = this.attributeValueDescriptor;
- } else if (this._attributeDescriptor) {
- this._attributeValueDescriptor = this._attributeDescriptor.valueDescriptor;
+ } else {
+ const attributeOrDescriptorOrName = this.attributeDescriptor || this.attribute ? this.attribute : this.attributeRef ? this.attributeRef.attributeName! : undefined;
+
+ if (!attributeOrDescriptorOrName) {
+ this._attributeDescriptor = this.attributeDescriptor;
+ this._attributeValueDescriptor = this.attributeValueDescriptor;
+ } else {
+ const attributeAndValueDescriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assetType, attributeOrDescriptorOrName);
+ this._attributeDescriptor = attributeAndValueDescriptors[0];
+ this._attributeValueDescriptor = this.attributeValueDescriptor ? this._attributeValueDescriptor : attributeAndValueDescriptors[1];
+ }
}
this._updateTemplate();
@@ -524,7 +526,12 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
this._max = Util.getMetaValue(MetaItemType.RANGE_MAX, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor) as number;
this._unit = Util.getMetaValue(MetaItemType.UNIT_TYPE, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor) as string;
this._step = Util.getMetaValue(MetaItemType.STEP, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor) as number;
- this._label = this.label !== undefined ? this.label : Util.getAttributeLabel(this.attribute, this._attributeDescriptor) + (this._unit ? " (" + i18next.t(this._unit) + ")" : "");
+ if (this.label) {
+ this._label = this.label;
+ } else {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assetType, this.attribute || this._attributeDescriptor);
+ this._label = Util.getAttributeLabel(this.attribute, descriptors[0], descriptors[1], true);
+ }
this._readonly = this.readonly !== undefined ? this.readonly : Util.getMetaValue(MetaItemType.READ_ONLY, this.attribute, this._attributeDescriptor);
this._disabled = this.disabled;
this._options = Util.getMetaValue(MetaItemType.ALLOWED_VALUES, this.attribute, this._attributeDescriptor);
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index b36c5064b..c65a2766a 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -498,11 +498,8 @@ export class OrChart extends translate(i18next)(LitElement) {
${this.assetAttributes && this.assetAttributes.map((attr, index) => {
const attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(attr.name!);
- let label = Util.getAttributeLabel(attr, attributeDescriptor);
- let unit = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor);
- if(unit) {
- label = label + " ("+i18next.t(unit)+")";
- }
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assets[index]!.type, attr);
+ const label = Util.getAttributeLabel(attr, descriptors[0], descriptors[1], true);
const bgColor = Util.getMetaValue('color', attr, undefined) ? Util.getMetaValue('color', attr, undefined) : "";
return html`
<div class="attribute-list-item" @mouseover="${()=> this.addDatasetHighlight(bgColor)}" @mouseout="${()=> this.removeDatasetHighlight(bgColor)}">
@@ -856,7 +853,11 @@ export class OrChart extends translate(i18next)(LitElement) {
attributes = attributes
.filter((attr: AssetAttribute) => Util.getFirstMetaItem(attr, MetaItemType.STORE_DATA_POINTS.urn!))
.filter((attr: AssetAttribute) => (this.assetAttributes && !this.assetAttributes.some(assetAttr => (assetAttr.name === attr.name) && (assetAttr.assetId === attr.assetId))));
- const options = attributes.map((attr: AssetAttribute) => [attr.name, Util.getAttributeLabel(attr, undefined)]);
+ const options = attributes.map((attr: AssetAttribute) => {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.activeAsset!.type, attr);
+ const label = Util.getAttributeLabel(attr, descriptors[0], descriptors[1], false);
+ return [attr.name, label];
+ });
return options
}
}
@@ -912,9 +913,11 @@ export class OrChart extends translate(i18next)(LitElement) {
const dataset = {...datasetBases[index],
data: valuepoints
};
- if(this.assets[index])
- dataset['label'] = this.assets[index]!.name +" "+ Util.getAttributeLabel(attribute, undefined);
-
+ if(this.assets[index]) {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assets[index]!.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ dataset["label"] = this.assets[index]!.name + " " + label;
+ }
return dataset;
});
@@ -923,15 +926,18 @@ export class OrChart extends translate(i18next)(LitElement) {
this._baseData = [...completed];
}));
- let predictedData = this.assetAttributes.map(async (attribute, index) => {
+ const predictedData = this.assetAttributes.map(async (attribute, index) => {
const valuepoints = await this._loadPredictedAttributeData(attribute, this.timestamp);
const dataset = {...datasetBases[index],
data: valuepoints,
borderDash: [2, 4]
};
- if(this.assets[index])
- dataset['label'] = this.assets[index]!.name +" "+ Util.getAttributeLabel(attribute, undefined)+" "+i18next.t("predicted");
+ if(this.assets[index]) {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assets[index]!.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ dataset["label"] = this.assets[index]!.name + " " + label + " " + i18next.t("predicted");
+ }
return dataset;
});
@@ -945,8 +951,11 @@ export class OrChart extends translate(i18next)(LitElement) {
borderDash: [10, 10]
};
- if(this.assets[index])
- dataset['label'] = this.assets[index]!.name +" "+ Util.getAttributeLabel(attribute, undefined)+" "+i18next.t("compare");
+ if(this.assets[index]) {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assets[index]!.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ dataset["label"] = this.assets[index]!.name + " " + label + " " + i18next.t("compare");
+ }
return dataset;
});
@@ -957,8 +966,11 @@ export class OrChart extends translate(i18next)(LitElement) {
data: valuepoints,
borderDash: [2, 4]
};
- if(this.assets[index])
- dataset['label'] = this.assets[index]!.name +" "+ Util.getAttributeLabel(attribute, undefined)+" "+i18next.t("compare")+" "+i18next.t("predicted")
+ if(this.assets[index]) {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assets[index]!.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ dataset["label"] = this.assets[index]!.name + " " + label + " " + i18next.t("compare") + " " + i18next.t("predicted");
+ }
return dataset;
});
diff --git a/ui/component/or-map/src/or-map-asset-card.ts b/ui/component/or-map/src/or-map-asset-card.ts
index 1ab86e073..d66ada4d4 100644
--- a/ui/component/or-map/src/or-map-asset-card.ts
+++ b/ui/component/or-map/src/or-map-asset-card.ts
@@ -159,13 +159,8 @@ export class OrMapAssetCard extends subscribe(manager)(LitElement) {
<div id="attribute-list">
<ul>
${attrs.map((attr) => {
- const attributeDescriptor: AttributeDescriptor | undefined = AssetModelUtil.getAttributeDescriptorFromAsset(attr.name!);
- let label = Util.getAttributeLabel(attr, attributeDescriptor);
- const unit = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor);
-
- if (unit) {
- label = label + " (" + i18next.t(unit) + ")";
- }
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.asset!.type, attr);
+ const label = Util.getAttributeLabel(attr, descriptors[0], descriptors[1], true);
return html`<li><span class="attribute-name">${label}</span><span class="attribute-value"><or-attribute-field .attribute="${attr}"></or-attribute-field></span></li>`;
})}
</ul>
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts b/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts
index aa988d777..3cf927348 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts
@@ -116,13 +116,18 @@ export class OrRuleActionAttribute extends translate(i18next)(LitElement) {
if (asset) {
attributes = Util.getAssetAttributes(asset).filter((attr) => !Util.hasMetaItem(attr, MetaItemType.READ_ONLY.urn!))
.map((attr) => {
- const attrDescriptor = AssetModelUtil.getAssetAttributeDescriptor(assetDescriptor, attr.name);
- return [attr.name!, Util.getAttributeLabel(attr, attrDescriptor)];
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ return [attr.name!, label];
});
} else {
attributes = !assetDescriptor || !assetDescriptor.attributeDescriptors ? []
: assetDescriptor.attributeDescriptors.filter((ad) => !AssetModelUtil.hasMetaItem(ad, MetaItemType.READ_ONLY.urn!))
- .map((ad) => [ad.attributeName!, Util.getAttributeLabel(undefined, ad)]);
+ .map((ad) => {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset!.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ return [ad.attributeName!, label];
+ });
}
let attributeInput: TemplateResult | undefined;
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
index 472211433..a243aa8e2 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
@@ -152,13 +152,18 @@ export class OrRuleAssetQuery extends translate(i18next)(LitElement) {
attributes = Util.getAssetAttributes(asset)
.filter((attr) => Util.hasMetaItem(attr, MetaItemType.RULE_STATE.urn!))
.map((attr) => {
- const attrDescriptor = AssetModelUtil.getAssetAttributeDescriptor(assetDescriptor, attr.name);
- return [attr.name!, Util.getAttributeLabel(attr, attrDescriptor)];
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ return [attr.name!, label];
});
} else {
attributes = !assetDescriptor || !assetDescriptor.attributeDescriptors ? []
: assetDescriptor.attributeDescriptors
- .map((ad) => [ad.attributeName!, Util.getAttributeLabel(undefined, ad)]);
+ .map((ad) => {
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset!.type, attribute);
+ const label = Util.getAttributeLabel(attribute, descriptors[0], descriptors[1], false);
+ return [ad.attributeName!, label];
+ });
}
const operators = this.getOperators(assetDescriptor, attribute, attributeName);