Permalink
Browse files

Added new AttributeType POWER_PERCENTAGE

  • Loading branch information...
richturner committed Sep 12, 2018
1 parent f80ac7c commit d6ef48feadf93fc615e039d74edf8d7e21a611dd
@@ -230,6 +230,7 @@ attributeValueType[RAINFALL]=Rainfall millimetres per hour
attributeValueType[BRIGHTNESS_LUX]=Lux brightness
attributeValueType[DIRECTION_DECIMAL_DEGREES]=Direction in decimal degrees
attributeValueType[GEO_JSON_POINT]=Coordinates
attributeValueType[POWER_PERCENTAGE]=Power Percentage
validationFailureOnAttribute=Attribute error on ''{0}''
validationFailureOnMetaItem=Meta item error on ''{0}'' meta item ''{1}''
validationFailure=Unknown validation failure.
@@ -22,7 +22,6 @@
import org.openremote.model.ValidationFailure;
import org.openremote.model.ValueHolder;
import org.openremote.model.asset.AssetMeta;
import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
import org.openremote.model.value.Values;
@@ -57,28 +56,28 @@
RULES_TEMPLATE_FILTER("filter", ValueType.ARRAY, value -> Optional.empty()),
PERCENTAGE("percent", ValueType.NUMBER,
value -> Values.getNumber(value)
.filter(number -> number < 0 || number > 100)
.map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
new MetaItem(AssetMeta.FORMAT, Values.create("%3d %%"))
value -> Values.getNumber(value)
.filter(number -> number < 0 || number > 100)
.map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
new MetaItem(AssetMeta.FORMAT, Values.create("%3d %%"))
),
TIMESTAMP_MILLIS("clock-o", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%d ms"))
new MetaItem(FORMAT, Values.create("%d ms"))
),
TIMESTAMP_SECONDS("clock-o", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%d s"))
new MetaItem(FORMAT, Values.create("%d s"))
),
TIME_SECONDS("clock-o", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.1f s"))
new MetaItem(FORMAT, Values.create("%0.1f s"))
),
TIME_MINUTES("clock-o", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.1f min"))
new MetaItem(FORMAT, Values.create("%0.1f min"))
),
DATETIME("calendar", ValueType.STRING, value -> Optional.empty()),
@@ -101,8 +100,8 @@
TEMPERATURE_CELCIUS("thermometer", ValueType.NUMBER, value -> Values.getNumber(value)
.filter(n -> n < -273.15)
.map(n -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_TEMPERATURE_OUT_OF_RANGE)),
new MetaItem(FORMAT, Values.create("%0.1f C")
)
new MetaItem(FORMAT, Values.create("%0.1f C")
)
),
TEMPERATURE_KELVIN("thermometer", ValueType.NUMBER, value -> Values.getNumber(value)
@@ -116,117 +115,124 @@
),
RAINFALL("tint", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.1f mm/h"))
new MetaItem(FORMAT, Values.create("%0.1f mm/h"))
),
BRIGHTNESS_LUX("sun-o", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%d lx"))
new MetaItem(FORMAT, Values.create("%d lx"))
),
DISTANCE_M("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f m"))
new MetaItem(FORMAT, Values.create("%0.5f m"))
),
DISTANCE_CM("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f cm"))
new MetaItem(FORMAT, Values.create("%0.5f cm"))
),
DISTANCE_MM("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f mm"))
new MetaItem(FORMAT, Values.create("%0.5f mm"))
),
DISTANCE_IN("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f \""))
new MetaItem(FORMAT, Values.create("%0.5f \""))
),
DISTANCE_FT("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f '"))
new MetaItem(FORMAT, Values.create("%0.5f '"))
),
DISTANCE_YARD("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f yd"))
new MetaItem(FORMAT, Values.create("%0.5f yd"))
),
SPEED_MS("rocket", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.3f m/s"))
new MetaItem(FORMAT, Values.create("%0.3f m/s"))
),
SPEED_KPH("rocket", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.1f km/h"))
new MetaItem(FORMAT, Values.create("%0.1f km/h"))
),
SPEED_MPH("rocket", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.1f mi/h"))
new MetaItem(FORMAT, Values.create("%0.1f mi/h"))
),
CO2_PPM("leaf", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%4d ppm"))
new MetaItem(FORMAT, Values.create("%4d ppm"))
),
HUMIDITY_PERCENTAGE("tint", ValueType.NUMBER, value -> Values.getNumber(value)
.filter(number -> number < 0 || number > 100)
.map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
new MetaItem(FORMAT, Values.create("%3d %%"))
new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
new MetaItem(FORMAT, Values.create("%3d %%"))
),
HUMIDITY_GPCM("tint", ValueType.NUMBER, value -> Optional.empty()),
POWER_WATT("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f W"))
new MetaItem(FORMAT, Values.create("%0.5f W"))
),
POWER_KILOWATT("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f KW"))),
new MetaItem(FORMAT, Values.create("%0.5f KW"))
),
POWER_MEGAWATT("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f MW"))),
new MetaItem(FORMAT, Values.create("%0.5f MW"))
),
POWER_PERCENTAGE("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%3d %%"))
),
CHARGE_PERCENTAGE("battery-full", ValueType.NUMBER, value -> Values.getNumber(value)
.filter(number -> number < 0 || number > 100)
.map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
new MetaItem(FORMAT, Values.create("%3d %%"))
new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
new MetaItem(FORMAT, Values.create("%3d %%"))
),
CHARGE_KWH("battery-full", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f KWh"))),
new MetaItem(FORMAT, Values.create("%0.5f KWh"))
),
ENERGY_KWH("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f KWh"))
new MetaItem(FORMAT, Values.create("%0.5f KWh"))
),
ENERGY_JOULE("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f J"))
new MetaItem(FORMAT, Values.create("%0.5f J"))
),
ENERGY_MEGAJOULE("plug", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f MJ"))),
new MetaItem(FORMAT, Values.create("%0.5f MJ"))),
FLOW_LPM("tachometer", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f l/m"))
new MetaItem(FORMAT, Values.create("%0.5f l/m"))
),
FLOW_CMPS("tachometer", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f m³/s"))
new MetaItem(FORMAT, Values.create("%0.5f m³/s"))
),
FLOW_SCCM("tachometer", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f cm³/m"))
new MetaItem(FORMAT, Values.create("%0.5f cm³/m"))
),
FLOW_CFPS("tachometer", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f cfs"))
new MetaItem(FORMAT, Values.create("%0.5f cfs"))
),
FLOW_GPM("tachometer", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.5f gpm"))
new MetaItem(FORMAT, Values.create("%0.5f gpm"))
),
DIRECTION_DECIMAL_DEGREES("compass", ValueType.NUMBER, value -> Optional.empty(),
new MetaItem(FORMAT, Values.create("%0.1f deg"))
new MetaItem(FORMAT, Values.create("%0.1f deg"))
),
GEO_JSON_POINT("map-marker", ValueType.OBJECT, value -> Optional.empty());

0 comments on commit d6ef48f

Please sign in to comment.