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
Setup data import improvements
Christian Bauer1b3601ea1f9b
diff --git a/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.java b/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.javaindex 2c1afe766..3f1c1a3fa 100644--- a/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/notification/NotificationService.java@@ -19,7 +19,6 @@*/package org.openremote.manager.server.notification;-import org.apache.http.NoHttpResponseException;import org.jboss.resteasy.client.jaxrs.ResteasyClient;import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;@@ -27,7 +26,6 @@ import org.openremote.container.Container;import org.openremote.container.ContainerService;import org.openremote.container.persistence.PersistenceService;import org.openremote.container.web.WebService;-import org.openremote.model.asset.AssetQuery;import org.openremote.model.notification.AlertNotification;import org.openremote.model.notification.DeliveryStatus;import org.openremote.model.user.UserQuery;@@ -45,18 +43,20 @@ public class NotificationService implements ContainerService {private static final Logger LOG = Logger.getLogger(NotificationService.class.getName());- protected PersistenceService persistenceService;+ public static final String NOTIFICATION_FIREBASE_API_KEY = "NOTIFICATION_FIREBASE_API_KEY";+ public static final String NOTIFICATION_FIREBASE_URL = "NOTIFICATION_FIREBASE_URL";+ public static final String NOTIFICATION_FIREBASE_URL_DEFAULT = "https://fcm.googleapis.com/fcm/send";+ protected PersistenceService persistenceService;protected ResteasyWebTarget target;-private String fcmKey;@Overridepublic void init(Container container) throws Exception {- fcmKey = container.getConfig().get("FCM_KEY");+ fcmKey = container.getConfig().get(NOTIFICATION_FIREBASE_API_KEY);if (fcmKey == null) {- LOG.info("FCM_KEY not defined, notification service cannot send fcm notification");+ LOG.info(NOTIFICATION_FIREBASE_API_KEY + " not defined, can not send notifications to user devices");}this.persistenceService = container.getService(PersistenceService.class);@@ -65,7 +65,7 @@ public class NotificationService implements ContainerService {);ResteasyClient client = new ResteasyClientBuilder().build();- target = client.target("https://fcm.googleapis.com/fcm/send");+ target = client.target(container.getConfig().getOrDefault(NOTIFICATION_FIREBASE_URL, NOTIFICATION_FIREBASE_URL_DEFAULT));}@Override@@ -107,7 +107,7 @@ public class NotificationService implements ContainerService {persistenceService.doTransaction((EntityManager entityManager) -> {entityManager.merge(alertNotification);if (fcmKey == null) {- LOG.info("No FCM key configured, can't send to '" + userId + "', not sending: " + alertNotification);+ LOG.info("No " + NOTIFICATION_FIREBASE_API_KEY + " configured, not sending to '" + userId + "': " + alertNotification);return;}List<DeviceNotificationToken> allTokenForUser = findAllTokenForUser(userId);diff --git a/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java b/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.javaindex a9a43221a..a26d72966 100644--- a/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java@@ -163,8 +163,10 @@ public class ManagerIdentityService extends IdentityService {});}- public void configureRealm(RealmRepresentation realmRepresentation) {+ public void configureRealm(RealmRepresentation realmRepresentation, TenantEmailConfig emailConfig) {configureRealm(realmRepresentation, ACCESS_TOKEN_LIFESPAN_SECONDS);+ if (emailConfig != null)+ realmRepresentation.setSmtpServer(emailConfig.asMap());}public void createTenant(String forwardFor, String accessToken, Tenant tenant) throws Exception {@@ -174,10 +176,7 @@ public class ManagerIdentityService extends IdentityService {public void createTenant(String forwardFor, String accessToken, Tenant tenant, TenantEmailConfig emailConfig) throws Exception {LOG.fine("Create tenant: " + tenant);RealmRepresentation realmRepresentation = convert(Container.JSON, RealmRepresentation.class, tenant);- if (emailConfig != null) {- realmRepresentation.setSmtpServer(emailConfig.asMap());- }- configureRealm(realmRepresentation);+ configureRealm(realmRepresentation, emailConfig);getRealms(forwardFor, accessToken).create(realmRepresentation);// TODO This is not atomic, write compensation actionscreateClientApplication(forwardFor, accessToken, realmRepresentation.getRealm());diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.javaindex c7493b27a..74a8f4cf7 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractKeycloakSetup.java@@ -25,8 +25,12 @@ import org.keycloak.admin.client.resource.UsersResource;import org.keycloak.representations.idm.ClientRepresentation;import org.openremote.container.Container;import org.openremote.container.security.AuthForm;+import org.openremote.container.util.MapAccess;import org.openremote.manager.server.security.ManagerIdentityService;+import org.openremote.manager.shared.security.TenantEmailConfig;+import static org.openremote.container.util.MapAccess.getBoolean;+import static org.openremote.container.util.MapAccess.getInteger;import static org.openremote.model.Constants.*;public abstract class AbstractKeycloakSetup implements Setup {@@ -38,6 +42,20 @@ public abstract class AbstractKeycloakSetup implements Setup {public static final String SETUP_KEYCLOAK_ADMIN_PASSWORD = "SETUP_KEYCLOAK_ADMIN_PASSWORD";public static final String SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT = "secret";+ public static final String SETUP_KEYCLOAK_EMAIL_HOST = "SETUP_KEYCLOAK_EMAIL_HOST";+ public static final String SETUP_KEYCLOAK_EMAIL_HOST_DEFAULT = "smtp-host.demo.tld";+ public static final String SETUP_KEYCLOAK_EMAIL_USER = "SETUP_KEYCLOAK_EMAIL_USER";+ public static final String SETUP_KEYCLOAK_EMAIL_USER_DEFAULT = "smtp-user";+ public static final String SETUP_KEYCLOAK_EMAIL_PASSWORD = "SETUP_KEYCLOAK_EMAIL_PASSWORD";+ public static final String SETUP_KEYCLOAK_EMAIL_PASSWORD_DEFAULT = "smtp-password";+ public static final String SETUP_KEYCLOAK_EMAIL_PORT = "SETUP_KEYCLOAK_EMAIL_PORT";+ public static final int SETUP_KEYCLOAK_EMAIL_PORT_DEFAULT = 25;+ public static final String SETUP_KEYCLOAK_EMAIL_AUTH = "SETUP_KEYCLOAK_EMAIL_AUTH";+ public static final boolean SETUP_KEYCLOAK_EMAIL_AUTH_DEFAULT = true;+ public static final String SETUP_KEYCLOAK_EMAIL_TLS = "SETUP_KEYCLOAK_EMAIL_TLS";+ public static final boolean SETUP_KEYCLOAK_EMAIL_TLS_DEFAULT = true;+ public static final String SETUP_KEYCLOAK_EMAIL_FROM = "SETUP_KEYCLOAK_EMAIL_FROM";+ public static final String SETUP_KEYCLOAK_EMAIL_FROM_DEFAULT = "[email protected]";final protected ManagerIdentityService identityService;final protected SetupService setupService;@@ -45,6 +63,7 @@ public abstract class AbstractKeycloakSetup implements Setup {final protected RealmResource masterRealmResource;final protected ClientsResource masterClientsResource;final protected UsersResource masterUsersResource;+ final protected TenantEmailConfig emailConfig;public AbstractKeycloakSetup(Container container) {this.identityService = container.getService(ManagerIdentityService.class);@@ -59,6 +78,20 @@ public abstract class AbstractKeycloakSetup implements Setup {masterRealmResource = identityService.getRealms(null, accessToken).realm(MASTER_REALM);masterClientsResource = identityService.getRealms(null, accessToken).realm(MASTER_REALM).clients();masterUsersResource = identityService.getRealms(null, accessToken).realm(MASTER_REALM).users();++ // Configure SMTP+ if (container.getConfig().containsKey(SETUP_KEYCLOAK_EMAIL_HOST)) {+ emailConfig = new TenantEmailConfig();+ emailConfig.setHost(container.getConfig().getOrDefault(SETUP_KEYCLOAK_EMAIL_HOST, SETUP_KEYCLOAK_EMAIL_HOST_DEFAULT));+ emailConfig.setStarttls(getBoolean(container.getConfig(), SETUP_KEYCLOAK_EMAIL_TLS,SETUP_KEYCLOAK_EMAIL_TLS_DEFAULT));+ emailConfig.setPort(getInteger(container.getConfig(), SETUP_KEYCLOAK_EMAIL_PORT, SETUP_KEYCLOAK_EMAIL_PORT_DEFAULT));+ emailConfig.setAuth(getBoolean(container.getConfig(), SETUP_KEYCLOAK_EMAIL_AUTH, SETUP_KEYCLOAK_EMAIL_AUTH_DEFAULT));+ emailConfig.setUser(container.getConfig().getOrDefault(SETUP_KEYCLOAK_EMAIL_USER, SETUP_KEYCLOAK_EMAIL_USER_DEFAULT));+ emailConfig.setPassword(container.getConfig().getOrDefault(SETUP_KEYCLOAK_EMAIL_PASSWORD, SETUP_KEYCLOAK_EMAIL_PASSWORD_DEFAULT));+ emailConfig.setFrom(container.getConfig().getOrDefault(SETUP_KEYCLOAK_EMAIL_FROM, SETUP_KEYCLOAK_EMAIL_FROM_DEFAULT));+ } else {+ emailConfig = null;+ }}protected String getClientObjectId(ClientsResource clientsResource) {diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.javaindex a05c7632a..30608422f 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java@@ -20,12 +20,33 @@package org.openremote.manager.server.setup;import com.vividsolutions.jts.geom.GeometryFactory;+import org.openremote.agent.protocol.macro.MacroAction;+import org.openremote.agent.protocol.macro.MacroProtocol;+import org.openremote.agent.protocol.timer.TimerValue;import org.openremote.container.Container;import org.openremote.container.persistence.PersistenceService;import org.openremote.manager.server.asset.AssetStorageService;+import org.openremote.manager.server.asset.ServerAsset;import org.openremote.manager.server.datapoint.AssetDatapointService;import org.openremote.manager.server.rules.RulesetStorageService;import org.openremote.manager.server.security.ManagerIdentityService;+import org.openremote.model.asset.AssetAttribute;+import org.openremote.model.attribute.*;+import org.openremote.model.value.Values;++import java.time.DayOfWeek;+import java.util.ArrayList;+import java.util.List;+import java.util.Locale;+import java.util.function.Supplier;++import static org.openremote.agent.protocol.macro.MacroProtocol.META_MACRO_ACTION_INDEX;+import static org.openremote.agent.protocol.timer.TimerConfiguration.initTimerConfiguration;+import static org.openremote.agent.protocol.timer.TimerProtocol.META_TIMER_VALUE_LINK;+import static org.openremote.model.asset.AssetMeta.*;+import static org.openremote.model.asset.AssetType.*;+import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;+import static org.openremote.model.attribute.AttributeType.DECIMAL;public abstract class AbstractManagerSetup implements Setup {@@ -46,4 +67,251 @@ public abstract class AbstractManagerSetup implements Setup {this.setupService = container.getService(SetupService.class);}+ // ################################ Demo apartment with complex scenes ###################################++ protected ServerAsset createDemoApartment(ServerAsset parent, String name) {+ ServerAsset apartment = new ServerAsset(name, RESIDENCE, parent);+ apartment.setLocation(parent.getLocation());+ 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());+ return room;+ }++ protected void addDemoApartmentRoomMotionCounter(ServerAsset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {+ room.addAttributes(+ 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 MetaItem(STORE_DATA_POINTS, Values.create(true))+ ).addMeta(shouldBeLinked ? agentLinker.get() : null),+ 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 MetaItem(SHOW_ON_DASHBOARD, Values.create(true))+ ),+ // TODO Should we have LONG?+ 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))+ )+ );+ }++ protected void addDemoApartmentRoomCO2Sensor(ServerAsset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {+ room.addAttributes(+ 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 MetaItem(STORE_DATA_POINTS, Values.create(true)),+ new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),+ new MetaItem(FORMAT, Values.create("%4d ppm"))+ ).addMeta(shouldBeLinked ? agentLinker.get() : null)+ );+ }++ protected void addDemoApartmentRoomHumiditySensor(ServerAsset room, boolean shouldBeLinked, Supplier<MetaItem[]> agentLinker) {+ room.addAttributes(+ 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 MetaItem(STORE_DATA_POINTS, Values.create(true)),+ new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),+ new MetaItem(FORMAT, Values.create("%3d %%"))+ ).addMeta(shouldBeLinked ? agentLinker.get() : null)+ );+ }++ protected void addDemoApartmentRoomThermometer(ServerAsset room,+ boolean shouldBeLinked,+ Supplier<MetaItem[]> agentLinker) {+ room.addAttributes(+ 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(STORE_DATA_POINTS, Values.create(true)),+ new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),+ new MetaItem(FORMAT, Values.create("%0.1f °"))+ ).addMeta(shouldBeLinked ? agentLinker.get() : null)+ );+ }+ protected void addDemoApartmentTemperatureControl(ServerAsset room,+ boolean shouldBeLinked,+ Supplier<MetaItem[]> agentLinker) {+ room.addAttributes(+ 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(SHOW_ON_DASHBOARD, Values.create(true)),+ new MetaItem(FORMAT, Values.create("%0.1f °"))+ ).addMeta(shouldBeLinked ? agentLinker.get() : null)+ );+ }++ public 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) {+ if (room.hasAttribute("targetTemperature")) {+ 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())+ )+ );+ }+ }+ }}diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.javaindex f0f7fb1c0..c9a3e187b 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakDemoSetup.java@@ -67,14 +67,14 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {customerA.setRealm("customerA");customerA.setDisplayName("Customer A");customerA.setEnabled(true);- identityService.createTenant(null, accessToken, customerA);+ identityService.createTenant(null, accessToken, customerA, emailConfig);customerATenant = identityService.getTenantForRealm(customerA.getRealm());Tenant customerB = new Tenant();customerB.setRealm("customerB");customerB.setDisplayName("Customer B");customerB.setEnabled(true);- identityService.createTenant(null, accessToken, customerB);+ identityService.createTenant(null, accessToken, customerB, emailConfig);customerBTenant = identityService.getTenantForRealm(customerB.getRealm());// Usersdiff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.javaindex bd7e6fb5d..1edbe6596 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/KeycloakInitSetup.java@@ -48,8 +48,8 @@ public class KeycloakInitSetup extends AbstractKeycloakSetup {masterRealm.setDisplayName("Master");- // Set theme, timeouts, etc.- identityService.configureRealm(masterRealm);+ // Set SMTP server, theme, timeouts, etc.+ identityService.configureRealm(masterRealm, emailConfig);masterRealmResource.update(masterRealm);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 8ca42de85..d45b98df4 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@@ -20,14 +20,11 @@package org.openremote.manager.server.setup.builtin;import com.vividsolutions.jts.geom.Coordinate;-import org.openremote.agent.protocol.macro.MacroAction;-import org.openremote.agent.protocol.macro.MacroProtocol;import org.openremote.agent.protocol.simulator.SimulatorProtocol;import org.openremote.agent.protocol.simulator.element.ColorSimulatorElement;import org.openremote.agent.protocol.simulator.element.DecimalSimulatorElement;import org.openremote.agent.protocol.simulator.element.IntegerSimulatorElement;import org.openremote.agent.protocol.simulator.element.SwitchSimulatorElement;-import org.openremote.agent.protocol.timer.TimerValue;import org.openremote.container.Container;import org.openremote.manager.server.asset.ServerAsset;import org.openremote.manager.server.setup.AbstractManagerSetup;@@ -37,18 +34,12 @@ 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;-import static org.openremote.agent.protocol.timer.TimerProtocol.META_TIMER_VALUE_LINK;import static org.openremote.model.asset.AssetMeta.*;import static org.openremote.model.asset.AssetType.*;import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;@@ -138,17 +129,17 @@ public class ManagerDemoSetup extends AbstractManagerSetup {smartOfficeId = smartOffice.getId();ServerAsset groundFloor = new ServerAsset("Ground Floor", FLOOR, smartOffice);- groundFloor.setLocation(geometryFactory.createPoint(new Coordinate(5.460315214821094, 51.44541688237109)));+ groundFloor.setLocation(smartOffice.getLocation());groundFloor = assetStorageService.merge(groundFloor);groundFloorId = groundFloor.getId();ServerAsset lobby = new ServerAsset("Lobby", ROOM, groundFloor);- lobby.setLocation(geometryFactory.createPoint(new Coordinate(5.460315214821094, 51.44541688237109)));+ lobby.setLocation(groundFloor.getLocation());lobby = assetStorageService.merge(lobby);lobbyId = lobby.getId();ServerAsset agent = new ServerAsset("Demo Agent", AGENT, lobby);- agent.setLocation(geometryFactory.createPoint(new Coordinate(5.460315214821094, 51.44541688237109)));+ agent.setLocation(lobby.getLocation());agent.setAttributes(initProtocolConfiguration(new AssetAttribute(agentProtocolConfigName), SimulatorProtocol.PROTOCOL_NAME).addMeta(@@ -166,7 +157,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {agentId = agent.getId();ServerAsset thing = new ServerAsset("Demo Thing", THING, agent);- thing.setLocation(geometryFactory.createPoint(new Coordinate(5.460315214821094, 51.44541688237109)));+ thing.setLocation(agent.getLocation());thing.setAttributes(new AssetAttribute("light1Toggle", BOOLEAN, Values.create(true)).setMeta(new Meta(@@ -337,23 +328,50 @@ public class ManagerDemoSetup extends AbstractManagerSetup {smartHomeId = smartHome.getId();// The "Apartment 1" is the demo apartment with complex scenes- ServerAsset apartment1 = createDemoApartment(smartHome, "Apartment 1", new Coordinate(5.470945, 51.438000));+ ServerAsset apartment1 = createDemoApartment(smartHome, "Apartment 1");apartment1 = assetStorageService.merge(apartment1);apartment1Id = apartment1.getId();- ServerAsset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room");- apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);- apartment1LivingroomId = apartment1Livingroom.getId();-- ServerAsset apartment1ServiceAgent = createDemoApartmentServiceAgent(apartment1);+ ServerAsset apartment1ServiceAgent = new ServerAsset("Service Agent (Simulator)", AGENT, apartment1);+ apartment1ServiceAgent.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)+ ))+ );apartment1ServiceAgent = assetStorageService.merge(apartment1ServiceAgent);apartment1ServiceAgentId = apartment1ServiceAgent.getId();- linkDemoApartmentWithServiceAgent(apartment1, apartment1ServiceAgent);- apartment1 = assetStorageService.merge(apartment1);+ ServerAsset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room");+ addDemoApartmentRoomMotionCounter(apartment1Livingroom, true, () -> new MetaItem[]{+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(IntegerSimulatorElement.ELEMENT_NAME_INTEGER))+ });+ addDemoApartmentRoomCO2Sensor(apartment1Livingroom, true, () -> new MetaItem[]{+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ });+ addDemoApartmentRoomHumiditySensor(apartment1Livingroom, true, () -> new MetaItem[]{+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ });+ addDemoApartmentRoomThermometer(apartment1Livingroom, true, () -> new MetaItem[]{+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ });+ addDemoApartmentTemperatureControl(apartment1Livingroom, true, () -> new MetaItem[]{+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(DecimalSimulatorElement.ELEMENT_NAME))+ });- linkDemoApartmentRoomWithServiceAgent(apartment1Livingroom, apartment1ServiceAgent);apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);+ apartment1LivingroomId = apartment1Livingroom.getId();if (importDemoScenes) {Scene[] scenes = new Scene[]{@@ -373,7 +391,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {}ServerAsset apartment2 = new ServerAsset("Apartment 2", RESIDENCE, smartHome);- apartment2.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));+ apartment2.setLocation(smartHome.getLocation());apartment2.setAttributes(new AssetAttribute("allLightsOffSwitch", AttributeType.BOOLEAN, Values.create(true)).setMeta(@@ -387,7 +405,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment2Id = apartment2.getId();ServerAsset apartment2Livingroom = new ServerAsset("Living Room", ROOM, apartment2);- apartment2Livingroom.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));+ apartment2Livingroom.setLocation(apartment2.getLocation());apartment2Livingroom.setAttributes(new AssetAttribute("motionSensor", AttributeType.BOOLEAN, Values.create(false)).setMeta(@@ -422,13 +440,12 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment2LivingroomId = apartment2Livingroom.getId();ServerAsset apartment3 = new ServerAsset("Apartment 3", RESIDENCE, smartHome);- apartment3.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));-+ apartment3.setLocation(smartHome.getLocation());apartment3 = assetStorageService.merge(apartment3);apartment3Id = apartment3.getId();ServerAsset apartment3Livingroom = new ServerAsset("Living Room", ROOM, apartment3);- apartment3Livingroom.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));+ apartment3Livingroom.setLocation(apartment3.getLocation());apartment3Livingroom.addAttributes(new AssetAttribute("lightSwitch", AttributeType.BOOLEAN));@@ -444,288 +461,4 @@ public class ManagerDemoSetup extends AbstractManagerSetup {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/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovyindex 1d104bc14..10a5e9371 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@@ -1,5 +1,6 @@package org.openremote.test.assets+import org.openremote.model.attribute.MetaItemimport org.openremote.model.value.Valuesimport org.openremote.container.util.IdentifierUtilimport org.openremote.manager.server.setup.SetupService@@ -21,6 +22,9 @@ import static org.openremote.container.util.MapAccess.getStringimport static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORDimport static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULTimport static org.openremote.model.Constants.*+import static org.openremote.model.asset.AssetMeta.FORMAT+import static org.openremote.model.asset.AssetMeta.SHOW_ON_DASHBOARD+import static org.openremote.model.asset.AssetMeta.STORE_DATA_POINTSimport static org.openremote.model.attribute.MetaItem.isMetaNameEqualToclass AssetPermissionsTest extends Specification implements ManagerContainerTrait {@@ -587,10 +591,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraicurrentTemperature.getType().get() == AttributeType.DECIMAL!currentTemperature.getValue().isPresent()Meta protectedMeta = currentTemperature.getMeta()- protectedMeta.size() == 3- protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.LABEL)).findFirst().get().getValueAsString().get() == "Current temperature"+ protectedMeta.size() == 6+ protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.LABEL)).findFirst().get().getValueAsString().get() == "Current Temperature"protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.READ_ONLY)).findFirst().get().getValueAsBoolean().get()protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.RULE_STATE)).findFirst().get().getValueAsBoolean().get()+ protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.STORE_DATA_POINTS)).findFirst().get().getValueAsBoolean().get()+ protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.SHOW_ON_DASHBOARD)).findFirst().get().getValueAsBoolean().get()+ protectedMeta.stream().filter(isMetaNameEqualTo(AssetMeta.FORMAT)).findFirst().get().getValueAsString().get() == "%0.1f °"when: "an asset is retrieved by ID in a foreign realm"assetResource.get(null, managerDemoSetup.thingId)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 c1c42952a..dcdd2bf6c 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@@ -40,7 +40,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match (and some values should be empty because we need an AssetQuery to get them)"asset.id == managerDemoSetup.apartment1Id- asset.version == 1+ asset.version == 0asset.createdOn.time < System.currentTimeMillis()asset.name == "Apartment 1"asset.wellKnownType == AssetType.RESIDENCE@@ -161,7 +161,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"assets.size() == 3assets.get(0).id == managerDemoSetup.apartment1Id- assets.get(0).version == 1+ assets.get(0).version == 0assets.get(0).createdOn.time < System.currentTimeMillis()assets.get(0).name == "Apartment 1"assets.get(0).wellKnownType == AssetType.RESIDENCE@@ -223,8 +223,8 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"assets.size() == 3assets.get(0).id == managerDemoSetup.apartment1Id- assets.get(1).id == managerDemoSetup.apartment1LivingroomId- assets.get(2).id == managerDemoSetup.apartment1ServiceAgentId+ assets.get(1).id == managerDemoSetup.apartment1ServiceAgentId+ assets.get(2).id == managerDemoSetup.apartment1LivingroomIdwhen: "a query is executed"assets = assetStorageService.findAll(@@ -248,9 +248,9 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets.get(1).id == managerDemoSetup.apartment1LivingroomIdassets.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("currentTemperature").get().meta.size() == 6!assets.get(1).getAttribute("targetTemperature").get().getValue().isPresent()- assets.get(1).getAttribute("targetTemperature").get().meta.size() == 2+ assets.get(1).getAttribute("targetTemperature").get().meta.size() == 4assets.get(2).id == managerDemoSetup.apartment2Idwhen: "a query is executed"diff --git a/profile/demo.yml b/profile/demo.ymlindex 90ecc9abf..c79b8f60a 100644--- a/profile/demo.yml+++ b/profile/demo.yml@@ -61,6 +61,15 @@ services:SETUP_IMPORT_DEMO_ASSETS: 'true'SETUP_IMPORT_DEMO_RULES: 'true'+ # Optional: Configure SMTP smart host for Keycloak, to send password reset emails etc.+ #SETUP_KEYCLOAK_EMAIL_HOST: smtp-host.demo.tld+ #SETUP_KEYCLOAK_EMAIL_USER: 'smtp-user'+ #SETUP_KEYCLOAK_EMAIL_PASSWORD: 'smtp-password'+ #SETUP_KEYCLOAK_EMAIL_PORT: 25+ #SETUP_KEYCLOAK_EMAIL_AUTH: 'true'+ #SETUP_KEYCLOAK_EMAIL_TLS: 'true'+ #SETUP_KEYCLOAK_EMAIL_FROM: '[email protected]'+# The public host name of this OpenRemote installation. This name is used in bearer tokens# and must be the name you access the web services under. If you are using Docker Toolbox,# this is the IP of a virtual machine running the Linux Docker host (see VirtualBox).@@ -86,6 +95,10 @@ services:KEYCLOAK_HOST: keycloakKEYCLOAK_PORT: 8080+ # Optional: Console applications can register for push notifications through FCM.+ # NOTIFICATION_FIREBASE_URL: https://fcm.googleapis.com/fcm/send+ # NOTIFICATION_FIREBASE_API_KEY = '...'+# Optional: Override built-in logging.properties with a file of your choice# LOGGING_CONFIG_FILE: /my/manager/logging.properties