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
Work on demo apartment/scene setup
Christian Bauer83d2f4f5b9f6
diff --git a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.javaindex f4d76ce4b..2e2da94bd 100644--- a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java@@ -44,13 +44,20 @@ public class SimulatorProtocol extends AbstractProtocol {* Controls how and when sensor update is called after an actuator write.*/public enum Mode {- // Send to actuator values are written through to sensor immediately++ /**+ * Send to actuator values are written through to sensor immediately.+ */WRITE_THROUGH_IMMEDIATE,- // Send to actuator values are written through to sensor after configured delay+ /**+ * Send to actuator values are written through to sensor after configured delay.+ */WRITE_THROUGH_DELAYED,- // Producer of send to actuator will have to manually update the sensor by calling updateSensor+ /**+ * Producer of send to actuator will have to manually update the sensor by calling {@link #updateSensor)}.+ */MANUAL}diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/attributes/AttributesView.java b/manager/client/src/main/java/org/openremote/manager/client/assets/attributes/AttributesView.javaindex ef8939a1e..30e5f612f 100644--- a/manager/client/src/main/java/org/openremote/manager/client/assets/attributes/AttributesView.java+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/attributes/AttributesView.java@@ -300,12 +300,21 @@ public abstract class AttributesView<formGroup.addFormLabel(createAttributeLabel(attribute));- attribute.getType()- .map(attributeType -> environment.getMessages().attributeType(attributeType.name()))- .map(typeDisplayName -> typeDisplayName + (- getAttributeDescription(attribute)- .map(description -> " - " + description).orElse("")- )).ifPresent(infoText -> formGroup.addInfolabel(new Label(infoText)));+ StringBuilder infoText = new StringBuilder();+ if (attribute.isExecutable()) {+ infoText.append(environment.getMessages().executable());+ } else if (attribute.getType().isPresent()) {+ infoText.append(environment.getMessages().attributeType(attribute.getType().get().name()));+ }+ getAttributeDescription(attribute)+ .ifPresent(description -> {+ if (infoText.length() > 0)+ infoText.append(" - " );+ infoText.append(description);+ });+ if (infoText.length() > 0) {+ formGroup.addInfolabel(new Label(infoText.toString()));+ }FormGroupActions formGroupActions = new FormGroupActions();diff --git a/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java b/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.javaindex 8f385ba5f..8e72b55de 100644--- a/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java+++ b/manager/client/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java@@ -358,4 +358,6 @@ public interface ManagerMessages extends Messages {String emptyJsonData();String reset();++ String executable();}diff --git a/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.properties b/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.propertiesindex 455cc8a0a..78c821407 100644--- a/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.properties+++ b/manager/client/src/main/resources/org/openremote/manager/client/i18n/ManagerMessages.properties@@ -234,5 +234,6 @@ jsonArray=JSON arrayedit=EditemptyJsonData=Empty JSON data.reset=Reset+executable=Executablediff --git a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.javaindex d0722073c..d8ea43a3a 100644--- a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java@@ -134,7 +134,8 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSerprotected AssetDatapointService assetDatapointService;protected MessageBrokerService messageBrokerService;protected EventService eventService;- protected long lastProcessedEventTimestamp;+ // Used in testing to detect if initial/startup processing has completed+ protected long lastProcessedEventTimestamp = System.currentTimeMillis();final protected List<Consumer<AssetState>> processors = new ArrayList<>();diff --git a/manager/server/src/main/java/org/openremote/manager/server/rules/RulesService.java b/manager/server/src/main/java/org/openremote/manager/server/rules/RulesService.javaindex 6cf5ddeb1..8186cd074 100644--- a/manager/server/src/main/java/org/openremote/manager/server/rules/RulesService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/rules/RulesService.java@@ -175,7 +175,6 @@ public class RulesService extends RouteBuilder implements ContainerService, ConsAssetState assetState = new AssetState(asset, ruleAttribute);// Set the status to completed already so rules cannot interfere with this initial insertassetState.setProcessingStatus(AssetState.ProcessingStatus.COMPLETED);- LOG.fine("Inserting initial rules engine state: " + assetState);updateAssetState(assetState, true);});});@@ -560,10 +559,6 @@ public class RulesService extends RouteBuilder implements ContainerService, Cons// Get the chain of rule engines that we need to pass throughList<RulesEngine> rulesEngines = getEnginesInScope(assetEvent.getRealmId(), assetEvent.getPathFromRoot());- if (rulesEngines.size() == 0) {- LOG.fine("Ignoring asset event as there are no matching rules engines: " + assetEvent);- }-// Check that all engines in the scope are not in ERROR stateif (rulesEngines.stream().anyMatch(RulesEngine::isError)) {LOG.severe("At least one rule engine is in an error state so cannot process event:" + assetEvent);@@ -588,10 +583,6 @@ public class RulesService extends RouteBuilder implements ContainerService, Cons// Get the chain of rule engines that we need to pass throughList<RulesEngine> rulesEngines = getEnginesInScope(assetState.getRealmId(), assetState.getPathFromRoot());- if (rulesEngines.size() == 0) {- LOG.fine("Ignoring as there are no matching rules engine: " + assetState);- }-if (!skipStatusCheck) {// Check that all engines in the scope are not in ERROR statefor (RulesEngine rulesEngine : rulesEngines) {diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.javaindex 91e7f42c3..5463e2ff3 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java@@ -43,9 +43,10 @@ import static org.openremote.container.util.MapAccess.getBoolean;* {@link Container} constructor. Available config options are:* <ul>* <li>{@link #SETUP_INIT_CLEAN_DATABASE}</li>- * <li>{@link #SETUP_IMPORT_DEMO_ASSETS} depends on {@link #SETUP_IMPORT_DEMO_USERS}</li>* <li>{@link #SETUP_IMPORT_DEMO_USERS}</li>+ * <li>{@link #SETUP_IMPORT_DEMO_ASSETS} depends on {@link #SETUP_IMPORT_DEMO_USERS}</li>* <li>{@link #SETUP_IMPORT_DEMO_RULES} depends on {@link #SETUP_IMPORT_DEMO_ASSETS}</li>+ * <li>{@link #SETUP_IMPORT_DEMO_SCENES} depends on {@link #SETUP_IMPORT_DEMO_RULES}</li>* </ul>*/public class BuiltinSetupTasks extends AbstractSetupTasks {@@ -53,21 +54,26 @@ public class BuiltinSetupTasks extends AbstractSetupTasks {public static final String SETUP_INIT_CLEAN_DATABASE = "SETUP_INIT_CLEAN_DATABASE";public static final String SETUP_IMPORT_DEMO_USERS = "SETUP_IMPORT_DEMO_USERS";public static final String SETUP_IMPORT_DEMO_ASSETS = "SETUP_IMPORT_DEMO_ASSETS";- // TODO: Only import apartment 1 if this flag is set- public static final String SETUP_IMPORT_DEMO_APARTMENT = "SETUP_IMPORT_DEMO_APARTMENT";public static final String SETUP_IMPORT_DEMO_RULES = "SETUP_IMPORT_DEMO_RULES";+ public static final String SETUP_IMPORT_DEMO_SCENES = "SETUP_IMPORT_DEMO_SCENES";@Overridepublic List<Setup> createTasks(Container container) {boolean cleanDatabase = getBoolean(container.getConfig(), SETUP_INIT_CLEAN_DATABASE, container.isDevMode());- boolean importDemoRules = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_RULES, container.isDevMode());++ // Demo scenes are optional because they create many attributes+ boolean importDemoScenes = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_SCENES, container.isDevMode());++ // If importing demo scenes we have to import demo rules+ boolean importDemoRules = importDemoScenes || getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_RULES, container.isDevMode());+// If importing demo rules we have to import demo assetsboolean importDemoAssets = importDemoRules || getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_ASSETS, container.isDevMode());+// If importing demo assets we have to import demo usersboolean importDemoUsers = importDemoAssets || getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_USERS, container.isDevMode());-if (cleanDatabase) {addTask(new ManagerCleanSetup(container));addTask(new KeycloakCleanSetup(container));@@ -80,7 +86,7 @@ public class BuiltinSetupTasks extends AbstractSetupTasks {}if (importDemoAssets) {- addTask(new ManagerDemoSetup(container));+ addTask(new ManagerDemoSetup(container, importDemoScenes));}if (importDemoRules) {diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.javaindex 98b5d9b92..0b3493758 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java@@ -38,11 +38,14 @@ import org.openremote.model.asset.AssetState;import org.openremote.model.attribute.*;import org.openremote.model.value.Values;+import java.time.DayOfWeek;import java.time.LocalDateTime;import java.time.ZoneId;import java.time.ZonedDateTime;+import java.util.ArrayList;import java.util.Arrays;import java.util.List;+import java.util.Locale;import static org.openremote.agent.protocol.macro.MacroProtocol.META_MACRO_ACTION_INDEX;import static org.openremote.agent.protocol.timer.TimerConfiguration.initTimerConfiguration;@@ -54,14 +57,21 @@ import static org.openremote.model.attribute.AttributeType.*;public class ManagerDemoSetup extends AbstractManagerSetup {+ final protected boolean importDemoScenes;+// Update these numbers whenever you change a RULE_STATE flag in test data- public static final int DEMO_RULE_STATES_APARTMENT_1 = 38;+ public static final int DEMO_RULE_STATES_APARTMENT_1 = 11;public static final int DEMO_RULE_STATES_APARTMENT_2 = 3;public static final int DEMO_RULE_STATES_APARTMENT_3 = 0;public static final int DEMO_RULE_STATES_SMART_HOME = DEMO_RULE_STATES_APARTMENT_1 + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3;public static final int DEMO_RULE_STATES_CUSTOMER_A = DEMO_RULE_STATES_SMART_HOME;public static final int DEMO_RULE_STATES_GLOBAL = DEMO_RULE_STATES_CUSTOMER_A;+ public static final int DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1 + 28;+ public static final int DEMO_RULE_STATES_SMART_HOME_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3;+ public static final int DEMO_RULE_STATES_CUSTOMER_A_WITH_SCENES = DEMO_RULE_STATES_SMART_HOME_WITH_SCENES;+ public static final int DEMO_RULE_STATES_GLOBAL_WITH_SCENES = DEMO_RULE_STATES_CUSTOMER_A_WITH_SCENES;+public String smartOfficeId;public String groundFloorId;public String lobbyId;@@ -70,9 +80,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {public String thingId;public String smartHomeId;public String apartment1Id;- public String apartment1SceneAgentId;+ public String apartment1ServiceAgentId;public String apartment1LivingroomId;- public String apartment1LivingroomThermostatId;public String apartment2Id;public String apartment3Id;public String apartment2LivingroomId;@@ -80,8 +89,9 @@ public class ManagerDemoSetup extends AbstractManagerSetup {public String masterRealmId;public String customerARealmId;- public ManagerDemoSetup(Container container) {+ public ManagerDemoSetup(Container container, boolean importDemoScenes) {super(container);+ this.importDemoScenes = importDemoScenes;}@Override@@ -151,7 +161,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {SimulatorProtocol.CONFIG_WRITE_DELAY_MILLISECONDS,Values.create(500)))- );+ );agent = assetStorageService.merge(agent);agentId = agent.getId();@@ -176,63 +186,63 @@ public class ManagerDemoSetup extends AbstractManagerSetup {),new AssetAttribute("light1Dimmer", PERCENTAGE) // No initial value!.setMeta(new Meta(- new MetaItem(- LABEL,- Values.create("Light 1 Dimmer")),- new MetaItem(- DESCRIPTION,- Values.create("Dimmer for living room light")),- new MetaItem(- RANGE_MIN,- Values.create(0)),- new MetaItem(- RANGE_MAX,- Values.create(100)),- new MetaItem(- AGENT_LINK,- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),- new MetaItem(- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(IntegerSimulatorElement.ELEMENT_NAME_RANGE)),- new MetaItem(- SimulatorProtocol.CONFIG_MODE, Values.create(true))+ new MetaItem(+ LABEL,+ Values.create("Light 1 Dimmer")),+ new MetaItem(+ DESCRIPTION,+ Values.create("Dimmer for living room light")),+ new MetaItem(+ RANGE_MIN,+ Values.create(0)),+ new MetaItem(+ RANGE_MAX,+ Values.create(100)),+ new MetaItem(+ AGENT_LINK,+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),+ new MetaItem(+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(IntegerSimulatorElement.ELEMENT_NAME_RANGE)),+ new MetaItem(+ SimulatorProtocol.CONFIG_MODE, Values.create(true)))),new AssetAttribute("light1Color", COLOR_RGB, new ColorRGB(88, 123, 88).asArrayValue()).setMeta(new Meta(- new MetaItem(- LABEL,- Values.create("Light 1 Color")),- new MetaItem(- DESCRIPTION,- Values.create("Color of living room light")),- new MetaItem(- AGENT_LINK,- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),- new MetaItem(- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ColorSimulatorElement.ELEMENT_NAME))+ new MetaItem(+ LABEL,+ Values.create("Light 1 Color")),+ new MetaItem(+ DESCRIPTION,+ Values.create("Color of living room light")),+ new MetaItem(+ AGENT_LINK,+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),+ new MetaItem(+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ColorSimulatorElement.ELEMENT_NAME)))),new AssetAttribute("light1PowerConsumption", ENERGY_KWH, Values.create(12.345)).setMeta(new Meta(- new MetaItem(- LABEL,- Values.create("Light 1 Usage")),- new MetaItem(- DESCRIPTION,- Values.create("Total energy consumption of living room light")),- new MetaItem(- READ_ONLY,- Values.create(true)),- new MetaItem(- FORMAT,- Values.create("%3d kWh")),- new MetaItem(- AGENT_LINK,- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),- new MetaItem(- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME)),- new MetaItem(- STORE_DATA_POINTS.getUrn(), Values.create(true))+ new MetaItem(+ LABEL,+ Values.create("Light 1 Usage")),+ new MetaItem(+ DESCRIPTION,+ Values.create("Total energy consumption of living room light")),+ new MetaItem(+ READ_ONLY,+ Values.create(true)),+ new MetaItem(+ FORMAT,+ Values.create("%3d kWh")),+ new MetaItem(+ AGENT_LINK,+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),+ new MetaItem(+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME)),+ new MetaItem(+ STORE_DATA_POINTS.getUrn(), Values.create(true)))));@@ -327,729 +337,41 @@ public class ManagerDemoSetup extends AbstractManagerSetup {smartHome = assetStorageService.merge(smartHome);smartHomeId = smartHome.getId();- ServerAsset apartment1 = new ServerAsset("Apartment 1", RESIDENCE, smartHome);- apartment1.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));- apartment1.setAttributes(- new AssetAttribute("alarmEnabled", AttributeType.BOOLEAN, Values.create(false))- .setMeta(new Meta(- new MetaItem(LABEL, Values.create("Alarm enabled")),- new MetaItem(READ_ONLY, Values.create(true)),- new MetaItem(DESCRIPTION, Values.create("Send notifications when presence is detected")),- new MetaItem(RULE_STATE, Values.create(true))- )),- new AssetAttribute("vacationDays", AttributeType.INTEGER)- .setMeta(new Meta(- new MetaItem(LABEL, Values.create("Vacation days")),- new MetaItem(DESCRIPTION, Values.create("Enable vacation mode for given days")),- new MetaItem(RULE_STATE, Values.create(true))- )),- new AssetAttribute("autoSceneSchedule", AttributeType.BOOLEAN, Values.create(false))- .setMeta(- new MetaItem(LABEL, Values.create("Automatic scene schedule")),- new MetaItem(DESCRIPTION, Values.create("Predict presence and automatically adjust scene schedule")),- new MetaItem(RULE_STATE, Values.create(true))- ),- new AssetAttribute("lastExecutedScene", AttributeType.STRING, Values.create("HOME"))- .setMeta(- new MetaItem(LABEL, Values.create("Last executed scene")),- new MetaItem(READ_ONLY, Values.create(true)),- new MetaItem(RULE_STATE, Values.create(true))- )- );+ // The "Apartment 1" is the demo apartment with complex scenes+ ServerAsset apartment1 = createDemoApartment(smartHome, "Apartment 1", new Coordinate(5.470945, 51.438000));apartment1 = assetStorageService.merge(apartment1);apartment1Id = apartment1.getId();- ServerAsset apartment1Livingroom = new ServerAsset("Living Room", ROOM, apartment1);- apartment1Livingroom.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));- apartment1Livingroom.setAttributes(- new AssetAttribute("motionCount", AttributeType.INTEGER, Values.create(0))- .setMeta(new Meta(- new MetaItem(LABEL, Values.create("Motion Count")),- new MetaItem(DESCRIPTION, Values.create("Sensor that increments a counter when motion is detected")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(RULE_EVENT, Values.create(true))- )),- new AssetAttribute("presenceDetected", AttributeType.BOOLEAN)- .setMeta(new Meta(- new MetaItem(LABEL, Values.create("Presence Detected")),- new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),- new MetaItem(RULE_STATE, Values.create(true))- )),- new AssetAttribute("lastPresenceDetected", AttributeType.DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Last Presence Timestamp")),- new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),- new MetaItem(RULE_STATE, Values.create(true))- ),- new AssetAttribute("co2Level", AttributeType.DECIMAL, Values.create(450))- .setMeta(new Meta(- new MetaItem(LABEL, Values.create("CO2 Level")),- new MetaItem(RULE_STATE, Values.create(true))- ))- );+ ServerAsset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room");apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);apartment1LivingroomId = apartment1Livingroom.getId();- ServerAsset apartment1LivingroomThermostat = new ServerAsset("Living Room Thermostat", THING, apartment1Livingroom);- apartment1LivingroomThermostat.setAttributes(- new AssetAttribute("currentTemperature", DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Current temperature")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(PROTECTED, Values.create(true)),- new MetaItem(READ_ONLY, Values.create(true)),- new MetaItem(- Constants.NAMESPACE + ":foo:bar", Values.create("FOO")),- new MetaItem(- "urn:thirdparty:bar", Values.create("BAR"))- ),- new AssetAttribute("targetTemperature", DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Target Temperature")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(PROTECTED, Values.create(true)),- new MetaItem(Constants.NAMESPACE + ":foo:bar", Values.create("FOO")),- new MetaItem("urn:thirdparty:bar", Values.create("BAR")),- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME)- )- )- );- apartment1LivingroomThermostat = assetStorageService.merge(apartment1LivingroomThermostat);- apartment1LivingroomThermostatId = apartment1LivingroomThermostat.getId();+ ServerAsset apartment1ServiceAgent = createDemoApartmentServiceAgent(apartment1);+ apartment1ServiceAgent = assetStorageService.merge(apartment1ServiceAgent);+ apartment1ServiceAgentId = apartment1ServiceAgent.getId();- // Create scene and trigger agent- ServerAsset apartment1SceneAgent = new ServerAsset("Scenes and triggers", AGENT, apartment1);- apartment1SceneAgent.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));+ linkDemoApartmentWithServiceAgent(apartment1, apartment1ServiceAgent);+ apartment1 = assetStorageService.merge(apartment1);- // Add scenes- apartment1SceneAgent.setAttributes(- initProtocolConfiguration(new AssetAttribute("homeScene"), MacroProtocol.PROTOCOL_NAME)- .addMeta(- new MetaItem(LABEL, Values.create("Home scene")),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(false))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(21d))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("HOME"))).toMetaItem()- ),- initProtocolConfiguration(new AssetAttribute("awayScene"), MacroProtocol.PROTOCOL_NAME)- .addMeta(- new MetaItem(LABEL, Values.create("Away scene")),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(true))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(15d))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("AWAY"))).toMetaItem()- ),- initProtocolConfiguration(new AssetAttribute("eveningScene"), MacroProtocol.PROTOCOL_NAME)- .addMeta(- new MetaItem(LABEL, Values.create("Evening scene")),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(false))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(22d))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("EVENING"))).toMetaItem()- ),- initProtocolConfiguration(new AssetAttribute("nightScene"), MacroProtocol.PROTOCOL_NAME)- .addMeta(- new MetaItem(LABEL, Values.create("Night scene")),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(true))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(19d))).toMetaItem(),- new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("NIGHT"))).toMetaItem()- ),- // Add triggers- initTimerConfiguration(new AssetAttribute("homeMondayTrigger"), "0 0 7 ? * MON *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Monday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awayMondayTrigger"), "0 30 8 ? * MON *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Monday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningMondayTrigger"), "0 30 17 ? * MON *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Monday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightMondayTrigger"), "0 0 22 ? * MON *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Monday trigger"))- ),- initTimerConfiguration(new AssetAttribute("homeTuesdayTrigger"), "0 0 7 ? * TUE *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Tuesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awayTuesdayTrigger"), "0 30 8 ? * TUE *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Tuesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningTuesdayTrigger"), "0 30 17 ? * TUE *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Tuesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightTuesdayTrigger"), "0 0 22 ? * TUE *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Tuesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("homeWednesdayTrigger"), "0 0 7 ? * WED *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Wednesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awayWednesdayTrigger"), "0 30 8 ? * WED *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Wednesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningWednesdayTrigger"), "0 30 17 ? * WED *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Wednesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightWednesdayTrigger"), "0 0 22 ? * WED *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Wednesday trigger"))- ),- initTimerConfiguration(new AssetAttribute("homeThursdayTrigger"), "0 0 7 ? * THU *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Thursday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awayThursdayTrigger"), "0 30 8 ? * THU *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Thursday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningThursdayTrigger"), "0 30 17 ? * THU *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Thursday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightThursdayTrigger"), "0 0 22 ? * THU *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Thursday trigger"))- ),- initTimerConfiguration(new AssetAttribute("homeFridayTrigger"), "0 0 7 ? * FRI *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Friday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awayFridayTrigger"), "0 30 8 ? * FRI *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Friday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningFridayTrigger"), "0 30 17 ? * FRI *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Friday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightFridayTrigger"), "0 0 22 ? * FRI *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Friday trigger"))- ),- initTimerConfiguration(new AssetAttribute("homeSaturdayTrigger"), "0 0 8 ? * SAT *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Saturday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awaySaturdayTrigger"), "0 30 9 ? * SAT *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Saturday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningSaturdayTrigger"), "0 30 18 ? * SAT *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Saturday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightSaturdayTrigger"), "0 0 23 ? * SAT *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Saturday trigger"))- ),- initTimerConfiguration(new AssetAttribute("homeSundayTrigger"), "0 0 8 ? * SUN *",- new AttributeState(apartment1Id, "home", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Home Sunday trigger"))- ),- initTimerConfiguration(new AssetAttribute("awaySundayTrigger"), "0 30 9 ? * SUN *",- new AttributeState(apartment1Id, "away", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Sunday trigger"))- ),- initTimerConfiguration(new AssetAttribute("eveningSundayTrigger"), "0 30 18 ? * SUN *",- new AttributeState(apartment1Id, "evening", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Evening Sunday trigger"))- ),- initTimerConfiguration(new AssetAttribute("nightSundayTrigger"), "0 0 23 ? * SUN *",- new AttributeState(apartment1Id, "night", Values.create("REQUEST_START")))- .addMeta(- new MetaItem(LABEL, Values.create("Night Sunday trigger"))- )- );+ linkDemoApartmentRoomWithServiceAgent(apartment1Livingroom, apartment1ServiceAgent);+ apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);- apartment1SceneAgent = assetStorageService.merge(apartment1SceneAgent);- apartment1SceneAgentId = apartment1SceneAgent.getId();+ if (importDemoScenes) {+ Scene[] scenes = new Scene[]{+ new Scene("homeScene", "Home scene", "HOME", "0 0 7 ? *", false, 21d),+ new Scene("awayScene", "Away scene", "AWAY", "0 30 8 ? *", true, 15d),+ new Scene("eveningScene", "Evening scene", "EVENING", "0 30 17 ? *", false, 22d),+ new Scene("nightScene", "Night scene", "NIGHT", "0 0 22 ? *", true, 19d)+ };- // Update apartment 1 with scenes and triggers- apartment1.addAttributes(- new AssetAttribute("home", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home scene")),- new MetaItem(DESCRIPTION, Values.create("Execute the home scene")),- new MetaItem(EXECUTABLE, Values.create(true)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeScene").toArrayValue())- ),- new AssetAttribute("homeAlarmEnabled", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home alarm enabled")),- new MetaItem(DESCRIPTION, Values.create("Alarm enabled for home scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeScene").toArrayValue())- ),- new AssetAttribute("homeTargetTemperature", AttributeType.DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Home target temperature")),- new MetaItem(DESCRIPTION, Values.create("Target temperature for home scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(1)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeScene").toArrayValue())- ),- new AssetAttribute("away", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away scene")),- new MetaItem(DESCRIPTION, Values.create("Execute the away scene")),- new MetaItem(EXECUTABLE, Values.create(true)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayScene").toArrayValue())- ),- new AssetAttribute("awayAlarmEnabled", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away alarm enabled")),- new MetaItem(DESCRIPTION, Values.create("Alarm enabled for away scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayScene").toArrayValue())- ),- new AssetAttribute("awayTargetTemperature", AttributeType.DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Away target temperature")),- new MetaItem(DESCRIPTION, Values.create("Target temperature for away scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(1)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayScene").toArrayValue())- ),- new AssetAttribute("evening", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening scene")),- new MetaItem(DESCRIPTION, Values.create("Execute the evening scene")),- new MetaItem(EXECUTABLE, Values.create(true)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningScene").toArrayValue())- ),- new AssetAttribute("eveningAlarmEnabled", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening alarm enabled")),- new MetaItem(DESCRIPTION, Values.create("Alarm enabled for evening scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningScene").toArrayValue())- ),- new AssetAttribute("eveningTargetTemperature", AttributeType.DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Evening target temperature")),- new MetaItem(DESCRIPTION, Values.create("Target temperature for evening scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(1)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningScene").toArrayValue())- ),- new AssetAttribute("night", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night scene")),- new MetaItem(DESCRIPTION, Values.create("Execute the night scene")),- new MetaItem(EXECUTABLE, Values.create(true)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightScene").toArrayValue())- ),- new AssetAttribute("nightAlarmEnabled", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night alarm enabled")),- new MetaItem(DESCRIPTION, Values.create("Alarm enabled for night scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightScene").toArrayValue())- ),- new AssetAttribute("nightTargetTemperature", AttributeType.DECIMAL)- .setMeta(- new MetaItem(LABEL, Values.create("Night target temperature")),- new MetaItem(DESCRIPTION, Values.create("Target temperature for night scene")),- new MetaItem(META_MACRO_ACTION_INDEX, Values.create(1)),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightScene").toArrayValue())- ),- new AssetAttribute("homeTimeMONDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Monday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeMondayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledMONDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Monday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeMondayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeMONDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Monday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayMondayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledMONDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Monday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayMondayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeMONDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Monday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningMondayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledMONDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Monday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningMondayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeMONDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Monday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightMondayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledMONDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Monday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightMondayTrigger").toArrayValue())- ),- new AssetAttribute("homeTimeTUESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Tuesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledTUESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Tuesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeTUESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Tuesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledTUESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Tuesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeTUESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Tuesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledTUESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Tuesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeTUESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Tuesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledTUESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Tuesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightTuesdayTrigger").toArrayValue())- ),- new AssetAttribute("homeTimeWEDNESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Wednesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledWEDNESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Wednesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeWEDNESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Wednesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledWEDNESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Wednesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeWEDNESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Wednesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledWEDNESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Wednesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeWEDNESDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Wednesday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledWEDNESDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Wednesday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightWednesdayTrigger").toArrayValue())- ),- new AssetAttribute("homeTimeTHURSDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Thursday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeThursdayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledTHURSDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Thursday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeThursdayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeTHURSDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Thursday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayThursdayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledTHURSDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Thursday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayThursdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeTHURSDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Thursday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningThursdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledTHURSDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Thursday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningThursdayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeTHURSDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Thursday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightThursdayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledTHURSDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Thursday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightThursdayTrigger").toArrayValue())- ),- new AssetAttribute("homeTimeFRIDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Friday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeFridayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledFRIDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Friday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeFridayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeFRIDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Friday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayFridayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledFRIDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Friday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayFridayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeFRIDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Friday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningFridayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledFRIDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Friday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningFridayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeFRIDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Friday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightFridayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledFRIDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Friday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightFridayTrigger").toArrayValue())- ),- new AssetAttribute("homeTimeSATURDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Saturday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeSaturdayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledSATURDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Saturday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeSaturdayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeSATURDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Saturday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awaySaturdayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledSATURDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Saturday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awaySaturdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeSATURDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Saturday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningSaturdayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledSATURDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Saturday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningSaturdayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeSATURDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Saturday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightSaturdayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledSATURDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Saturday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightSaturdayTrigger").toArrayValue())- ),- new AssetAttribute("homeTimeSUNDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Home time Sunday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeSundayTrigger").toArrayValue())- ),- new AssetAttribute("homeEnabledSUNDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Home enabled Sunday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeSundayTrigger").toArrayValue())- ),- new AssetAttribute("awayTimeSUNDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Away time Sunday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awaySundayTrigger").toArrayValue())- ),- new AssetAttribute("awayEnabledSUNDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Away enabled Sunday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awaySundayTrigger").toArrayValue())- ),- new AssetAttribute("eveningTimeSUNDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Evening time Sunday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningSundayTrigger").toArrayValue())- ),- new AssetAttribute("eveningEnabledSUNDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Evening enabled Sunday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningSundayTrigger").toArrayValue())- ),- new AssetAttribute("nightTimeSUNDAY", AttributeType.STRING)- .setMeta(- new MetaItem(LABEL, Values.create("Night time Sunday")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightSundayTrigger").toArrayValue())- ),- new AssetAttribute("nightEnabledSUNDAY", AttributeType.BOOLEAN)- .setMeta(- new MetaItem(LABEL, Values.create("Night enabled Sunday")),- new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),- new MetaItem(AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightSundayTrigger").toArrayValue())- )- );+ ServerAsset demoApartmentSceneAgent = createDemoApartmentSceneAgent(+ apartment1, scenes, apartment1Livingroom+ );+ demoApartmentSceneAgent = assetStorageService.merge(demoApartmentSceneAgent);- apartment1 = assetStorageService.merge(apartment1);+ linkDemoApartmentWithSceneAgent(apartment1, demoApartmentSceneAgent, scenes);+ apartment1 = assetStorageService.merge(apartment1);+ }ServerAsset apartment2 = new ServerAsset("Apartment 2", RESIDENCE, smartHome);apartment2.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));@@ -1077,28 +399,24 @@ public class ManagerDemoSetup extends AbstractManagerSetup {),new AssetAttribute("presenceDetected", AttributeType.BOOLEAN, Values.create(false)).setMeta(- new MetaItem(LABEL, Values.create("Presence Detected")),- new MetaItem(DESCRIPTION, Values.create(- "Someone is currently present in the room"- )),- new MetaItem(RULE_STATE, Values.create(true))+ new MetaItem(LABEL, Values.create("Presence Detected")),+ new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),+ new MetaItem(RULE_STATE, Values.create(true))),new AssetAttribute("lastPresenceDetected", AttributeType.DECIMAL).setMeta(- new MetaItem(LABEL, Values.create("Last Presence Timestamp")),- new MetaItem(DESCRIPTION, Values.create(- "Timestamp of last detected presence"- )),- new MetaItem(RULE_STATE, Values.create(true))+ new MetaItem(LABEL, Values.create("Last Presence Timestamp")),+ new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),+ new MetaItem(RULE_STATE, Values.create(true))),new AssetAttribute("lightSwitch", AttributeType.BOOLEAN, Values.create(true)).setMeta(- new MetaItem(LABEL, Values.create("Light Switch")),- new MetaItem(RULE_STATE, Values.create(false))+ new MetaItem(LABEL, Values.create("Light Switch")),+ new MetaItem(RULE_STATE, Values.create(false))),new AssetAttribute("windowOpen", AttributeType.BOOLEAN, Values.create(false)).setMeta(- new MetaItem(LABEL, Values.create("Window Open"))+ new MetaItem(LABEL, Values.create("Window Open"))));apartment2Livingroom = assetStorageService.merge(apartment2Livingroom);@@ -1121,9 +439,291 @@ public class ManagerDemoSetup extends AbstractManagerSetup {identityService.setRestrictedUser(keycloakDemoSetup.testuser3Id, true);assetStorageService.storeUserAsset(keycloakDemoSetup.testuser3Id, apartment1Id);assetStorageService.storeUserAsset(keycloakDemoSetup.testuser3Id, apartment1LivingroomId);- assetStorageService.storeUserAsset(keycloakDemoSetup.testuser3Id, apartment1LivingroomThermostatId);assetStorageService.storeUserAsset(keycloakDemoSetup.testuser3Id, apartment2Id);+ }++ // ################################ Demo apartment with complex scenes ###################################++ protected ServerAsset createDemoApartment(ServerAsset parent, String name, Coordinate location) {+ ServerAsset apartment = new ServerAsset(name, RESIDENCE, parent);+ apartment.setLocation(geometryFactory.createPoint(location));+ apartment.setAttributes(+ new AssetAttribute("alarmEnabled", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(new Meta(+ new MetaItem(LABEL, Values.create("Alarm enabled")),+ new MetaItem(READ_ONLY, Values.create(true)),+ new MetaItem(DESCRIPTION, Values.create("Send notifications when presence is detected")),+ new MetaItem(RULE_STATE, Values.create(true))+ )),+ new AssetAttribute("vacationDays", AttributeType.INTEGER)+ .setMeta(new Meta(+ new MetaItem(LABEL, Values.create("Vacation days")),+ new MetaItem(DESCRIPTION, Values.create("Enable vacation mode for given days")),+ new MetaItem(RULE_STATE, Values.create(true))+ )),+ new AssetAttribute("autoSceneSchedule", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem(LABEL, Values.create("Automatic scene schedule")),+ new MetaItem(DESCRIPTION, Values.create("Predict presence and automatically adjust scene schedule")),+ new MetaItem(RULE_STATE, Values.create(true))+ ),+ new AssetAttribute("lastExecutedScene", AttributeType.STRING, Values.create("HOME"))+ .setMeta(+ new MetaItem(LABEL, Values.create("Last executed scene")),+ new MetaItem(READ_ONLY, Values.create(true)),+ new MetaItem(RULE_STATE, Values.create(true))+ )+ );+ return apartment;+ }++ protected ServerAsset createDemoApartmentRoom(ServerAsset apartment, String name) {+ ServerAsset room = new ServerAsset(name, ROOM, apartment);+ room.setLocation(apartment.getLocation());+ room.setAttributes(+ new AssetAttribute("motionCount", AttributeType.INTEGER)+ .setMeta(+ new MetaItem(LABEL, Values.create("Motion Count")),+ new MetaItem(DESCRIPTION, Values.create("Sensor that increments a counter when motion is detected")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(RULE_EVENT, Values.create(true))+ ),+ new AssetAttribute("presenceDetected", AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem(LABEL, Values.create("Presence Detected")),+ new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(PROTECTED, Values.create(true)),+ new MetaItem(READ_ONLY, Values.create(true))+ ),+ new AssetAttribute("lastPresenceDetected", AttributeType.DECIMAL)+ .setMeta(+ new MetaItem(LABEL, Values.create("Last Presence Timestamp")),+ new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(PROTECTED, Values.create(true)),+ new MetaItem(READ_ONLY, Values.create(true))+ ),+ new AssetAttribute("co2Level", AttributeType.DECIMAL)+ .setMeta(+ new MetaItem(LABEL, Values.create("CO2 Level")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(PROTECTED, Values.create(true)),+ new MetaItem(READ_ONLY, Values.create(true))+ ),+ new AssetAttribute("humidity", AttributeType.DECIMAL)+ .setMeta(+ new MetaItem(LABEL, Values.create("Humidity")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(PROTECTED, Values.create(true)),+ new MetaItem(READ_ONLY, Values.create(true))+ ),+ new AssetAttribute("currentTemperature", DECIMAL)+ .setMeta(+ new MetaItem(LABEL, Values.create("Current temperature")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(PROTECTED, Values.create(true)),+ new MetaItem(READ_ONLY, Values.create(true))+ ),+ new AssetAttribute("targetTemperature", DECIMAL)+ .setMeta(+ new MetaItem(LABEL, Values.create("Target Temperature")),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(PROTECTED, Values.create(true))+ )+ );+ return room;+ }++ protected ServerAsset createDemoApartmentServiceAgent(ServerAsset apartment) {+ ServerAsset agent = new ServerAsset("Service Agent (Simulator)", AGENT, apartment);+ agent.setLocation(apartment.getLocation());+ agent.setAttributes(+ initProtocolConfiguration(new AssetAttribute("apartmentSimulator"), SimulatorProtocol.PROTOCOL_NAME)+ .addMeta(+ new MetaItem(+ SimulatorProtocol.CONFIG_MODE,+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_DELAYED.toString())+ ),+ new MetaItem(+ SimulatorProtocol.CONFIG_WRITE_DELAY_MILLISECONDS,+ Values.create(500)+ )),+ initProtocolConfiguration(new AssetAttribute("roomSimulator"), SimulatorProtocol.PROTOCOL_NAME)+ .addMeta(+ new MetaItem(+ SimulatorProtocol.CONFIG_MODE,+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_DELAYED.toString())+ ),+ new MetaItem(+ SimulatorProtocol.CONFIG_WRITE_DELAY_MILLISECONDS,+ Values.create(500)+ ))+ );+ return agent;+ }++ protected void linkDemoApartmentWithServiceAgent(ServerAsset apartment, ServerAsset agent) {+ for (AssetAttribute attribute : apartment.getAttributesList()) {+ String name = attribute.getName().orElseThrow(+ () -> new IllegalStateException("Missing apartment attribute name: " + attribute)+ );+ switch (name) {+ // TODO Any attributes of apartment to link with simulator?+ }+ }+ }++ protected void linkDemoApartmentRoomWithServiceAgent(ServerAsset room, ServerAsset agent) {+ for (AssetAttribute attribute : room.getAttributesList()) {+ String name = attribute.getName().orElseThrow(+ () -> new IllegalStateException("Missing apartment room attribute name: " + attribute)+ );+ switch (name) {+ case "motionCount":+ attribute.getMeta().add(+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "roomSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(IntegerSimulatorElement.ELEMENT_NAME_INTEGER))+ );+ break;+ case "co2Level":+ attribute.getMeta().add(+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "roomSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ );+ break;+ case "humidity":+ attribute.getMeta().add(+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "roomSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ );+ break;+ case "currentTemperature":+ attribute.getMeta().add(+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "roomSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ );+ break;+ case "targetTemperature":+ attribute.getMeta().add(+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "roomSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ );+ break;+ }+ }+ }++ public static class Scene {++ final String attributeName;+ final String attributeLabel;+ final String internalName;+ final String startTime;+ final boolean alarmEnabled;+ final double targetTemperature;++ public Scene(String attributeName,+ String attributeLabel,+ String internalName,+ String startTime,+ boolean alarmEnabled,+ double targetTemperature) {+ this.attributeName = attributeName;+ this.attributeLabel = attributeLabel;+ this.internalName = internalName;+ this.startTime = startTime;+ this.alarmEnabled = alarmEnabled;+ this.targetTemperature = targetTemperature;+ }++ AssetAttribute createMacroAttribute(ServerAsset apartment, ServerAsset... rooms) {+ AssetAttribute attribute = initProtocolConfiguration(new AssetAttribute(attributeName), MacroProtocol.PROTOCOL_NAME)+ .addMeta(new MetaItem(LABEL, Values.create(attributeLabel)));+ attribute.getMeta().add(+ new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), "alarmEnabled"), Values.create(alarmEnabled))).toMetaItem()+ );+ for (ServerAsset room : rooms) {+ attribute.getMeta().add(+ new MacroAction(new AttributeState(new AttributeRef(room.getId(), "targetTemperature"), Values.create(targetTemperature))).toMetaItem()+ );+ }+ attribute.getMeta().add(+ new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), "lastExecutedScene"), Values.create(internalName))).toMetaItem()+ );+ return attribute;+ }++ AssetAttribute[] createTimerAttributes(ServerAsset apartment) {+ List<AssetAttribute> attributes = new ArrayList<>();+ for (DayOfWeek dayOfWeek : DayOfWeek.values()) {+ // "MONDAY" => "Monday"+ String dayName = dayOfWeek.name().substring(0, 1) + dayOfWeek.name().substring(1).toLowerCase(Locale.ROOT);+ // "0 0 7 ? *" => "0 0 7 ? * MON *"+ String timePattern = startTime + " " + dayOfWeek.name().substring(0, 3).toUpperCase(Locale.ROOT) + " *";+ attributes.add(+ initTimerConfiguration(new AssetAttribute(attributeName + dayName), timePattern,+ new AttributeState(apartment.getId(), attributeName, Values.create("REQUEST_START")))+ .addMeta(new MetaItem(LABEL, Values.create(attributeLabel + " trigger " + dayName)))+ );+ }+ return attributes.toArray(new AssetAttribute[attributes.size()]);+ }+ }+ protected ServerAsset createDemoApartmentSceneAgent(ServerAsset apartment, Scene[] scenes, ServerAsset... rooms) {+ ServerAsset agent = new ServerAsset("Scene Agent", AGENT, apartment);+ agent.setLocation(apartment.getLocation());+ for (Scene scene : scenes) {+ agent.addAttributes(scene.createMacroAttribute(apartment, rooms));+ }+ for (Scene scene : scenes) {+ agent.addAttributes(scene.createTimerAttributes(apartment));+ }+ return agent;+ }+ protected void linkDemoApartmentWithSceneAgent(ServerAsset apartment, ServerAsset agent, Scene[] scenes) {+ for (Scene scene : scenes) {+ apartment.addAttributes(+ new AssetAttribute(scene.attributeName, AttributeType.STRING, Values.create(AttributeExecuteStatus.READY.name()))+ .setMeta(+ new MetaItem(LABEL, Values.create(scene.attributeLabel)),+ new MetaItem(EXECUTABLE, Values.create(true)),+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())+ ),+ new AssetAttribute(scene.attributeName + "AlarmEnabled", AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem(LABEL, Values.create(scene.attributeLabel + " alarm enabled")),+ new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)),+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())+ ),+ new AssetAttribute(scene.attributeName + "TargetTemperature", AttributeType.DECIMAL)+ .setMeta(+ new MetaItem(LABEL, Values.create(scene.attributeLabel + " target temperature")),+ new MetaItem(META_MACRO_ACTION_INDEX, Values.create(1)),+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())+ )+ );+ for (DayOfWeek dayOfWeek : DayOfWeek.values()) {+ // "MONDAY" => "Monday"+ String dayName = dayOfWeek.name().substring(0, 1) + dayOfWeek.name().substring(1).toLowerCase(Locale.ROOT);+ apartment.addAttributes(+ new AssetAttribute(scene.attributeName + "Time" + dayOfWeek.name(), AttributeType.STRING)+ .setMeta(+ new MetaItem(LABEL, Values.create(scene.attributeLabel + " time " + dayName)),+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName + dayName).toArrayValue())+ ),+ new AssetAttribute(scene.attributeName + "Enabled" + dayOfWeek.name(), AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem(LABEL, Values.create(scene.attributeLabel + " enabled " + dayName)),+ new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())),+ new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName + dayName).toArrayValue())+ )+ );+ }+ }}-}+}\ No newline at end of filediff --git a/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovyindex 9db8c1770..35a057c09 100644--- a/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy+++ b/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy@@ -65,29 +65,29 @@ trait ManagerContainerTrait extends ContainerTrait {defaultServices(Arrays.asList(additionalServices))}- /**- * Faster startup - Start a container with no demo rules- */- static Container startContainerNoDemoRules(Map<String, String> config, Iterable<ContainerService> services) {- startContainer(config << [(SETUP_IMPORT_DEMO_RULES): "false"], services)+ static Container startContainerNoDemoScenes(Map<String, String> config, Iterable<ContainerService> services) {+ config << [(SETUP_IMPORT_DEMO_SCENES): "false"]+ startContainer(config, services);}- /**- * Faster startup - Start a container with no demo assets or rules- */- static Container startContainerNoDemoRulesOrAssets(Map<String, String> config, Iterable<ContainerService> services) {- config << [(SETUP_IMPORT_DEMO_ASSETS): "false"]+ static Container startContainerNoDemoScenesOrRules(Map<String, String> config, Iterable<ContainerService> services) {+ config << [(SETUP_IMPORT_DEMO_SCENES): "false"]config << [(SETUP_IMPORT_DEMO_RULES): "false"]startContainer(config, services);}- /**- * Faster startup - Start a container with no demo users, assets or rules- */- static Container startContainerMinimal(Map<String, String> config, Iterable<ContainerService> services) {- config << [(SETUP_IMPORT_DEMO_USERS): "false"]+ static Container startContainerNoDemoScenesOrRulesOrAssets(Map<String, String> config, Iterable<ContainerService> services) {+ config << [(SETUP_IMPORT_DEMO_SCENES): "false"]+ config << [(SETUP_IMPORT_DEMO_RULES): "false"]config << [(SETUP_IMPORT_DEMO_ASSETS): "false"]+ startContainer(config, services);+ }++ static Container startContainerNoDemoImport(Map<String, String> config, Iterable<ContainerService> services) {+ config << [(SETUP_IMPORT_DEMO_SCENES): "false"]config << [(SETUP_IMPORT_DEMO_RULES): "false"]+ config << [(SETUP_IMPORT_DEMO_ASSETS): "false"]+ config << [(SETUP_IMPORT_DEMO_USERS): "false"]startContainer(config, services);}diff --git a/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy b/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovyindex d419bbff3..835eaf781 100644--- a/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy@@ -46,7 +46,7 @@ class AdminTenantsActivityTest extends Specification implements ManagerContainergiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRulesOrAssets(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRulesOrAssets(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)and: "expected results"diff --git a/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy b/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovyindex cf3670132..7384a5c6a 100644--- a/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy@@ -43,7 +43,7 @@ class AdminUsersActivityTest extends Specification implements ManagerContainerTrgiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRulesOrAssets(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRulesOrAssets(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)and: "expected results"diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovyindex 4c9dc18b9..61b7c7e7a 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy@@ -43,7 +43,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainegiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)def assetStorageService = container.getService(AssetStorageService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -212,7 +212,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainegiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)def assetStorageService = container.getService(AssetStorageService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -390,7 +390,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainegiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)def assetStorageService = container.getService(AssetStorageService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovyindex 4fdcaf361..3a3b3ddf0 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy@@ -20,10 +20,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTraitwhen: "the demo agent and thing have been deployed"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(- defaultConfig(serverPort),- defaultServices()- )+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def simulatorProtocol = container.getService(SimulatorProtocol.class)def assetStorageService = container.getService(AssetStorageService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovyindex b06d84c4e..6b4a48d61 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy@@ -26,7 +26,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTraitdef "Test asset changes as superuser"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovyindex 636206ffc..e6c7486f4 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy@@ -28,7 +28,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef "Access assets as superuser"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def conditions = new PollingConditions(delay: 1, timeout: 5)@@ -153,8 +153,8 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiex.response.status == 404when: "an asset is deleted in a foreign realm"- assetResource.delete(null, managerDemoSetup.apartment1LivingroomThermostatId)- assetResource.get(null, managerDemoSetup.apartment1LivingroomThermostatId)+ assetResource.delete(null, managerDemoSetup.apartment2LivingroomId)+ assetResource.get(null, managerDemoSetup.apartment2LivingroomId)then: "the asset should be not found"ex = thrown()@@ -203,7 +203,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraigiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def conditions = new PollingConditions(delay: 1, timeout: 10)@@ -327,8 +327,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiex.response.status == 404when: "an asset is deleted in a foreign realm"- assetResource.delete(null, managerDemoSetup.apartment1LivingroomThermostatId)- assetResource.get(null, managerDemoSetup.apartment1LivingroomThermostatId)+ assetResource.delete(null, managerDemoSetup.apartment2LivingroomId)then: "access should be forbidden"ex = thrown()@@ -358,7 +357,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef "Access assets as testuser2"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -455,7 +454,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiex.response.status == 403when: "an asset is deleted in the authenticated realm"- assetResource.delete(null, managerDemoSetup.apartment1LivingroomThermostatId)+ assetResource.delete(null, managerDemoSetup.apartment2LivingroomId)then: "access should be forbidden"ex = thrown()@@ -489,7 +488,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef "Access assets as testuser3"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def conditions = new PollingConditions(delay: 1, timeout: 5)@@ -512,7 +511,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef assets = assetResource.getCurrentUserAssets(null)then: "result should match"- assets.length == 4+ assets.length == 3Asset apartment1 = assets[0]apartment1.id == managerDemoSetup.apartment1Idapartment1.name == "Apartment 1"@@ -529,11 +528,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiapartment1Livingroom.id == managerDemoSetup.apartment1LivingroomIdapartment1Livingroom.name == "Living Room"- Asset apartment1LivingroomThermostat = assets[2]- apartment1LivingroomThermostat.id == managerDemoSetup.apartment1LivingroomThermostatId- apartment1LivingroomThermostat.name == "Living Room Thermostat"-- Asset apartment2 = assets[3]+ Asset apartment2 = assets[2]apartment2.id == managerDemoSetup.apartment2Idapartment2.name == "Apartment 2"@@ -581,14 +576,14 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiex.response.status == 403when: "a user asset is retrieved by ID in the authenticated realm"- apartment1LivingroomThermostat = assetResource.get(null, managerDemoSetup.apartment1LivingroomThermostatId)+ apartment1Livingroom = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)then: "the protected asset details should be available"- apartment1LivingroomThermostat.id == managerDemoSetup.apartment1LivingroomThermostatId- apartment1LivingroomThermostat.name == "Living Room Thermostat"- def protectedAttributes = apartment1LivingroomThermostat.getAttributesList()- protectedAttributes.size() == 2- def currentTemperature = apartment1LivingroomThermostat.getAttribute("currentTemperature").get()+ apartment1Livingroom.id == managerDemoSetup.apartment1LivingroomId+ apartment1Livingroom.name == "Living Room"+ def protectedAttributes = apartment1Livingroom.getAttributesList()+ protectedAttributes.size() == 6+ def currentTemperature = apartment1Livingroom.getAttribute("currentTemperature").get()currentTemperature.getType().get() == AttributeType.DECIMAL!currentTemperature.getValue().isPresent()Meta protectedMeta = currentTemperature.getMeta()@@ -655,18 +650,18 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiex.response.status == 404when: "a protected read-only asset attribute is written on a user asset"- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomThermostatId, "currentTemperature", Values.create(22.123).toJson())+ assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomId, "currentTemperature", Values.create(22.123).toJson())then: "the request should be forbidden"ex = thrown()ex.response.status == 403when: "a protected asset attribute is written on a user asset"- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomThermostatId, "targetTemperature", Values.create(22.123).toJson())+ assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomId, "targetTemperature", Values.create(22.123).toJson())then: "result should match"conditions.eventually {- def asset = assetResource.get(null, managerDemoSetup.apartment1LivingroomThermostatId)+ def asset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)assert asset.getAttribute("targetTemperature").get().getValue().isPresent()assert asset.getAttribute("targetTemperature").get().getValue().get().toJson() == Values.create(22.123).toJson()}diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovyindex 594770567..4d74d4427 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy@@ -103,7 +103,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitwhen: "the container is started with the mock protocol and consumers"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices(mockProtocol))+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices(mockProtocol))def assetStorageService = container.getService(AssetStorageService.class)def assetProcessingService = container.getService(AssetProcessingService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovyindex 7cfc43791..c1c42952a 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy@@ -24,7 +24,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {def "Query assets"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def assetStorageService = container.getService(AssetStorageService.class)@@ -221,11 +221,10 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {)then: "result should match"- assets.size() == 4+ assets.size() == 3assets.get(0).id == managerDemoSetup.apartment1Idassets.get(1).id == managerDemoSetup.apartment1LivingroomId- assets.get(2).id == managerDemoSetup.apartment1LivingroomThermostatId- assets.get(3).id == managerDemoSetup.apartment1SceneAgentId+ assets.get(2).id == managerDemoSetup.apartment1ServiceAgentIdwhen: "a query is executed"assets = assetStorageService.findAll(@@ -244,16 +243,15 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {)then: "result should match"- assets.size() == 4+ assets.size() == 3assets.get(0).id == managerDemoSetup.apartment1Idassets.get(1).id == managerDemoSetup.apartment1LivingroomId- assets.get(2).id == managerDemoSetup.apartment1LivingroomThermostatId- assets.get(2).getAttributesList().size() == 2- !assets.get(2).getAttribute("currentTemperature").get().getValue().isPresent()- assets.get(2).getAttribute("currentTemperature").get().meta.size() == 3- !assets.get(2).getAttribute("targetTemperature").get().getValue().isPresent()- assets.get(2).getAttribute("targetTemperature").get().meta.size() == 2- assets.get(3).id == managerDemoSetup.apartment2Id+ assets.get(1).getAttributesList().size() == 6+ !assets.get(1).getAttribute("currentTemperature").get().getValue().isPresent()+ assets.get(1).getAttribute("currentTemperature").get().meta.size() == 3+ !assets.get(1).getAttribute("targetTemperature").get().getValue().isPresent()+ assets.get(1).getAttribute("targetTemperature").get().meta.size() == 2+ assets.get(2).id == managerDemoSetup.apartment2Idwhen: "a query is executed"assets = assetStorageService.findAll(@@ -266,7 +264,6 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {expect: "a result to match the executed query "assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1Id)assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1LivingroomId)- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1LivingroomThermostatId)assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment2Id)!assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment3Id)!assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.smartOfficeId)@@ -279,7 +276,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"assets.size() == 2assets.get(0).id == managerDemoSetup.agentId- assets.get(1).id == managerDemoSetup.apartment1SceneAgentId+ assets.get(1).id == managerDemoSetup.apartment1ServiceAgentIdwhen: "a query is executed"assets = assetStorageService.findAll(new AssetQuery()diff --git a/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy b/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovyindex df490b4a3..1a79e80f4 100644--- a/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy@@ -14,7 +14,7 @@ class MapResourceTest extends Specification implements ManagerContainerTrait {def "Retrieve map settings"() {given: "the server container is started"def serverPort = findEphemeralPort();- def container = startContainerMinimal(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoImport(defaultConfig(serverPort), defaultServices())and: "an authenticated user"def realm = MASTER_REALM;diff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovyindex 645d565e1..67dde7445 100644--- a/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy@@ -144,7 +144,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait {and: "the container is started with the mock protocol"def serverPort = findEphemeralPort()- def container = startContainerMinimal(defaultConfig(serverPort), defaultServices(mockProtocol))+ def container = startContainerNoDemoImport(defaultConfig(serverPort), defaultServices(mockProtocol))def assetStorageService = container.getService(AssetStorageService.class)def agentService = container.getService(AgentService.class)def assetProcessingService = container.getService(AssetProcessingService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovyindex 5884b14e4..8dd52f155 100644--- a/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy@@ -19,90 +19,91 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {when: "the container starts"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainer(defaultConfig(serverPort), defaultServices())def assetStorageService = container.getService(AssetStorageService.class)def assetProcessingService = container.getService(AssetProcessingService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)then: "the container should be running and attributes linked"conditions.eventually {- assert isContainerRunning()+ assertNothingProcessedFor(assetProcessingService, 500)+def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- assert apartment1.getAttribute("home").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()- assert apartment1.getAttribute("away").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()- assert apartment1.getAttribute("evening").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()- assert apartment1.getAttribute("night").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()- assert !apartment1.getAttribute("homeAlarmEnabled").get().getValueAsBoolean().orElse(true)- assert apartment1.getAttribute("homeTargetTemperature").get().getValueAsNumber().orElse(0d) == 21d+ assert apartment1.getAttribute("homeScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()+ assert apartment1.getAttribute("awayScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()+ assert apartment1.getAttribute("eveningScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()+ assert apartment1.getAttribute("nightScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()+ assert !apartment1.getAttribute("homeSceneAlarmEnabled").get().getValueAsBoolean().orElse(true)+ assert apartment1.getAttribute("homeSceneTargetTemperature").get().getValueAsNumber().orElse(0d) == 21d}when: "Apartment 1 home scene is executed"- def macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "home", AttributeExecuteStatus.REQUEST_START.asValue())+ def macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "homeScene", AttributeExecuteStatus.REQUEST_START.asValue())assetProcessingService.sendAttributeEvent(macroExecute)then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be updated to match the scene"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- def thermostat1 = assetStorageService.find(managerDemoSetup.apartment1LivingroomThermostatId, true)+ def livingRoom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)assert !apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(true)assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "HOME"- assert thermostat1.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 21d+ assert livingRoom.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 21d}then: "Apartment 1 home scene attribute status should show as COMPLETED"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- assert apartment1.getAttribute("home").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()+ assert apartment1.getAttribute("homeScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()}when: "Apartment 1 away scene is executed"- macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "away", AttributeExecuteStatus.REQUEST_START.asValue())+ macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "awayScene", AttributeExecuteStatus.REQUEST_START.asValue())assetProcessingService.sendAttributeEvent(macroExecute)then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be update to match the scene"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- def thermostat1 = assetStorageService.find(managerDemoSetup.apartment1LivingroomThermostatId, true)+ def livingRoom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)assert apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(false)assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "AWAY"- assert thermostat1.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 15d+ assert livingRoom.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 15d}then: "Apartment 1 away scene attribute status should show as COMPLETED"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- assert apartment1.getAttribute("away").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()+ assert apartment1.getAttribute("awayScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()}when: "The target temperature of the home scene is modified via the apartment attribute"- def updateTargetTemp = new AttributeEvent(managerDemoSetup.apartment1Id, "homeTargetTemperature", Values.create(10d))+ def updateTargetTemp = new AttributeEvent(managerDemoSetup.apartment1Id, "homeSceneTargetTemperature", Values.create(10d))assetProcessingService.sendAttributeEvent(updateTargetTemp)then: "Apartment 1 home scene attribute status should reset to show as READY and home target temp should show new value"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- assert apartment1.getAttribute("home").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()- assert apartment1.getAttribute("homeTargetTemperature").get().getValueAsNumber().orElse(0d) == 10d- assert !apartment1.getAttribute("homeAlarmEnabled").get().getValueAsBoolean().orElse(true)+ assert apartment1.getAttribute("homeScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()+ assert apartment1.getAttribute("homeSceneTargetTemperature").get().getValueAsNumber().orElse(0d) == 10d+ assert !apartment1.getAttribute("homeSceneAlarmEnabled").get().getValueAsBoolean().orElse(true)}when: "Apartment 1 home scene is executed"- macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "home", AttributeExecuteStatus.REQUEST_START.asValue())+ macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "homeScene", AttributeExecuteStatus.REQUEST_START.asValue())assetProcessingService.sendAttributeEvent(macroExecute)then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be updated to match the scene"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- def thermostat1 = assetStorageService.find(managerDemoSetup.apartment1LivingroomThermostatId, true)+ def livingRoom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)assert !apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(true)assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "HOME"- assert thermostat1.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 10d+ assert livingRoom.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 10d}then: "Apartment 1 home scene attribute status should show as COMPLETED"conditions.eventually {def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)- assert apartment1.getAttribute("home").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()+ assert apartment1.getAttribute("homeScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()}cleanup: "the server should be stopped"diff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovyindex b925a8e4f..d4fec1616 100644--- a/manager/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy@@ -22,14 +22,15 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {when: "the container starts"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def assetStorageService = container.getService(AssetStorageService.class)def assetProcessingService = container.getService(AssetProcessingService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)then: "the container should be running and attributes linked"conditions.eventually {- assert isContainerRunning()+ assertNothingProcessedFor(assetProcessingService, 500)+def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)assert apartment1.getAttribute("home").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()assert apartment1.getAttribute("away").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovyindex fd7f407bf..ee43518f4 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy@@ -28,7 +28,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex 5023fbd4d..ee4f1b5f5 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -79,7 +79,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -187,7 +187,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -274,7 +274,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -446,7 +446,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovyindex 9c9f05430..0bffc122e 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy@@ -31,7 +31,7 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContaand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def rulesService = container.getService(RulesService.class)def rulesetStorageService = container.getService(RulesetStorageService.class)@@ -73,7 +73,7 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContagiven: "the container environment is started"def conditions = new PollingConditions(timeout: 30, delay: 1)def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort) << [(TIMER_CLOCK_TYPE): PSEUDO.name()], defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort) << [(TIMER_CLOCK_TYPE): PSEUDO.name()], defaultServices())def rulesService = container.getService(RulesService.class)def rulesetStorageService = container.getService(RulesetStorageService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovyindex a489688d7..081138e9a 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy@@ -25,7 +25,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerdef "Access rules as superuser"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -295,7 +295,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainergiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -525,7 +525,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainergiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -673,7 +673,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainergiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentNotificationWhenAlarmTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentNotificationWhenAlarmTest.groovyindex d3b139cf9..59c8bb181 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentNotificationWhenAlarmTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentNotificationWhenAlarmTest.groovy@@ -13,6 +13,7 @@ import spock.lang.Specificationimport spock.util.concurrent.PollingConditionsimport static org.openremote.manager.server.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1+import static org.openremote.manager.server.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1_WITH_SCENESclass ApartmentNotificationWhenAlarmTest extends Specification implements ManagerContainerTrait {@@ -37,8 +38,8 @@ class ApartmentNotificationWhenAlarmTest extends Specification implements Managand: "the demo attributes marked with RULE_STATE = true meta should be inserted into the engines"conditions.eventually {- assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1- assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1+ assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES+ assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES}and: "the alarm enabled, presence detected flag and timestamp of the room should not be set"diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentVacationModeTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentVacationModeTest.groovyindex 763dedd6d..7aa9214f7 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentVacationModeTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/apartment/ApartmentVacationModeTest.groovy@@ -14,6 +14,7 @@ import spock.util.concurrent.PollingConditionsimport static java.util.concurrent.TimeUnit.*import static org.openremote.manager.server.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1+import static org.openremote.manager.server.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1_WITH_SCENESclass ApartmentVacationModeTest extends Specification implements ManagerContainerTrait {@@ -38,8 +39,8 @@ class ApartmentVacationModeTest extends Specification implements ManagerContaineand: "the demo attributes marked with RULE_STATE = true meta should be inserted into the engines"conditions.eventually {- assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1- assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1+ assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES+ assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES}when: "the vacation days are set to 5"diff --git a/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy b/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovyindex 224d603b1..df27370e3 100644--- a/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy@@ -5,7 +5,6 @@ import org.openremote.manager.server.setup.SetupServiceimport org.openremote.manager.server.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.server.setup.builtin.ManagerDemoSetupimport org.openremote.manager.shared.notification.NotificationResource-import org.openremote.model.asset.AssetQueryimport org.openremote.model.notification.ActionTypeimport org.openremote.model.notification.AlertActionimport org.openremote.model.notification.AlertNotification@@ -14,7 +13,6 @@ import org.openremote.test.ManagerContainerTraitimport spock.lang.Specificationimport static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID-import static org.openremote.model.Constants.MASTER_REALMclass NotificationServiceTest extends Specification implements ManagerContainerTrait {@@ -22,7 +20,7 @@ class NotificationServiceTest extends Specification implements ManagerContainerTgiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoScenesOrRules(defaultConfig(serverPort), defaultServices())def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def notificationService = container.getService(NotificationService.class)diff --git a/model/src/main/java/org/openremote/model/asset/Asset.java b/model/src/main/java/org/openremote/model/asset/Asset.javaindex 770ab3f54..86da3094b 100644--- a/model/src/main/java/org/openremote/model/asset/Asset.java+++ b/model/src/main/java/org/openremote/model/asset/Asset.java@@ -356,6 +356,9 @@ public class Asset implements IdentifiableEntity {throw new IllegalArgumentException("Attribute cannot be null and must have a name and type");attribute.assetId = getId();+ if (attributes == null) {+ attributes = Values.createObject();+ }attributes.put(attribute.getName().get(), attribute.getObjectValue());}diff --git a/model/src/main/java/org/openremote/model/attribute/Meta.java b/model/src/main/java/org/openremote/model/attribute/Meta.javaindex 68367fb2a..d8d79fc91 100644--- a/model/src/main/java/org/openremote/model/attribute/Meta.java+++ b/model/src/main/java/org/openremote/model/attribute/Meta.java@@ -22,10 +22,7 @@ package org.openremote.model.attribute;import org.openremote.model.value.ArrayValue;import org.openremote.model.value.Values;-import java.util.AbstractList;-import java.util.Collections;-import java.util.NoSuchElementException;-import java.util.Objects;+import java.util.*;/*** A {@link java.util.List} of {@link MetaItem} elements, wrapping an {@link ArrayValue}.@@ -84,6 +81,12 @@ public class Meta extends AbstractList<MetaItem> {arrayValue.add(index, item.getObjectValue());}+ public void add(MetaItem... items) {+ if (items != null) {+ addAll(Arrays.asList(items));+ }+ }+@Overridepublic MetaItem remove(int index) {checkBounds(index);