100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Rule state is now opt out on all attributes (will need to monitor performance)
Rich Turner0084b5e60e8d
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.javaindex 3acc74982..f1405a7b1 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java@@ -22,9 +22,6 @@ package org.openremote.manager.asset;import org.apache.camel.Exchange;import org.apache.camel.Processor;import org.apache.camel.builder.RouteBuilder;-import org.openremote.model.asset.agent.Protocol;-import org.openremote.model.Container;-import org.openremote.model.ContainerService;import org.openremote.container.message.MessageBrokerService;import org.openremote.container.persistence.PersistenceService;import org.openremote.container.security.AuthContext;@@ -37,9 +34,16 @@ import org.openremote.manager.gateway.GatewayService;import org.openremote.manager.rules.RulesService;import org.openremote.manager.security.ManagerIdentityService;import org.openremote.model.Constants;-import org.openremote.model.attribute.*;-import org.openremote.model.asset.*;+import org.openremote.model.Container;+import org.openremote.model.ContainerService;+import org.openremote.model.asset.Asset;+import org.openremote.model.asset.AssetResource;+import org.openremote.model.asset.agent.Protocol;+import org.openremote.model.attribute.Attribute;+import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.attribute.AttributeEvent.Source;+import org.openremote.model.attribute.AttributeExecuteStatus;+import org.openremote.model.attribute.MetaItem;import org.openremote.model.security.ClientRole;import org.openremote.model.value.MetaItemType;import org.openremote.model.value.ValueType;@@ -113,19 +117,19 @@ import static org.openremote.model.value.MetaItemType.AGENT_LINK;* successful.* <h2>Asset Datapoint Service processing logic</h2>* <p>- * Checks if attribute has {@link MetaItemType#STORE_DATA_POINTS} {@link MetaItem}, and if so the {@link AttributeEvent}- * is stored in a time series of historical data. Then allows the message to continue if the commit was successful.+ * Checks if attribute has {@link MetaItemType#STORE_DATA_POINTS} set to false, and if so the {@link AttributeEvent}+ * is not stored in a time series DB of historical data, otherwise the value is stored. Then allows the message to+ * continue if the commit was successful.*/@SuppressWarnings("unchecked")public class AssetProcessingService extends RouteBuilder implements ContainerService {public static final int PRIORITY = AssetStorageService.PRIORITY + 1000;- private static final Logger LOG = Logger.getLogger(AssetProcessingService.class.getName());-// TODO: Some of these options should be configurable depending on expected load etc.// Message topic for communicating individual asset attribute changespublic static final String ASSET_QUEUE = "seda://AssetQueue?waitForTaskToComplete=IfReplyExpected&timeout=10000&purgeWhenStopping=true&discardIfNoConsumers=false&size=25000";-+ private static final Logger LOG = Logger.getLogger(AssetProcessingService.class.getName());+ final protected List<AssetUpdateProcessor> processors = new ArrayList<>();protected TimerService timerService;protected ManagerIdentityService identityService;protected PersistenceService persistenceService;@@ -140,7 +144,38 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer// Used in testing to detect if initial/startup processing has completedprotected long lastProcessedEventTimestamp = System.currentTimeMillis();- final protected List<AssetUpdateProcessor> processors = new ArrayList<>();+ protected static Processor handleAssetProcessingException(Logger logger) {+ return exchange -> {+ AttributeEvent event = exchange.getIn().getBody(AttributeEvent.class);+ Exception exception = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);++ StringBuilder error = new StringBuilder();++ Source source = exchange.getIn().getHeader(HEADER_SOURCE, "unknown source", Source.class);+ if (source != null) {+ error.append("Error processing from ").append(source);+ }++ String protocolName = exchange.getIn().getHeader(Protocol.SENSOR_QUEUE_SOURCE_PROTOCOL, String.class);+ if (protocolName != null) {+ error.append(" (protocol: ").append(protocolName).append(")");+ }++ // TODO Better exception handling - dead letter queue?+ if (exception instanceof AssetProcessingException) {+ AssetProcessingException processingException = (AssetProcessingException) exception;+ error.append(" - ").append(processingException.getMessage());+ error.append(": ").append(event.toString());+ logger.warning(error.toString());+ } else {+ error.append(": ").append(event.toString());+ logger.log(Level.WARNING, error.toString(), exception);+ }++ // Make the exception available if MEP is InOut+ exchange.getOut().setBody(exception);+ };+ }@Overridepublic int getPriority() {@@ -275,7 +310,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer} else {// Check realm, must be accessibleif (!identityService.getIdentityProvider().isTenantActiveAndAccessible(authContext,- asset.getRealm())) {+ asset.getRealm())) {throw new AssetProcessingException(INSUFFICIENT_ACCESS);}@@ -286,7 +321,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer// Regular user must have write attributes roleif (!authContext.hasResourceRoleOrIsSuperUser(ClientRole.WRITE_ATTRIBUTES.getValue(),- Constants.KEYCLOAK_CLIENT_ID)) {+ Constants.KEYCLOAK_CLIENT_ID)) {throw new AssetProcessingException(INSUFFICIENT_ACCESS);}@@ -294,7 +329,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSerif (identityService.getIdentityProvider().isRestrictedUser(authContext.getUserId())) {// Must be asset linked to userif (!assetStorageService.isUserAsset(authContext.getUserId(),- event.getAssetId())) {+ event.getAssetId())) {throw new AssetProcessingException(INSUFFICIENT_ACCESS);}// Must be writable by restricted client@@ -307,7 +342,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSercase SENSOR:Optional<Protocol<?>> protocol = oldAttribute.getMetaValue(AGENT_LINK)- .map(agentLink -> agentService.getProtocolInstance(agentLink.getId()));+ .map(agentLink -> agentService.getProtocolInstance(agentLink.getId()));// Sensor event must be for an attribute linked to an agentif (!protocol.isPresent()) {@@ -413,17 +448,17 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer}/**- * This deals with single {@link Attribute} updates and pushes them through the chain where each- * processor is given the opportunity to completely consume the update or allow its progress to the next- * processor, see {@link AssetUpdateProcessor#processAssetUpdate}. If no processor completely consumed the- * update, the attribute will be stored in the database.+ * This deals with single {@link Attribute} updates and pushes them through the chain where each processor is given+ * the opportunity to completely consume the update or allow its progress to the next processor, see {@link+ * AssetUpdateProcessor#processAssetUpdate}. If no processor completely consumed the update, the attribute will be+ * stored in the database.*/protected boolean processAssetUpdate(EntityManager em,Asset<?> asset,Attribute<?> attribute,Source source) throws AssetProcessingException {- String attributeStr = "Asset ID=" + asset.getId() + ", Asset name=" +asset.getName() + ", " + attribute;+ String attributeStr = "Asset ID=" + asset.getId() + ", Asset name=" + asset.getName() + ", " + attribute;LOG.fine(">>> Processing start: " + attributeStr);@@ -463,39 +498,6 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSerreturn complete;}- protected static Processor handleAssetProcessingException(Logger logger) {- return exchange -> {- AttributeEvent event = exchange.getIn().getBody(AttributeEvent.class);- Exception exception = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);-- StringBuilder error = new StringBuilder();-- Source source = exchange.getIn().getHeader(HEADER_SOURCE, "unknown source", Source.class);- if (source != null) {- error.append("Error processing from ").append(source);- }-- String protocolName = exchange.getIn().getHeader(Protocol.SENSOR_QUEUE_SOURCE_PROTOCOL, String.class);- if (protocolName != null) {- error.append(" (protocol: ").append(protocolName).append(")");- }-- // TODO Better exception handling - dead letter queue?- if (exception instanceof AssetProcessingException) {- AssetProcessingException processingException = (AssetProcessingException) exception;- error.append(" - ").append(processingException.getMessage());- error.append(": ").append(event.toString());- logger.warning(error.toString());- } else {- error.append(": ").append(event.toString());- logger.log(Level.WARNING, error.toString(), exception);- }-- // Make the exception available if MEP is InOut- exchange.getOut().setBody(exception);- };- }-protected void storeAttributeValue(EntityManager em, Asset<?> asset, Attribute<?> attribute) throws AssetProcessingException {if (!assetStorageService.updateAttributeValue(em, asset, attribute)) {diff --git a/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.javaindex 5c5bbc907..d71086d3f 100644--- a/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java@@ -122,8 +122,6 @@ public class ConsoleResourceImpl extends ManagerWebResource implements ConsoleRepublic static ConsoleAsset initConsoleAsset(ConsoleRegistration consoleRegistration, boolean allowPublicLocationWrite, boolean allowRestrictedLocationWrite) {ConsoleAsset consoleAsset = new ConsoleAsset(consoleRegistration.getName());- consoleAsset.getAttributes().getOrCreate(Asset.LOCATION).addOrReplaceMeta(new MetaItem<>(RULE_STATE));-if (allowPublicLocationWrite) {consoleAsset.getAttributes().getOrCreate(Asset.LOCATION).addOrReplaceMeta(new MetaItem<>(ACCESS_PUBLIC_WRITE, true));}diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.javaindex 4b13f4f40..f5742d89e 100644--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java@@ -341,19 +341,14 @@ public class AssetDatapointService implements ContainerService, AssetUpdateProcenew AssetQuery().attributes(new AttributePredicate().meta(- new NameValuePredicate(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, null)- ),- new AttributePredicate().meta(- new NameValuePredicate(STORE_DATA_POINTS, null)- ))+ new NameValuePredicate(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, null)+ )).select(AssetQuery.Select.selectExcludePathAndParentInfo()));List<Pair<String, Attribute<?>>> attributes = assets.stream().map(asset -> asset.getAttributes().stream()- .filter(assetAttribute ->- assetAttribute.getMetaValue(STORE_DATA_POINTS).orElse(false)- && assetAttribute.hasMeta(MetaItemType.DATA_POINTS_MAX_AGE_DAYS))+ .filter(assetAttribute -> assetAttribute.hasMeta(MetaItemType.DATA_POINTS_MAX_AGE_DAYS)).map(assetAttribute -> new Pair<String, Attribute<?>>(asset.getId(), assetAttribute)).collect(toList())).flatMap(List::stream)diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.javaindex 3304b2620..76980f397 100644--- a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java+++ b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java@@ -37,7 +37,6 @@ import org.openremote.model.query.filter.LocationAttributePredicate;import org.openremote.model.rules.*;import org.openremote.model.syslog.SyslogCategory;import org.openremote.model.util.TextUtil;-import org.openremote.model.value.MetaItemType;import java.util.*;import java.util.concurrent.ScheduledExecutorService;@@ -98,11 +97,9 @@ public class RulesEngine<T extends Ruleset> {// Separate logger for periodic stats printerpublic static final Logger STATS_LOG = Logger.getLogger("org.openremote.rules.RulesEngineStats");-+ protected static BiConsumer<RulesEngine<?>, RulesetDeployment> UNPAUSE_SCHEDULER = RulesEngine::scheduleUnpause;// Here to facilitate testingprotected static BiConsumer<RulesEngine<?>, RulesetDeployment> PAUSE_SCHEDULER = RulesEngine::schedulePause;- protected static BiConsumer<RulesEngine<?>, RulesetDeployment> UNPAUSE_SCHEDULER = RulesEngine::scheduleUnpause;-final protected TimerService timerService;final protected ScheduledExecutorService executorService;final protected AssetStorageService assetStorageService;@@ -356,6 +353,7 @@ public class RulesEngine<T extends Ruleset> {}}}+public void stop() {stop(false);}@@ -602,8 +600,7 @@ public class RulesEngine<T extends Ruleset> {}/**- * This is called with all the asset's that have a location attribute marked with {@link MetaItemType#RULE_STATE} and- * that are in the scope of a rule containing a location predicate.+ * This is called with all the asset's that have a location attribute currently loaded into this engine.*/protected void processLocationRules(List<AssetStateLocationPredicates> assetStateLocationPredicates) {if (assetLocationPredicatesConsumer != null) {@@ -667,7 +664,7 @@ public class RulesEngine<T extends Ruleset> {protected void schedulePause(RulesetDeployment deployment) {long delay = deployment.getValidTo() - timerService.getCurrentTimeMillis();- LOG.info("Scheduling pause of ruleset at '" + new Date(deployment.getValidTo()).toString() + "' ("+ delay + "ms): " + deployment.ruleset.getName());+ LOG.info("Scheduling pause of ruleset at '" + new Date(deployment.getValidTo()).toString() + "' (" + delay + "ms): " + deployment.ruleset.getName());pauseTimers.put(deployment.getId(), executorService.schedule(() -> pauseRuleset(deployment), delay, TimeUnit.MILLISECONDS));}@@ -697,7 +694,7 @@ public class RulesEngine<T extends Ruleset> {protected void scheduleUnpause(RulesetDeployment deployment) {long delay = deployment.getValidFrom() - timerService.getCurrentTimeMillis();- LOG.info("Scheduling un-pause of ruleset at '" + new Date(deployment.getValidFrom()).toString() + "' ("+ delay + "ms): " + deployment.ruleset.getName());+ LOG.info("Scheduling un-pause of ruleset at '" + new Date(deployment.getValidFrom()).toString() + "' (" + delay + "ms): " + deployment.ruleset.getName());unpauseTimers.put(deployment.getId(), executorService.schedule(() -> unPauseRuleset(deployment), delay, TimeUnit.MILLISECONDS));}diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesService.java b/manager/src/main/java/org/openremote/manager/rules/RulesService.javaindex e7e84914a..8d46abf46 100644--- a/manager/src/main/java/org/openremote/manager/rules/RulesService.java+++ b/manager/src/main/java/org/openremote/manager/rules/RulesService.java@@ -47,10 +47,7 @@ import org.openremote.model.attribute.AttributeEvent.Source;import org.openremote.model.attribute.AttributeMap;import org.openremote.model.query.AssetQuery;import org.openremote.model.query.RulesetQuery;-import org.openremote.model.query.filter.AttributePredicate;-import org.openremote.model.query.filter.BooleanPredicate;import org.openremote.model.query.filter.LocationAttributePredicate;-import org.openremote.model.query.filter.NameValuePredicate;import org.openremote.model.rules.*;import org.openremote.model.rules.geofence.GeofenceDefinition;import org.openremote.model.security.ClientRole;@@ -82,7 +79,7 @@ import static org.openremote.model.value.MetaItemType.RULE_STATE;/*** Manages {@link RulesEngine}s for stored {@link Ruleset}s and processes asset attribute updates.* <p>- * If an updated attribute's {@link MetaItemType#RULE_STATE} is true, this implementation of {@link+ * If an updated attribute doesn't have meta {@link MetaItemType#RULE_STATE} is false, this implementation of {@link* AssetUpdateProcessor} converts the update message to an {@link AssetState} fact. This service keeps the facts and* thus the state of rule facts are in sync with the asset state changes that occur. If an asset attribute value* changes, the {@link AssetState} in the rules engines will be updated to reflect the change.@@ -341,7 +338,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse// We might process two facts for a single attribute update, if that is what the user wants// First as asset state- if (attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(false)) {+ if (attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(true)) {updateAssetState(new AssetState<>(asset, attribute, source));}@@ -463,11 +460,11 @@ public class RulesService extends RouteBuilder implements ContainerService, Asseswitch (persistenceEvent.getCause()) {case CREATE: {- // New asset has been created so get attributes that have RULE_STATE meta+ // New asset has been created so get attributes that don't have RULE_STATE=false metaList<Attribute<?>> ruleStateAttributes = asset.getAttributes().stream()- .filter(attribute -> attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(false)).collect(Collectors.toList());+ .filter(attribute -> attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(true)).collect(Collectors.toList());// Asset<?> used to be loaded for each attribute which is inefficientAsset<?> loadedAsset = ruleStateAttributes.isEmpty() ? null : assetStorageService.find(asset.getId(),@@ -501,12 +498,12 @@ public class RulesService extends RouteBuilder implements ContainerService, AsseList<Attribute<?>> oldStateAttributes = ((AttributeMap)persistenceEvent.getPreviousState("attributes")).stream()- .filter(attr -> attr.getMetaValue(RULE_STATE).orElse(false))+ .filter(attr -> attr.getMetaValue(RULE_STATE).orElse(true)).collect(toList());List<Attribute<?>> newStateAttributes = ((AttributeMap) persistenceEvent.getCurrentState("attributes")).stream()- .filter(attr -> attr.getMetaValue(RULE_STATE).orElse(false))+ .filter(attr -> attr.getMetaValue(RULE_STATE).orElse(true)).collect(Collectors.toList());// Retract obsolete or modified attributes@@ -531,7 +528,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Assecase DELETE:// Retract any facts that were associated with this assetasset.getAttributes().stream()- .filter(attribute -> attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(false))+ .filter(attribute -> attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(true)).forEach(attribute -> {AssetState<?> assetState = new AssetState<>(asset, attribute, Source.INTERNAL);LOG.fine("Asset was persisted (" + persistenceEvent.getCause() + "), retracting fact: " + assetState);@@ -854,24 +851,20 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse}protected Stream<Pair<Asset<?>, Stream<Attribute<?>>>> findRuleStateAttributes() {- List<Asset<?>> assets = assetStorageService.findAll(- new AssetQuery()- .attributes(- new AttributePredicate().meta(- new NameValuePredicate(MetaItemType.RULE_STATE, new BooleanPredicate(true)))));+ // Get all assets then filter out any attributes with RULE_STATE=false+ List<Asset<?>> assets = assetStorageService.findAll(new AssetQuery());return assets.stream().map(asset ->new Pair<>(asset, asset.getAttributes().stream()- .filter(attribute -> attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(false)))+ .filter(attribute -> attribute.getMetaValue(MetaItemType.RULE_STATE).orElse(true))));}/**- * Called when an engine's rules change identifying assets with location attributes marked with {@link- * MetaItemType#RULE_STATE} that also have {@link LocationAttributePredicate} in the rules. The job here is to- * identify the asset's (via {@link AssetState}) that have modified {@link LocationAttributePredicate}s and to- * notify the {@link GeofenceAssetAdapter}s.+ * Called when an engine's rules change identifying assets with location attributes that also have+ * {@link LocationAttributePredicate} in the rules. The job here is to identify the asset's (via {@link AssetState})+ * that have modified {@link LocationAttributePredicate}s and to notify the {@link GeofenceAssetAdapter}s.*/protected void onEngineLocationRulesChanged(RulesEngine<?> rulesEngine, List<RulesEngine.AssetStateLocationPredicates> newEngineAssetStateLocationPredicates) {withLock(getClass().getSimpleName() + "::onEngineLocationRulesChanged", () -> {diff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.javaindex 5a712d4d9..f144690c9 100644--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java@@ -91,33 +91,25 @@ public abstract class AbstractManagerSetup implements Setup {.addMeta(new MetaItem<>(LABEL, "Alarm enabled"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(RULE_STATE, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true)+ new MetaItem<>(ACCESS_RESTRICTED_WRITE, true)),new Attribute<>("presenceDetected", BOOLEAN).addMeta(new MetaItem<>(LABEL, "Presence detected"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true),- new MetaItem<>(STORE_DATA_POINTS, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true)+ new MetaItem<>(READ_ONLY, true)),new Attribute<>("vacationUntil", TIMESTAMP).addMeta(new MetaItem<>(LABEL, "Vacation until"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(ACCESS_RESTRICTED_WRITE, true)),new Attribute<>("lastExecutedScene", ValueType.TEXT).addMeta(new MetaItem<>(LABEL, "Last executed scene"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true)+ new MetaItem<>(READ_ONLY, true)),new Attribute<>(Asset.LOCATION, location).addMeta(new MetaItem<>(ACCESS_RESTRICTED_READ, true))@@ -128,13 +120,11 @@ public abstract class AbstractManagerSetup implements Setup {new MetaItem<>(DESCRIPTION, "Predict presence and automatically adjust scene schedule"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(RULE_STATE, true)),new Attribute<>("lastDetectedScene", ValueType.STRING).addMeta(new MetaItem<>(LABEL, "Last detected scene by rules"),new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true))*/);@@ -152,29 +142,22 @@ public abstract class AbstractManagerSetup implements Setup {new Attribute<>("motionSensor", INTEGER).addMeta(new MetaItem<>(LABEL, "Motion sensor"),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true),- new MetaItem<>(STORE_DATA_POINTS)),+ new MetaItem<>(READ_ONLY, true)),new Attribute<>("presenceDetected", BOOLEAN).addMeta(new MetaItem<>(LABEL, "Presence detected"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(STORE_DATA_POINTS, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true)+ new MetaItem<>(READ_ONLY, true)),new Attribute<>("firstPresenceDetected", TIMESTAMP).addMeta(new MetaItem<>(LABEL, "First time movement was detected"),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(READ_ONLY, true)),new Attribute<>("lastPresenceDetected", TIMESTAMP).addMeta(new MetaItem<>(LABEL, "Last time movement was detected"),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(READ_ONLY, true)));@@ -194,13 +177,10 @@ public abstract class AbstractManagerSetup implements Setup {.addMeta(new MetaItem<>(UNITS, Constants.units(UNITS_PART_PER_MILLION)),new MetaItem<>(LABEL, "CO2 level"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(RULE_EVENT, true),new MetaItem<>(RULE_EVENT_EXPIRES, "PT45M"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true),- new MetaItem<>(STORE_DATA_POINTS)+ new MetaItem<>(READ_ONLY, true)));if (shouldBeLinked) {@@ -215,14 +195,11 @@ public abstract class AbstractManagerSetup implements Setup {new Attribute<>("humidity", POSITIVE_INTEGER).addMeta(new MetaItem<>(LABEL, "Humidity"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(RULE_EVENT, true),new MetaItem<>(RULE_EVENT_EXPIRES, "PT45M"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(READ_ONLY, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true),- new MetaItem<>(UNITS, Constants.units(UNITS_PERCENTAGE)),- new MetaItem<>(STORE_DATA_POINTS)+ new MetaItem<>(UNITS, Constants.units(UNITS_PERCENTAGE))));if (shouldBeLinked) {@@ -239,13 +216,10 @@ public abstract class AbstractManagerSetup implements Setup {new Attribute<>("currentTemperature", NUMBER).addMeta(new MetaItem<>(LABEL, "Current temperature"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(READ_ONLY, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true),new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS)),- new MetaItem<>(FORMAT, ValueFormat.NUMBER_1_DP()),- new MetaItem<>(STORE_DATA_POINTS)+ new MetaItem<>(FORMAT, ValueFormat.NUMBER_1_DP())));if (shouldBeLinked) {@@ -262,13 +236,10 @@ public abstract class AbstractManagerSetup implements Setup {new Attribute<>("targetTemperature", NUMBER).addMeta(new MetaItem<>(LABEL, "Target temperature"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true),new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS)),- new MetaItem<>(FORMAT, ValueFormat.NUMBER_1_DP()),- new MetaItem<>(STORE_DATA_POINTS)+ new MetaItem<>(FORMAT, ValueFormat.NUMBER_1_DP())));if (shouldBeLinked) {@@ -296,7 +267,6 @@ public abstract class AbstractManagerSetup implements Setup {new MetaItem<>(LABEL, "Smart Switch mode " + switchName),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(RULE_EVENT, true),new MetaItem<>(RULE_EVENT_EXPIRES, "PT48H")),// Time@@ -304,28 +274,28 @@ public abstract class AbstractManagerSetup implements Setup {.addMeta(new MetaItem<>(LABEL, "Smart Switch begin/end cycle " + switchName),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(RULE_STATE, true)),+ new MetaItem<>(ACCESS_RESTRICTED_WRITE, true)+ ),// StartTimenew Attribute<>("smartSwitchStartTime" + switchName, TIMESTAMP).addMeta(new MetaItem<>(LABEL, "Smart Switch actuator earliest start time " + switchName),new MetaItem<>(READ_ONLY, true),- new MetaItem<>(UNITS, Constants.units(UNITS_SECOND)),- new MetaItem<>(RULE_STATE, true)),+ new MetaItem<>(UNITS, Constants.units(UNITS_SECOND))+ ),// StopTimenew Attribute<>("smartSwitchStopTime" + switchName, TIMESTAMP).addMeta(new MetaItem<>(LABEL, "Smart Switch actuator latest stop time " + switchName),new MetaItem<>(READ_ONLY, true),- new MetaItem<>(UNITS, Constants.units(UNITS_SECOND)),- new MetaItem<>(RULE_STATE, true)),+ new MetaItem<>(UNITS, Constants.units(UNITS_SECOND))+ ),// Enablednew Attribute<>("smartSwitchEnabled" + switchName, NUMBER).addMeta(new MetaItem<>(LABEL, "Smart Switch actuator enabled " + switchName),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true))+ new MetaItem<>(READ_ONLY, true)+ ));if (shouldBeLinked) {@@ -354,14 +324,11 @@ public abstract class AbstractManagerSetup implements Setup {new Attribute<>("ventilationLevel", POSITIVE_INTEGER).addMeta(new MetaItem<>(LABEL, "Ventilation level"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(STORE_DATA_POINTS)),+ new MetaItem<>(ACCESS_RESTRICTED_WRITE, true)),new Attribute<>("ventilationAuto", BOOLEAN).addMeta(new MetaItem<>(LABEL, "Ventilation auto"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(ACCESS_RESTRICTED_WRITE, true))@@ -537,7 +504,6 @@ public abstract class AbstractManagerSetup implements Setup {new MetaItem<>(LABEL, scene.sceneName + " time " + dayOfWeekLabel),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(ACCESS_RESTRICTED_WRITE, true),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(AGENT_LINK, new TimerAgent.TimerAgentLink(agents.get(i+j).getId()).setTimerValue(TimerValue.TIME))),new Attribute<>(scene.attributeName + "Enabled" + dayOfWeek.name(), BOOLEAN)@@ -557,7 +523,6 @@ public abstract class AbstractManagerSetup implements Setup {.addMeta(new MetaItem<>(LABEL, "Scene timer enabled"),new MetaItem<>(ACCESS_RESTRICTED_READ, true),- new MetaItem<>(SHOW_ON_DASHBOARD, true),new MetaItem<>(READ_ONLY, true)),new Attribute<>("enableSceneTimer", EXECUTION_STATUS)@@ -584,46 +549,27 @@ public abstract class AbstractManagerSetup implements Setup {new Attribute<>(Asset.LOCATION, location));peopleCounterAsset.getAttribute("peopleCountIn").ifPresent(assetAttribute -> {- assetAttribute.addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );if (agentLinker != null) {assetAttribute.addMeta(new MetaItem<>(AGENT_LINK, agentLinker.get()));}});peopleCounterAsset.getAttribute("peopleCountOut").ifPresent(assetAttribute -> {- assetAttribute.addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );if (agentLinker != null) {assetAttribute.addMeta(new MetaItem<>(AGENT_LINK, agentLinker.get()));}});peopleCounterAsset.getAttribute("peopleCountInMinute").ifPresent(assetAttribute -> {- assetAttribute.addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );if (agentLinker != null) {assetAttribute.addMeta(new MetaItem<>(AGENT_LINK, agentLinker.get()));}});peopleCounterAsset.getAttribute("peopleCountOutMinute").ifPresent(assetAttribute -> {- assetAttribute.addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );if (agentLinker != null) {assetAttribute.addMeta(new MetaItem<>(AGENT_LINK, agentLinker.get()));}});peopleCounterAsset.getAttribute("peopleCountTotal").ifPresent(assetAttribute -> {- assetAttribute.addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );+if (agentLinker != null) {assetAttribute.addMeta(new MetaItem<>(AGENT_LINK, agentLinker.get()));}@@ -640,8 +586,7 @@ public abstract class AbstractManagerSetup implements Setup {);microphoneAsset.getAttribute(MicrophoneAsset.SOUND_LEVEL).ifPresent(assetAttribute -> {assetAttribute.addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)+ new MetaItem<>(READ_ONLY));if (agentLinker != null) {assetAttribute.addMeta(new MetaItem<>(AGENT_LINK, agentLinker.get()));@@ -677,29 +622,8 @@ public abstract class AbstractManagerSetup implements Setup {protected LightAsset createDemoLightAsset(String name, Asset<?> area, GeoJSONPoint location) {LightAsset lightAsset = new LightAsset(name);lightAsset.setParent(area);- lightAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(new MetaItem<>(SHOW_ON_DASHBOARD, true))- );- lightAsset.getAttributes().getOrCreate(LightAsset.ON_OFF).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate(LightAsset.BRIGHTNESS).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate(LightAsset.COLOUR_RGB).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate("groupNumber", POSITIVE_INTEGER).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate("scenario", TEXT).addMeta(- new MetaItem<>(RULE_STATE)- );-+ lightAsset.getAttributes().getOrCreate("groupNumber", POSITIVE_INTEGER);+ lightAsset.getAttributes().getOrCreate("scenario", TEXT);return lightAsset;}@@ -709,21 +633,7 @@ public abstract class AbstractManagerSetup implements Setup {lightAsset.getAttributes().addOrReplace(new Attribute<>(Asset.LOCATION, location));- lightAsset.getAttributes().getOrCreate(LightAsset.ON_OFF).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate(LightAsset.BRIGHTNESS).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate(LightAsset.COLOUR_RGB).addMeta(- new MetaItem<>(RULE_STATE),- new MetaItem<>(STORE_DATA_POINTS)- );- lightAsset.getAttributes().getOrCreate("scenario", TEXT).addMeta(- new MetaItem<>(RULE_STATE)- );+ lightAsset.getAttributes().getOrCreate("scenario", TEXT);return lightAsset;}@@ -731,84 +641,42 @@ public abstract class AbstractManagerSetup implements Setup {protected ElectricityStorageAsset createDemoElectricityStorageAsset(String name, Asset<?> area, GeoJSONPoint location) {ElectricityStorageAsset electricityStorageAsset = new ElectricityStorageAsset(name);electricityStorageAsset.setParent(area);- electricityStorageAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-- return electricityStorageAsset;+ return electricityStorageAsset;}protected ElectricityProducerSolarAsset createDemoElectricitySolarProducerAsset(String name, Asset<?> area, GeoJSONPoint location) {ElectricityProducerSolarAsset electricityProducerAsset = new ElectricityProducerSolarAsset(name);electricityProducerAsset.setParent(area);- electricityProducerAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-- return electricityProducerAsset;+ return electricityProducerAsset;}protected ElectricityConsumerAsset createDemoElectricityConsumerAsset(String name, Asset<?> area, GeoJSONPoint location) {ElectricityConsumerAsset electricityConsumerAsset = new ElectricityConsumerAsset(name);electricityConsumerAsset.setParent(area);- electricityConsumerAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-- return electricityConsumerAsset;+ return electricityConsumerAsset;}protected ElectricityChargerAsset createDemoElectricityChargerAsset(String name, Asset<?> area, GeoJSONPoint location) {ElectricityChargerAsset electricityChargerAsset = new ElectricityChargerAsset(name);electricityChargerAsset.setParent(area);- electricityChargerAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-return electricityChargerAsset;}protected GroundwaterSensorAsset createDemoGroundwaterAsset(String name, Asset<?> area, GeoJSONPoint location) {GroundwaterSensorAsset groundwaterAsset = new GroundwaterSensorAsset(name);groundwaterAsset.setParent(area);- groundwaterAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-- return groundwaterAsset;+ return groundwaterAsset;}protected ParkingAsset createDemoParkingAsset(String name, Asset<?> area, GeoJSONPoint location) {ParkingAsset parkingAsset = new ParkingAsset(name);parkingAsset.setParent(area);- parkingAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-- return parkingAsset;+ return parkingAsset;}protected ShipAsset createDemoShipAsset(String name, Asset<?> area, GeoJSONPoint location) {ShipAsset shipAsset = new ShipAsset(name);shipAsset.setParent(area);- shipAsset.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, location).addMeta(- new MetaItem<>(SHOW_ON_DASHBOARD)- )- );-return shipAsset;}}diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.javaindex 2830391b4..b2d7d6b90 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java@@ -110,14 +110,10 @@ public class ManagerDemoSetup extends AbstractManagerSetup {.addOrReplaceMeta(new MetaItem<>(LABEL, "Combined power of all producers"),new MetaItem<>(UNITS, Constants.units(Constants.UNITS_KILO, Constants.UNITS_WATT)),- new MetaItem<>(STORE_DATA_POINTS, true),- new MetaItem<>(READ_ONLY, true),- new MetaItem<>(RULE_STATE, true)),+ new MetaItem<>(READ_ONLY, true)),new Attribute<>("powerTotalConsumers", NUMBER).addOrReplaceMeta(new MetaItem<>(LABEL, "Combined power use of all consumers"),new MetaItem<>(UNITS, Constants.units(Constants.UNITS_KILO, Constants.UNITS_WATT)),- new MetaItem<>(STORE_DATA_POINTS, true),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(READ_ONLY, true)));energyManagement.setId(UniqueIdentifierGenerator.generateId(energyManagement.getName()));@@ -136,8 +132,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {new Attribute<>("powerBalance", NUMBER).addMeta(new MetaItem<>(LABEL, "Balance of power production and use"),new MetaItem<>(UNITS, Constants.units(Constants.UNITS_KILO, Constants.UNITS_WATT)),- new MetaItem<>(STORE_DATA_POINTS),- new MetaItem<>(RULE_STATE),new MetaItem<>(READ_ONLY)));building1Asset.setId(UniqueIdentifierGenerator.generateId(building1Asset.getName() + "building"));@@ -147,12 +141,10 @@ public class ManagerDemoSetup extends AbstractManagerSetup {storage1Asset.setManufacturer("Super-B");storage1Asset.setModel("Nomia");storage1Asset.setId(UniqueIdentifierGenerator.generateId(storage1Asset.getName()));- storage1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));storage1Asset = assetStorageService.merge(storage1Asset);ElectricityConsumerAsset consumption1Asset = createDemoElectricityConsumerAsset("Consumption De Rotterdam", building1Asset, new GeoJSONPoint(4.487519, 51.906544));consumption1Asset.getAttribute(ElectricityConsumerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS, true));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -188,14 +180,12 @@ public class ManagerDemoSetup extends AbstractManagerSetup {});consumption1Asset.setId(UniqueIdentifierGenerator.generateId(consumption1Asset.getName()));- consumption1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));consumption1Asset = assetStorageService.merge(consumption1Asset);ElectricityProducerSolarAsset production1Asset = createDemoElectricitySolarProducerAsset("Solar De Rotterdam", building1Asset, new GeoJSONPoint(4.488592, 51.907047));production1Asset.setManufacturer("AEG");production1Asset.setModel("AS-P60");production1Asset.getAttribute(ElectricityProducerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -235,7 +225,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {production1Asset.setEfficiency(93);production1Asset.setPanelOrientation(ElectricityProducerSolarAsset.PanelOrientation.EAST_WEST);production1Asset.setId(UniqueIdentifierGenerator.generateId(production1Asset.getName()));- production1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));production1Asset = assetStorageService.merge(production1Asset);// ### Stadhuis ###@@ -256,12 +245,10 @@ public class ManagerDemoSetup extends AbstractManagerSetup {storage2Asset.setManufacturer("LG Chem");storage2Asset.setModel("ESS Industrial");storage2Asset.setId(UniqueIdentifierGenerator.generateId(storage2Asset.getName()));- storage2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));storage2Asset = assetStorageService.merge(storage2Asset);ElectricityConsumerAsset consumption2Asset = createDemoElectricityConsumerAsset("Consumption Stadhuis", building2Asset, new GeoJSONPoint(4.47933, 51.92259));consumption2Asset.getAttribute(ElectricityConsumerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -297,12 +284,10 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});consumption2Asset.setId(UniqueIdentifierGenerator.generateId(consumption2Asset.getName()));- consumption2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));consumption2Asset = assetStorageService.merge(consumption2Asset);ElectricityProducerSolarAsset production2Asset = createDemoElectricitySolarProducerAsset("Solar Stadhuis", building2Asset, new GeoJSONPoint(4.47945, 51.92301));production2Asset.getAttribute(ElectricityProducerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -344,7 +329,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {production2Asset.setManufacturer("Solarwatt");production2Asset.setModel("EasyIn 60M");production2Asset.setId(UniqueIdentifierGenerator.generateId(production2Asset.getName()));- production2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));production2Asset = assetStorageService.merge(production2Asset);// ### Markthal ###@@ -360,7 +344,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {new Attribute<>("allChargersInUse", BOOLEAN).addMeta(new MetaItem<>(LABEL, "All chargers in use"),- new MetaItem<>(RULE_STATE),new MetaItem<>(READ_ONLY)));building3Asset.setId(UniqueIdentifierGenerator.generateId(building3Asset.getName() + "building"));@@ -368,7 +351,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {ElectricityProducerSolarAsset production3Asset = createDemoElectricitySolarProducerAsset("Solar Markthal", building3Asset, new GeoJSONPoint(4.47945, 51.92301));production3Asset.getAttribute(ElectricityProducerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -410,7 +392,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {production3Asset.setManufacturer("Sunpower");production3Asset.setModel("E20-327");production3Asset.setId(UniqueIdentifierGenerator.generateId(production3Asset.getName()));- production3Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));production3Asset = assetStorageService.merge(production3Asset);ElectricityChargerAsset charger1Asset = createDemoElectricityChargerAsset("Charger 1 Markthal", building3Asset, new GeoJSONPoint(4.486143, 51.920058));@@ -451,7 +432,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {charger1Asset.setManufacturer("Allego");charger1Asset.setModel("HPC");charger1Asset.setId(UniqueIdentifierGenerator.generateId(charger1Asset.getName()));- charger1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));charger1Asset = assetStorageService.merge(charger1Asset);ElectricityChargerAsset charger2Asset = createDemoElectricityChargerAsset("Charger 2 Markthal", building3Asset, new GeoJSONPoint(4.486188, 51.919957));@@ -493,7 +473,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {charger2Asset.setManufacturer("Bosch");charger2Asset.setModel("EV800");charger2Asset.setId(UniqueIdentifierGenerator.generateId(charger2Asset.getName()));- charger2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));charger2Asset = assetStorageService.merge(charger2Asset);ElectricityChargerAsset charger3Asset = createDemoElectricityChargerAsset("Charger 3 Markthal", building3Asset, new GeoJSONPoint(4.486232, 51.919856));@@ -535,7 +514,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {charger3Asset.setManufacturer("Siemens");charger3Asset.setModel("CPC 50");charger3Asset.setId(UniqueIdentifierGenerator.generateId(charger3Asset.getName()));- charger3Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));charger3Asset = assetStorageService.merge(charger3Asset);ElectricityChargerAsset charger4Asset = createDemoElectricityChargerAsset("Charger 4 Markthal", building3Asset, new GeoJSONPoint(4.486286, 51.919733));@@ -578,7 +556,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {charger4Asset.setManufacturer("SemaConnect");charger4Asset.setModel("The Series 6");charger4Asset.setId(UniqueIdentifierGenerator.generateId(charger4Asset.getName()));- charger4Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));charger4Asset = assetStorageService.merge(charger4Asset);// ### Erasmianum ###@@ -597,7 +574,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {ElectricityConsumerAsset consumption4Asset = createDemoElectricityConsumerAsset("Consumption Erasmianum", building4Asset, new GeoJSONPoint(4.468324, 51.912062));consumption4Asset.getAttribute(ElectricityConsumerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -633,7 +609,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});consumption4Asset.setId(UniqueIdentifierGenerator.generateId(consumption4Asset.getName()));- consumption4Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));consumption4Asset = assetStorageService.merge(consumption4Asset);// ### Oostelijk zwembad ###@@ -652,7 +627,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {ElectricityConsumerAsset consumption5Asset = createDemoElectricityConsumerAsset("Consumption Zwembad", building5Asset, new GeoJSONPoint(4.498048, 51.925770));consumption5Asset.getAttribute(ElectricityConsumerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -688,12 +662,10 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});consumption5Asset.setId(UniqueIdentifierGenerator.generateId(consumption5Asset.getName()));- consumption5Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));consumption5Asset = assetStorageService.merge(consumption5Asset);ElectricityProducerSolarAsset production5Asset = createDemoElectricitySolarProducerAsset("Solar Zwembad", building5Asset, new GeoJSONPoint(4.498281, 51.925507));production5Asset.getAttribute(ElectricityProducerAsset.POWER_TOTAL).ifPresent(assetAttribute -> {- assetAttribute.addMeta(new MetaItem<>(STORE_DATA_POINTS));assetAttribute.addMeta(new MetaItem<>(AGENT_LINK,@@ -735,7 +707,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {production5Asset.setManufacturer("S-Energy");production5Asset.setModel("SN260P-10");production5Asset.setId(UniqueIdentifierGenerator.generateId(production5Asset.getName()));- production5Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));production5Asset = assetStorageService.merge(production5Asset);// ### Weather ###@@ -779,7 +750,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {})));new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.463250, 51.918849));- weather.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));weather = assetStorageService.merge(weather);// ################################ Realm smartcity - Environment monitor ###################################@@ -838,7 +808,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});asset.setId(UniqueIdentifierGenerator.generateId(asset.getName()));- asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));asset = assetStorageService.merge(asset);}@@ -921,7 +890,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});asset.setId(UniqueIdentifierGenerator.generateId(asset.getName()));- asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));asset = assetStorageService.merge(asset);}@@ -942,9 +910,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {new MetaItem<>(LABEL, "Percentage of total parking spaces in use"),new MetaItem<>(UNITS, Constants.units(Constants.UNITS_PERCENTAGE)),new MetaItem<>(CONSTRAINTS, ValueConstraint.constraints(new ValueConstraint.Min(0), new ValueConstraint.Max(100))),- new MetaItem<>(RULE_STATE),- new MetaItem<>(READ_ONLY),- new MetaItem<>(STORE_DATA_POINTS)));+ new MetaItem<>(READ_ONLY)));parkingGroupAsset.setId(UniqueIdentifierGenerator.generateId(parkingGroupAsset.getName()));parkingGroupAsset = assetStorageService.merge(parkingGroupAsset);@@ -990,7 +956,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {parking1Asset.setPriceDaily(25.00);parking1Asset.setSpacesTotal(512);parking1Asset.setId(UniqueIdentifierGenerator.generateId(parking1Asset.getName()));- parking1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));parking1Asset = assetStorageService.merge(parking1Asset);ParkingAsset parking2Asset = createDemoParkingAsset("Lijnbaan", parkingGroupAsset, new GeoJSONPoint(4.47681, 51.91849));@@ -1035,7 +1000,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {parking2Asset.setPriceDaily(23.00);parking2Asset.setSpacesTotal(390);parking2Asset.setId(UniqueIdentifierGenerator.generateId(parking2Asset.getName()));- parking2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));parking2Asset = assetStorageService.merge(parking2Asset);ParkingAsset parking3Asset = createDemoParkingAsset("Erasmusbrug", parkingGroupAsset, new GeoJSONPoint(4.48207, 51.91127));@@ -1080,7 +1044,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {parking3Asset.setPriceDaily(20.00);parking3Asset.setSpacesTotal(373);parking3Asset.setId(UniqueIdentifierGenerator.generateId(parking3Asset.getName()));- parking3Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));parking3Asset = assetStorageService.merge(parking3Asset);// ### Crowd control ###@@ -1137,7 +1100,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});peopleCounter1Asset.setId(UniqueIdentifierGenerator.generateId(peopleCounter1Asset.getName()));- peopleCounter1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));peopleCounter1Asset = assetStorageService.merge(peopleCounter1Asset);Asset<?> peopleCounter2Asset = createDemoPeopleCounterAsset("People Counter North", assetAreaStation, new GeoJSONPoint(4.469329, 51.923700), () ->@@ -1180,7 +1142,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});peopleCounter2Asset.setId(UniqueIdentifierGenerator.generateId(peopleCounter2Asset.getName()));- peopleCounter2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));peopleCounter2Asset = assetStorageService.merge(peopleCounter2Asset);MicrophoneAsset microphone1Asset = createDemoMicrophoneAsset("Microphone South", assetAreaStation, new GeoJSONPoint(4.470362, 51.923201), () ->@@ -1215,7 +1176,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {microphone1Asset.setManufacturer("Sorama");microphone1Asset.setModel("CAM1K");microphone1Asset.setId(UniqueIdentifierGenerator.generateId(microphone1Asset.getName()));- microphone1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));microphone1Asset = assetStorageService.merge(microphone1Asset);MicrophoneAsset microphone2Asset = createDemoMicrophoneAsset("Microphone North", assetAreaStation, new GeoJSONPoint(4.469190, 51.923786), () ->@@ -1250,28 +1210,24 @@ public class ManagerDemoSetup extends AbstractManagerSetup {microphone2Asset.setManufacturer("Sorama");microphone2Asset.setModel("CAM1K");microphone2Asset.setId(UniqueIdentifierGenerator.generateId(microphone2Asset.getName()));- microphone2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));microphone2Asset = assetStorageService.merge(microphone2Asset);LightAsset lightStation1Asset = createDemoLightAsset("Station Light NW", assetAreaStation, new GeoJSONPoint(4.468874, 51.923881));lightStation1Asset.setManufacturer("Philips");lightStation1Asset.setModel("CityTouch");lightStation1Asset.setId(UniqueIdentifierGenerator.generateId(lightStation1Asset.getName()));- lightStation1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightStation1Asset = assetStorageService.merge(lightStation1Asset);LightAsset lightStation2Asset = createDemoLightAsset("Station Light NE", assetAreaStation, new GeoJSONPoint(4.470539, 51.923991));lightStation2Asset.setManufacturer("Philips");lightStation2Asset.setModel("CityTouch");lightStation2Asset.setId(UniqueIdentifierGenerator.generateId(lightStation2Asset.getName()));- lightStation2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightStation2Asset = assetStorageService.merge(lightStation2Asset);LightAsset lightStation3Asset = createDemoLightAsset("Station Light S", assetAreaStation, new GeoJSONPoint(4.470558, 51.923186));lightStation3Asset.setManufacturer("Philips");lightStation3Asset.setModel("CityTouch");lightStation3Asset.setId(UniqueIdentifierGenerator.generateId(lightStation3Asset.getName()));- lightStation3Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightStation3Asset = assetStorageService.merge(lightStation3Asset);// ### Lighting controller ###@@ -1280,49 +1236,42 @@ public class ManagerDemoSetup extends AbstractManagerSetup {lightingControllerOPAsset.setManufacturer("Pharos");lightingControllerOPAsset.setModel("LPC X");lightingControllerOPAsset.setId(UniqueIdentifierGenerator.generateId(lightingControllerOPAsset.getName()));- lightingControllerOPAsset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightingControllerOPAsset = assetStorageService.merge(lightingControllerOPAsset);LightAsset lightOP1Asset = createDemoLightAsset("OnsPark1", lightingControllerOPAsset, new GeoJSONPoint(4.49626, 51.91516));lightOP1Asset.setManufacturer("Schréder");lightOP1Asset.setModel("Axia 2");lightOP1Asset.setId(UniqueIdentifierGenerator.generateId(lightOP1Asset.getName()));- lightOP1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightOP1Asset = assetStorageService.merge(lightOP1Asset);LightAsset lightOP2Asset = createDemoLightAsset("OnsPark2", lightingControllerOPAsset, new GeoJSONPoint(4.49705, 51.91549));lightOP2Asset.setManufacturer("Schréder");lightOP2Asset.setModel("Axia 2");lightOP2Asset.setId(UniqueIdentifierGenerator.generateId(lightOP2Asset.getName()));- lightOP2Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightOP2Asset = assetStorageService.merge(lightOP2Asset);LightAsset lightOP3Asset = createDemoLightAsset("OnsPark3", lightingControllerOPAsset, new GeoJSONPoint(4.49661, 51.91495));lightOP3Asset.setManufacturer("Schréder");lightOP3Asset.setModel("Axia 2");lightOP3Asset.setId(UniqueIdentifierGenerator.generateId(lightOP3Asset.getName()));- lightOP3Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightOP3Asset = assetStorageService.merge(lightOP3Asset);LightAsset lightOP4Asset = createDemoLightAsset("OnsPark4", lightingControllerOPAsset, new GeoJSONPoint(4.49704, 51.91520));lightOP4Asset.setManufacturer("Schréder");lightOP4Asset.setModel("Axia 2");lightOP4Asset.setId(UniqueIdentifierGenerator.generateId(lightOP4Asset.getName()));- lightOP4Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightOP4Asset = assetStorageService.merge(lightOP4Asset);LightAsset lightOP5Asset = createDemoLightAsset("OnsPark5", lightingControllerOPAsset, new GeoJSONPoint(4.49758, 51.91440));lightOP5Asset.setManufacturer("Schréder");lightOP5Asset.setModel("Axia 2");lightOP5Asset.setId(UniqueIdentifierGenerator.generateId(lightOP5Asset.getName()));- lightOP5Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightOP5Asset = assetStorageService.merge(lightOP5Asset);LightAsset lightOP6Asset = createDemoLightAsset("OnsPark6", lightingControllerOPAsset, new GeoJSONPoint(4.49786, 51.91452));lightOP6Asset.setManufacturer("Schréder");lightOP6Asset.setModel("Axia 2");lightOP6Asset.setId(UniqueIdentifierGenerator.generateId(lightOP6Asset.getName()));- lightOP6Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));lightOP6Asset = assetStorageService.merge(lightOP6Asset);// ### Ships ###@@ -1565,7 +1514,6 @@ public class ManagerDemoSetup extends AbstractManagerSetup {);});ship1Asset.setId(UniqueIdentifierGenerator.generateId(ship1Asset.getName()));- ship1Asset.getAttributes().forEach(attr -> attr.addMeta(new MetaItem<>(RULE_STATE)));ship1Asset = assetStorageService.merge(ship1Asset);// ### Mobile app config ###diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.javaindex 9ca8e3db9..dc158ec8c 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java@@ -51,14 +51,14 @@ import static org.openremote.model.value.ValueType.*;public class ManagerTestSetup extends AbstractManagerSetup {// Update these numbers whenever you change a RULE_STATE flag in test data- public static final int DEMO_RULE_STATES_APARTMENT_1 = 44;- public static final int DEMO_RULE_STATES_APARTMENT_2 = 13;- public static final int DEMO_RULE_STATES_APARTMENT_3 = 0;- public static final int DEMO_RULE_STATES_SMART_OFFICE = 1;- public static final int DEMO_RULE_STATES_SMART_BUILDING = DEMO_RULE_STATES_APARTMENT_1 + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3;- public static final int DEMO_RULE_STATES_SMART_CITY = 15;+ public static final int DEMO_RULE_STATES_APARTMENT_1 = 69;+ public static final int DEMO_RULE_STATES_APARTMENT_2 = 25;+ public static final int DEMO_RULE_STATES_APARTMENT_3 = 9;+ public static final int DEMO_RULE_STATES_SMART_OFFICE = 21;+ public static final int DEMO_RULE_STATES_SMART_BUILDING = DEMO_RULE_STATES_APARTMENT_1 + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3 + 6;+ public static final int DEMO_RULE_STATES_SMART_CITY = 82;public static final int DEMO_RULE_STATES_GLOBAL = DEMO_RULE_STATES_SMART_BUILDING + DEMO_RULE_STATES_SMART_OFFICE + DEMO_RULE_STATES_SMART_CITY;- public static final int DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1 + 28;+ public static final int DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1 + 309;public static final int DEMO_RULE_STATES_SMART_BUILDING_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3;public static GeoJSONPoint SMART_OFFICE_LOCATION = new GeoJSONPoint(5.460315214821094, 51.44541688237109);public static GeoJSONPoint SMART_BUILDING_LOCATION = new GeoJSONPoint(5.454027, 51.446308);@@ -160,7 +160,7 @@ public class ManagerTestSetup extends AbstractManagerSetup {Asset<?> thing = new ThingAsset("Demo Thing");thing.setParent(agent);thing.getAttributes().addOrReplace(- new Attribute<>(Asset.LOCATION, SMART_OFFICE_LOCATION).addMeta(new MetaItem<>(RULE_STATE, true)),+ new Attribute<>(Asset.LOCATION, SMART_OFFICE_LOCATION),new Attribute<>(thingLightToggleAttributeName, BOOLEAN, true).addOrReplaceMeta(new MetaItem<>(@@ -198,8 +198,7 @@ public class ManagerTestSetup extends AbstractManagerSetup {new MetaItem<>(LABEL, "Light 1 Usage"),new MetaItem<>(READ_ONLY, true),new MetaItem<>(UNITS, Constants.units(UNITS_KILO, UNITS_WATT, UNITS_HOUR)),- new MetaItem<>(AGENT_LINK, new SimulatorAgent.SimulatorAgentLink(agent.getId())),- new MetaItem<>(STORE_DATA_POINTS, true)+ new MetaItem<>(AGENT_LINK, new SimulatorAgent.SimulatorAgentLink(agent.getId()))));thing = assetStorageService.merge(thing);@@ -333,7 +332,6 @@ public class ManagerTestSetup extends AbstractManagerSetup {new Attribute<>(Asset.LOCATION, new GeoJSONPoint(5.454227,51.446753)),new Attribute<>("lights", BOOLEAN, true).addMeta(- new MetaItem<>(RULE_STATE, true),new MetaItem<>(ACCESS_RESTRICTED_READ, true),new MetaItem<>(ACCESS_RESTRICTED_WRITE, true))@@ -383,34 +381,28 @@ public class ManagerTestSetup extends AbstractManagerSetup {new Attribute<>("motionSensor", BOOLEAN, false).addMeta(new MetaItem<>(LABEL, "Motion Sensor"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(RULE_EVENT, true)),new Attribute<>("presenceDetected", BOOLEAN, false).addMeta(- new MetaItem<>(LABEL, "Presence Detected"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Presence Detected")),new Attribute<>("firstPresenceDetected", ValueType.TIMESTAMP).addMeta(- new MetaItem<>(LABEL, "First Presence Timestamp"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "First Presence Timestamp")),new Attribute<>("lastPresenceDetected", ValueType.TIMESTAMP).addMeta(- new MetaItem<>(LABEL, "Last Presence Timestamp"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Last Presence Timestamp")),new Attribute<>("co2Level", POSITIVE_INTEGER, 350).addMeta(new MetaItem<>(LABEL, "CO2 Level"),- new MetaItem<>(UNITS, Constants.units(UNITS_PART_PER_MILLION)),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(UNITS, Constants.units(UNITS_PART_PER_MILLION))),new Attribute<>("lightSwitch", BOOLEAN, true).addMeta(- new MetaItem<>(LABEL, "Light Switch"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Light Switch")),new Attribute<>("windowOpen", BOOLEAN, false).addMeta(@@ -418,13 +410,11 @@ public class ManagerTestSetup extends AbstractManagerSetup {),new Attribute<>("lightSwitchTriggerTimes", TEXT.asArray(), new String[] {"1800", "0830"}).addMeta(- new MetaItem<>(LABEL, "Lightswitch Trigger Times"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Lightswitch Trigger Times")),new Attribute<>("plantsWaterLevels", JSON_OBJECT, objectMap).addMeta(- new MetaItem<>(LABEL, "Water levels of the plants"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Water levels of the plants")));apartment2Livingroom = assetStorageService.merge(apartment2Livingroom);@@ -437,28 +427,23 @@ public class ManagerTestSetup extends AbstractManagerSetup {new Attribute<>("motionSensor", BOOLEAN, false).addMeta(new MetaItem<>(LABEL, "Motion Sensor"),- new MetaItem<>(RULE_STATE, true),new MetaItem<>(RULE_EVENT, true)),new Attribute<>("presenceDetected", BOOLEAN, false).addMeta(- new MetaItem<>(LABEL, "Presence Detected"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Presence Detected")),new Attribute<>("firstPresenceDetected", ValueType.TIMESTAMP).addMeta(- new MetaItem<>(LABEL, "First Presence Timestamp"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "First Presence Timestamp")),new Attribute<>("lastPresenceDetected", ValueType.TIMESTAMP).addMeta(- new MetaItem<>(LABEL, "Last Presence Timestamp"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Last Presence Timestamp")),new Attribute<>("lightSwitch", BOOLEAN, true).addMeta(- new MetaItem<>(LABEL, "Light Switch"),- new MetaItem<>(RULE_STATE, true)+ new MetaItem<>(LABEL, "Light Switch")));apartment2Bathroom = assetStorageService.merge(apartment2Bathroom);diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.javaindex 520b33ecb..cd5b3e911 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java@@ -69,7 +69,6 @@ public class RulesDemoSetup extends AbstractManagerSetup {keycloakDemoSetup.tenantCity.getRealm(), "De Kuip", Ruleset.Lang.JSON, rules).setAccessPublicRead(true);ruleset.getMeta().addOrReplace(- new MetaItem<>(SHOW_ON_DASHBOARD),new MetaItem<>(SHOW_ON_LIST));tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();}@@ -80,7 +79,6 @@ public class RulesDemoSetup extends AbstractManagerSetup {keycloakDemoSetup.tenantCity.getRealm(), "Euromast", Ruleset.Lang.JSON, rules).setAccessPublicRead(true);ruleset.getMeta().addOrReplace(- new MetaItem<>(SHOW_ON_DASHBOARD),new MetaItem<>(SHOW_ON_LIST));tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();}@@ -91,7 +89,6 @@ public class RulesDemoSetup extends AbstractManagerSetup {keycloakDemoSetup.tenantCity.getRealm(), "Markthal", Ruleset.Lang.JSON, rules).setAccessPublicRead(true);ruleset.getMeta().addOrReplace(- new MetaItem<>(SHOW_ON_DASHBOARD),new MetaItem<>(SHOW_ON_LIST));tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();}diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.javaindex 108453b49..ce7f92911 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.java@@ -128,7 +128,6 @@ public class RulesTestSetup extends AbstractManagerSetup {keycloakTestSetup.tenantCity.getRealm(), "Demo Geofences", Ruleset.Lang.JSON, rules).setAccessPublicRead(true);ruleset.getMeta().addOrReplace(- new MetaItem<>(SHOW_ON_DASHBOARD),new MetaItem<>(SHOW_ON_LIST));tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();}diff --git a/model/src/main/java/org/openremote/model/value/MetaItemType.java b/model/src/main/java/org/openremote/model/value/MetaItemType.javaindex 33220a63a..8a8c7996b 100644--- a/model/src/main/java/org/openremote/model/value/MetaItemType.java+++ b/model/src/main/java/org/openremote/model/value/MetaItemType.java@@ -86,7 +86,7 @@ public final class MetaItemType {/* DATA POINT META *//**- * Should attribute values be stored in time series database+ * Can be set to false to prevent attribute values being stored in time series database*/public static final MetaItemDescriptor<Boolean> STORE_DATA_POINTS = new MetaItemDescriptor<>("storeDataPoints", ValueType.BOOLEAN);@@ -106,9 +106,9 @@ public final class MetaItemType {/* RULE META *//**- * Set maximum lifetime of {@link AssetState} temporary facts in rules, for example "PT1H30M5S". The rules engine will- * remove temporary {@link AssetState} facts if they are older than this value (using event source/value timestamp,- * not event processing time).+ * Set maximum lifetime of {@link AssetState} temporary facts in rules, for example "PT1H30M5S". The rules engine+ * will remove temporary {@link AssetState} facts if they are older than this value (using event source/value+ * timestamp, not event processing time).* <p>* The default expiration for asset events can be configured with environment variable* <code>RULE_EVENT_EXPIRES</code>.@@ -128,11 +128,11 @@ public final class MetaItemType {public static final MetaItemDescriptor<Boolean> RULE_EVENT = new MetaItemDescriptor<>("ruleEvent", ValueType.BOOLEAN);/**- * Should attribute writes be processed by the rules engines as {@link AssetState} facts, with a lifecycle that- * reflects the state of the asset attribute. Each attribute will have one fact at all times in rules memory. These- * state facts are kept in sync with asset changes: When the attribute is updated, the fact will be updated- * (replaced). If you want evaluate the change history of an attribute, you typically need to combine this with- * {@link #RULE_EVENT}.+ * Can be set to false to exclude an attribute update from being processed by the rules engines as {@link+ * AssetState} facts, with a lifecycle that reflects the state of the asset attribute. Each attribute will have one+ * fact at all times in rules memory. These state facts are kept in sync with asset changes: When the attribute is+ * updated, the fact will be updated (replaced). If you want evaluate the change history of an attribute, you+ * typically need to combine this with {@link #RULE_EVENT}.*/public static final MetaItemDescriptor<Boolean> RULE_STATE = new MetaItemDescriptor<>("ruleState", ValueType.BOOLEAN);diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovyindex f213498ec..d71d1250b 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy@@ -654,14 +654,11 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai!currentTemperatureAttr.getValue().isPresent()MetaMap resultMeta = currentTemperatureAttr.getMeta()- resultMeta.size() == 9+ resultMeta.size() == 6resultMeta.getValueOrDefault(LABEL) == "Current temperature"resultMeta.getValue(READ_ONLY).orElse(false)resultMeta.has(AGENT_LINK)resultMeta.getValueOrDefault(ACCESS_RESTRICTED_READ)- resultMeta.getValue(RULE_STATE).orElse(false)- resultMeta.getValue(STORE_DATA_POINTS).orElse(false)- resultMeta.getValue(SHOW_ON_DASHBOARD).orElse(false)resultMeta.getValueOrDefault(UNITS) != nullresultMeta.getValueOrDefault(UNITS)[0] == UNITS_CELSIUSdiff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovyindex 743d5dfde..52e95fc55 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy@@ -491,14 +491,15 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {.tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm)).attributes(new AttributePredicate().meta(- new NameValuePredicate(STORE_DATA_POINTS, new BooleanPredicate(true))+ new NameValuePredicate(READ_ONLY, new BooleanPredicate(true)))))then: "result should match"- assets.size() == 1- assets.get(0).id == managerTestSetup.thingId+ assets.size() == 2+ assets.any{it.id == managerTestSetup.agentId}+ assets.any{it.id == managerTestSetup.thingId}when: "a query is executed"assets = assetStorageService.findAll(diff --git a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovyindex 4070e0aab..0716c4d04 100644--- a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy@@ -17,6 +17,7 @@ import org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetResourceimport org.openremote.model.asset.impl.ConsoleAssetimport org.openremote.model.attribute.AttributeRef+import org.openremote.model.attribute.MetaItemimport org.openremote.model.console.ConsoleProviderimport org.openremote.model.console.ConsoleRegistrationimport org.openremote.model.console.ConsoleResource@@ -654,9 +655,9 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {.count() == 12}- when: "the RULE_STATE meta is removed from a console's location attribute"+ when: "the RULE_STATE meta is set to false on a console's location attribute"testUser3Console1 = assetStorageService.find(testUser3Console1.id, true)- testUser3Console1.getAttribute(Asset.LOCATION.name).get().getMeta().remove(MetaItemType.RULE_STATE)+ testUser3Console1.getAttribute(Asset.LOCATION.name).ifPresent{it.addMeta(new MetaItem<>(MetaItemType.RULE_STATE, false))}testUser3Console1 = assetStorageService.merge(testUser3Console1)then: "no geofences should remain for this console"diff --git a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovyindex 594f3e3e5..ff2292f3c 100644--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy@@ -806,7 +806,6 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "a gateway client asset is modified"MicrophoneAsset microphone1 = assetStorageService.find(managerTestSetup.microphone1Id)microphone1.setName("Microphone 1 Updated")- microphone1.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).ifPresent{it.addMeta(new MetaItem<>(SHOW_ON_DASHBOARD))}microphone1.addAttributes(new Attribute<>("test", NUMBER, 100d))@@ -816,7 +815,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {conditions.eventually {def mirroredMicrophone = assetStorageService.find(mapAssetId(gateway.id, managerTestSetup.microphone1Id, false))assert mirroredMicrophone != null- assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap{it.getMetaItem(SHOW_ON_DASHBOARD)}.flatMap{it.getValue()}.orElse(false)+ assert mirroredMicrophone.getAttributes().get(MicrophoneAsset.SOUND_LEVEL).flatMap{it.getMetaItem(READ_ONLY)}.flatMap{it.getValue()}.orElse(false)assert mirroredMicrophone.getAttribute("test").isPresent()assert mirroredMicrophone.getAttribute("test", Double.class).flatMap{it.getValue()}.orElse(0d) == 100d}diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex 3dde20634..fefccf615 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -82,7 +82,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassertRulesFired(rulesImport.tenantBuildingEngine, ["All"])assertRulesFired(rulesImport.apartment2Engine, 1)assertRulesFired(rulesImport.apartment2Engine, ["All"])- assertRulesFired(rulesImport.apartment3Engine, 0)+ assertRulesFired(rulesImport.apartment3Engine, 1)+ assertRulesFired(rulesImport.apartment3Engine, ["All"])assertRulesFired(smartHomeEngine, 8)assertRulesFired(smartHomeEngine, ["Living Room All", "Kitchen All", "Kitchen Number Attributes", "Parent Type Residence", "Asset Type Room", "Boolean Attributes", "String attributes", "Number value types"])}@@ -135,15 +136,12 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassert noRuleEngineFiringScheduled()}- when: "a Kitchen room asset is inserted into apartment that contains a RULE_STATE = true meta flag"+ when: "a Kitchen room asset is inserted into apartment"def apartment2 = assetStorageService.find(managerTestSetup.apartment2Id)def asset = new RoomAsset("Kitchen").setParent(apartment2).addOrReplaceAttributes(new Attribute<>("testString", ValueType.TEXT, "test")- .addOrReplaceMeta(- new MetaItem<>(MetaItemType.RULE_STATE, true)- ))asset = assetStorageService.merge(asset)@@ -158,11 +156,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerthen: "after a few seconds the engines in scope should have facts and rules should have fired"conditions.eventually {- assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1- assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1+ assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 3+ assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 3assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE- assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING + 1- assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 1+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING + 3+ assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 3assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3assertRulesFired(rulesImport.globalEngine, 1)assertRulesFired(rulesImport.globalEngine, ["All"])@@ -172,7 +170,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassertRulesFired(rulesImport.tenantBuildingEngine, ["All"])assertRulesFired(rulesImport.apartment2Engine, 1)assertRulesFired(rulesImport.apartment2Engine, ["All"])- assertRulesFired(rulesImport.apartment3Engine, 0)+ assertRulesFired(rulesImport.apartment3Engine, 1)+ assertRulesFired(rulesImport.apartment3Engine, ["All"])}when: "time advances"@@ -200,29 +199,26 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassert apartment2LivingRoom.getAttribute("windowOpen").flatMap{it.getValueAs(Boolean.class)}.orElse(false)}- then: "the rules engines should not have fired"+ then: "the rules engines should have fired"conditions.eventually {- assert rulesImport.globalEngine.lastFireTimestamp == globalLastFireTimestamp+ assert rulesImport.globalEngine.lastFireTimestamp > globalLastFireTimestampassert rulesImport.masterEngine.lastFireTimestamp == masterLastFireTimestamp- assert rulesImport.tenantBuildingEngine.lastFireTimestamp == tenantALastFireTimestamp- assert rulesImport.apartment2Engine.lastFireTimestamp == apartment2LastFireTimestamp+ assert rulesImport.tenantBuildingEngine.lastFireTimestamp > tenantALastFireTimestamp+ assert rulesImport.apartment2Engine.lastFireTimestamp > apartment2LastFireTimestampassert rulesImport.apartment3Engine.lastFireTimestamp == apartment3LastFireTimestamp}when: "time advances"advancePseudoClock(1, TimeUnit.SECONDS, container)- and: "the Kitchen room asset is modified to add a new attribute but RULE_STATE = true meta is not changed"+ and: "the Kitchen room asset is modified to add a new attribute"globalLastFireTimestamp = rulesImport.globalEngine.lastFireTimestampmasterLastFireTimestamp = rulesImport.masterEngine.lastFireTimestamptenantALastFireTimestamp = rulesImport.tenantBuildingEngine.lastFireTimestampapartment2LastFireTimestamp = rulesImport.apartment2Engine.lastFireTimestampapartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestampasset.addOrReplaceAttributes(- new Attribute<>("testString", ValueType.TEXT, "test")- .addOrReplaceMeta(- new MetaItem<>(MetaItemType.RULE_STATE, true)- ),+ new Attribute<>("testString", ValueType.TEXT, "test"),new Attribute<>("testInteger", ValueType.NUMBER, 0d))asset = assetStorageService.merge(asset)@@ -238,20 +234,20 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerthen: "no rules should have fired"conditions.eventually {- assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1- assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1+ assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 4+ assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 4assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE- assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING + 1- assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 1+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING + 4+ assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 4assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3assertRulesFired(rulesImport.globalEngine, 1)assertRulesFired(rulesImport.masterEngine, 1)assertRulesFired(rulesImport.tenantBuildingEngine, 1)assertRulesFired(rulesImport.apartment2Engine, 1)- assertRulesFired(rulesImport.apartment3Engine, 0)+ assertRulesFired(rulesImport.apartment3Engine, 1)}- when: "the Kitchen room asset is modified to set the RULE_STATE to false"+ when: "the Kitchen room asset is modified to set the RULE_STATE to false on one attribute"rulesImport.resetRulesFired()asset.addOrReplaceAttributes(new Attribute<>("testString", ValueType.TEXT, "test")@@ -264,11 +260,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerthen: "the facts should be removed from the rule engines and rules should have fired"conditions.eventually {- assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL- assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL+ assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 3+ assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 3assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE- assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING- assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING + 3+ assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 3assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3assertRulesFired(rulesImport.globalEngine, 1)assertRulesFired(rulesImport.globalEngine, ["All"])@@ -279,16 +275,16 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassertRulesFired(rulesImport.apartment3Engine, 0)}- when: "the Kitchen room asset is modified to set all attributes to RULE_STATE = true"+ when: "the Kitchen room asset is modified to set all attributes to RULE_STATE = false"rulesImport.resetRulesFired()asset.addOrReplaceAttributes(new Attribute<>("testString", ValueType.TEXT, "test").addOrReplaceMeta(- new MetaItem<>(MetaItemType.RULE_STATE, true)+ new MetaItem<>(MetaItemType.RULE_STATE, false)),new Attribute<>("testInteger", ValueType.NUMBER, 0d).addOrReplaceMeta(- new MetaItem<>(MetaItemType.RULE_STATE, true)+ new MetaItem<>(MetaItemType.RULE_STATE, false)))asset = assetStorageService.merge(asset)diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovyindex 1cf5fc700..7c0150a4b 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy@@ -130,6 +130,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {assert tenantBuildingEngine != nullassert tenantBuildingEngine.isRunning()assert tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING+ assert tenantBuildingEngine.lastFireTimestamp > 0assert !tenantBuildingEngine.trackLocationPredicates}