Skip to content

armgit / core

Public Imported from GitHub
0

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

Introduced unit type constants

Rich Turner47e5f01f55cd
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 c15bee9bc..0515768bf 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
@@ -20,6 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.Constants;
import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.value.Value;
@@ -29,6 +30,8 @@ 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_TIME_MINUTES;
import static org.openremote.model.attribute.MetaItemType.UNIT_TYPE;
public class ThermostatProcessor extends FeatureProcessor {
@@ -140,27 +143,27 @@ public class ThermostatProcessor extends FeatureProcessor {
new PropertyDescriptor("tempAlarm3", "Temp Alarm 3", "TEMP_ALARM3", AttributeValueType.STRING, true),
new PropertyDescriptor("tempAlarm4", "Temp Alarm 4", "TEMP_ALARM4", AttributeValueType.STRING, true),
new PropertyDescriptor("tempState", "Thermostat State", "TEMP_STATE", AttributeValueType.STRING),
- new PropertyDescriptor("tempStateDisable", "Thermostat Disable (s)", "TEMP_STATE_DISABLE_SECONDS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("SECONDS"))),
+ new PropertyDescriptor("tempStateDisable", "Thermostat Disable (s)", "TEMP_STATE_DISABLE_SECONDS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
// Get current mode or set mode until next program step
new PropertyDescriptor("tempMode", "Thermostat Mode", "TEMP_MODE", AttributeValueType.STRING),
// MINS VALUE: 0 = Until next program step, -1 = Permanent, 1-65279 = for N mins
- new PropertyDescriptor("coolComfortMins", "Thermostat Cool Comfort (mins)", "TEMP_MODE_COOL_COMFORT_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("coolDayMins", "Cool Day (mins)", "TEMP_MODE_COOL_DAY_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("coolNightMins", "Cool Night (mins)", "TEMP_MODE_COOL_NIGHT_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("coolSafeMins", "Cool Safe (mins)", "TEMP_MODE_COOL_SAFE_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("heatComfortMins", "Heat Comfort (mins)", "TEMP_MODE_HEAT_COMFORT_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("heatDayMins", "Heat Day (mins)", "TEMP_MODE_HEAT_DAY_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("heatNightMins", "Heat Night (mins)", "TEMP_MODE_HEAT_NIGHT_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("heatSafeMins", "Heat Safe (mins)", "TEMP_MODE_HEAT_SAFE_MINS", AttributeValueType.TIME.withUnitType(UNIT_TYPE.withInitialValue("MINUTES"))),
- new PropertyDescriptor("tempTargetCurrent", "Temp Target Current", "TEMP_TARGET_CURRENT", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetCoolComfort", "Temp Target Cool Comfort", "TEMP_TARGET_COOL_COMFORT", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetCoolDay", "Temp Target Cool Day", "TEMP_TARGET_COOL_DAY", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetCoolNight", "Temp Target Cool Night", "TEMP_TARGET_COOL_NIGHT", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetCoolSafe", "Temp Target Cool Safe", "TEMP_TARGET_COOL_SAFE", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetHeatComfort", "Temp Target Heat Comfort", "TEMP_TARGET_HEAT_COMFORT", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetHeatDay", "Temp Target Heat Day", "TEMP_TARGET_HEAT_DAY", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetHeatNight", "Temp Target Heat Night", "TEMP_TARGET_HEAT_NIGHT", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS"))),
- new PropertyDescriptor("tempTargetHeatSafe", "Temp Target Heat Safe", "TEMP_TARGET_HEAT_SAFE", AttributeValueType.TEMPERATURE.withUnitType(UNIT_TYPE.withInitialValue("CELCIUS")))
+ new PropertyDescriptor("coolComfortMins", "Thermostat Cool Comfort (mins)", "TEMP_MODE_COOL_COMFORT_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("coolDayMins", "Cool Day (mins)", "TEMP_MODE_COOL_DAY_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("coolNightMins", "Cool Night (mins)", "TEMP_MODE_COOL_NIGHT_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("coolSafeMins", "Cool Safe (mins)", "TEMP_MODE_COOL_SAFE_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("heatComfortMins", "Heat Comfort (mins)", "TEMP_MODE_HEAT_COMFORT_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("heatDayMins", "Heat Day (mins)", "TEMP_MODE_HEAT_DAY_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("heatNightMins", "Heat Night (mins)", "TEMP_MODE_HEAT_NIGHT_MINS", AttributeValueType.TIME.withUnitType(UNITS_TIME_MINUTES)),
+ new PropertyDescriptor("heatSafeMins", "Heat Safe (mins)", "TEMP_MODE_HEAT_SAFE_MINS", AttributeValueType.TIME.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))
);
@Override
diff --git a/model/src/main/java/org/openremote/model/Constants.java b/model/src/main/java/org/openremote/model/Constants.java
index 0b532b69c..1a399832c 100644
--- a/model/src/main/java/org/openremote/model/Constants.java
+++ b/model/src/main/java/org/openremote/model/Constants.java
@@ -63,4 +63,7 @@ public interface Constants {
String SETUP_EMAIL_FROM = "SETUP_EMAIL_FROM";
String SETUP_EMAIL_FROM_DEFAULT = "[email protected]";
String REQUEST_HEADER_REALM = "Auth-Realm";
+
+ String UNITS_TEMPERATURE_CELCIUS = "CELCIUS";
+ String UNITS_TIME_MINUTES = "MINUTES";
}
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 f6dfdc8c6..e39a7c458 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
@@ -217,7 +217,8 @@ public enum AttributeValueType implements AttributeValueDescriptor {
return Optional.ofNullable(validator);
}
- public AttributeValueDescriptor withUnitType(MetaItemDescriptor unitType) {
+ public AttributeValueDescriptor withUnitType(String units) {
+ MetaItemDescriptor unitType = UNIT_TYPE.withInitialValue(units);
if (unitType.getUrn().equals(UNIT_TYPE.getUrn())) {
return new AttributeValueDescriptorImpl(getName(), getIcon(), getValueType(), new MetaItemDescriptor[]{unitType});
} else {
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index f621c36bb..fe183bd8f 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -571,7 +571,6 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
this._loading = false;
}
-
protected _getPanelConfig(asset: Asset): AssetViewerConfig {
let config = {...OrAssetViewer.DEFAULT_CONFIG};
@@ -579,8 +578,6 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
config.viewerStyles = {...config.viewerStyles};
config.panels = {...config.panels};
- config.viewerStyles = { ...config.viewerStyles };
- config.panels = { ...config.panels };
const assetConfig = this.config.assetTypes && this.config.assetTypes.hasOwnProperty(asset.type!) ? this.config.assetTypes[asset.type!] : this.config.default;
if (assetConfig) {