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
Updated android console build, methods in AbstractProtocol should be final, prevent publishing of private events to restricted users, serve web dependencies for console apps from platform static resources, work on demo residence rules and customer A smart home example app, improved or-* web components
Christian Bauer1c999647cffd
diff --git a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.javaindex 4d3d54848..b7f483405 100644--- a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java@@ -170,7 +170,7 @@ public abstract class AbstractProtocol implements Protocol {}@Override- public void linkProtocolConfiguration(AssetAttribute protocolConfiguration, Consumer<ConnectionStatus> statusConsumer) {+ final public void linkProtocolConfiguration(AssetAttribute protocolConfiguration, Consumer<ConnectionStatus> statusConsumer) {withLock(getProtocolName(), () -> {LOG.finer("Linking protocol configuration to protocol '" + getProtocolName() + "': " + protocolConfiguration);linkedProtocolConfigurations.put(@@ -182,7 +182,7 @@ public abstract class AbstractProtocol implements Protocol {}@Override- public void unlinkProtocolConfiguration(AssetAttribute protocolConfiguration) {+ final public void unlinkProtocolConfiguration(AssetAttribute protocolConfiguration) {withLock(getProtocolName(), () -> {LOG.finer("Unlinking protocol configuration from protocol '" + getProtocolName() + "': " + protocolConfiguration);doUnlinkProtocolConfiguration(protocolConfiguration);@@ -191,7 +191,7 @@ public abstract class AbstractProtocol implements Protocol {}@Override- public void linkAttributes(Collection<AssetAttribute> attributes, AssetAttribute protocolConfiguration) {+ final public void linkAttributes(Collection<AssetAttribute> attributes, AssetAttribute protocolConfiguration) {withLock(getProtocolName(), () -> {attributes.forEach(attribute -> {LOG.fine("Linking attribute to '" + getProtocolName() + "': " + attribute);@@ -222,7 +222,7 @@ public abstract class AbstractProtocol implements Protocol {}@Override- public void unlinkAttributes(Collection<AssetAttribute> attributes, AssetAttribute protocolConfiguration) throws Exception {+ final public void unlinkAttributes(Collection<AssetAttribute> attributes, AssetAttribute protocolConfiguration) throws Exception {withLock(getProtocolName(), () ->attributes.forEach(attribute -> {LOG.fine("Unlinking attribute on '" + getProtocolName() + "': " + attribute);@@ -259,7 +259,7 @@ public abstract class AbstractProtocol implements Protocol {});}- protected void processLinkedAttributeWrite(AttributeEvent event) {+ final protected void processLinkedAttributeWrite(AttributeEvent event) {LOG.finest("Processing linked attribute write on " + getProtocolName() + ": " + event);withLock(getProtocolName(), () -> {AssetAttribute attribute = linkedAttributes.get(event.getAttributeRef());@@ -277,7 +277,7 @@ public abstract class AbstractProtocol implements Protocol {* timestamp. Use {@link #updateLinkedAttribute} to publish new sensor values, which performs additional* verification and uses a different messaging queue.*/- protected void sendAttributeEvent(AttributeState state) {+ final protected void sendAttributeEvent(AttributeState state) {sendAttributeEvent(new AttributeEvent(state, timerService.getCurrentTimeMillis()));}@@ -285,7 +285,7 @@ public abstract class AbstractProtocol implements Protocol {* Send an arbitrary {@link AttributeEvent} through the processing chain. Use {@link #updateLinkedAttribute} to* publish new sensor values, which performs additional verification and uses a different messaging queue.*/- protected void sendAttributeEvent(AttributeEvent event) {+ final protected void sendAttributeEvent(AttributeEvent event) {withLock(getProtocolName(), () -> {// Don't allow updating linked attributes with this mechanism as it could cause an infinite loopif (linkedAttributes.containsKey(event.getAttributeRef())) {@@ -302,7 +302,7 @@ public abstract class AbstractProtocol implements Protocol {* before sending on the sensor queue.*/@SuppressWarnings("unchecked")- protected void updateLinkedAttribute(final AttributeState finalState, long timestamp) {+ final protected void updateLinkedAttribute(final AttributeState finalState, long timestamp) {withLock(getProtocolName(), () -> {AttributeState state = finalState;AssetAttribute attribute = linkedAttributes.get(state.getAttributeRef());@@ -404,11 +404,11 @@ public abstract class AbstractProtocol implements Protocol {* Update the value of a linked attribute, with the current system time as event time see* {@link #updateLinkedAttribute(AttributeState, long)} for more details.*/- protected void updateLinkedAttribute(AttributeState state) {+ final protected void updateLinkedAttribute(AttributeState state) {updateLinkedAttribute(state, timerService.getCurrentTimeMillis());}- protected void updateAssetLocation(String assetId, Point location) {+ final protected void updateAssetLocation(String assetId, Point location) {withLock(getProtocolName(), () -> assetService.updateAssetLocation(assetId, location));}@@ -417,7 +417,7 @@ public abstract class AbstractProtocol implements Protocol {* persist changing data e.g. authorization tokens. First this clones the existing protocolConfiguration and calls* the consumer to perform the modification.*/- protected void updateLinkedProtocolConfiguration(AssetAttribute protocolConfiguration, Consumer<AssetAttribute> protocolUpdater) {+ final protected void updateLinkedProtocolConfiguration(AssetAttribute protocolConfiguration, Consumer<AssetAttribute> protocolUpdater) {withLock(getProtocolName(), () -> {// Clone the protocol configuration rather than modify this oneAssetAttribute modifiedProtocolConfiguration = protocolConfiguration.deepCopy();@@ -429,7 +429,7 @@ public abstract class AbstractProtocol implements Protocol {/*** Update the runtime status of a protocol configuration by its attribute ref*/- protected void updateStatus(AttributeRef protocolRef, ConnectionStatus connectionStatus) {+ final protected void updateStatus(AttributeRef protocolRef, ConnectionStatus connectionStatus) {withLock(getProtocolName(), () -> {LinkedProtocolInfo protocolInfo = linkedProtocolConfigurations.get(protocolRef);if (protocolInfo != null) {@@ -443,7 +443,7 @@ public abstract class AbstractProtocol implements Protocol {/*** Gets the current runtime status of a protocol configuration.*/- protected ConnectionStatus getStatus(AssetAttribute protocolConfiguration) {+ final protected ConnectionStatus getStatus(AssetAttribute protocolConfiguration) {return withLockReturning(getProtocolName(), () -> {LinkedProtocolInfo linkedProtocolInfo = linkedProtocolConfigurations.get(protocolConfiguration.getReferenceOrThrow());return linkedProtocolInfo.getCurrentConnectionStatus();@@ -451,7 +451,7 @@ public abstract class AbstractProtocol implements Protocol {}@Override- public ProtocolDescriptor getProtocolDescriptor() {+ final public ProtocolDescriptor getProtocolDescriptor() {return new ProtocolDescriptor(getProtocolName(),getProtocolDisplayName(),diff --git a/client/build.gradle b/client/build.gradleindex ed7b28241..ae493305c 100644--- a/client/build.gradle+++ b/client/build.gradle@@ -146,8 +146,11 @@ task gwtSuperDev(dependsOn: classes, type: JavaExec) {"-generateJsInteropExports","-style", "PRETTY",// Change this to 0.0.0.0 to bind on all interfaces, enabling- // access of the code server from other devices in your LAN- "-bindAddress", "127.0.0.1"+ // access of the code server from other devices in your LAN:+ //+ // ./gradlew -PWEBSERVER_LISTEN_HOST=0.0.0.0 gwtSuperDev+ //+ "-bindAddress", project.hasProperty("WEBSERVER_LISTEN_HOST") ? project.property("WEBSERVER_LISTEN_HOST") : "127.0.0.1"]// Make this magic directory easily cleanable by placing it into the build folderdiff --git a/client/src/main/java/org/openremote/app/client/app/AppControllerImpl.java b/client/src/main/java/org/openremote/app/client/app/AppControllerImpl.javaindex b70fc727c..7ebf33aef 100644--- a/client/src/main/java/org/openremote/app/client/app/AppControllerImpl.java+++ b/client/src/main/java/org/openremote/app/client/app/AppControllerImpl.java@@ -122,6 +122,7 @@ public class AppControllerImpl implements AppController, AppView.Presenter {AppPlaceController appPlaceController = (AppPlaceController) placeController;appPlaceController.stop();}+ // TODO Must remove open popup panels (e.g. confirmation dialogs, map info panel)!environment.getEventService().stop();}}diff --git a/client/src/main/webapp/bower.json b/client/src/main/webapp/bower.jsonindex 413a8fc71..4c7857d55 100644--- a/client/src/main/webapp/bower.json+++ b/client/src/main/webapp/bower.json@@ -16,8 +16,10 @@"tests"],"dependencies": {- "polymer": "Polymer/polymer#^2.3.0",- "iron-flex-layout": "^2.0.0",+ "polymer": "Polymer/polymer#^2.5.0",+ "iron-flex-layout": "^2.0.3",+ "app-localize-behavior": "PolymerElements/app-localize-behavior#^2.0.1",+ "intl": "intl#^1.2.5","chart.js": "^2.7.0"}}\ No newline at end of filediff --git a/client/src/main/webapp/index.html b/client/src/main/webapp/index.htmlindex 767556621..b58df6c73 100644--- a/client/src/main/webapp/index.html+++ b/client/src/main/webapp/index.html@@ -18,7 +18,6 @@let app = e.detail.app;- // Load resources in parallelPromise.all([app.load.css("/static/3rdparty/mapbox-gl-js/0.42.2/mapbox-gl.css"),app.load.js("/static/3rdparty/mapbox-gl-js/0.42.2/mapbox-gl.js"),@@ -34,6 +33,19 @@});</script>+ <style type="text/css">+ ::-webkit-scrollbar {+ width: 1em;+ }+ ::-webkit-scrollbar-track {+ background-color: var(--theme-black);+ }++ ::-webkit-scrollbar-thumb {+ background-color: var(--theme-lightgreen);+ }+ </style>+</head><body class="layout vertical">diff --git a/client/src/main/webapp/src/manager/or-manager-console-apps/or-manager-console-apps-view.html b/client/src/main/webapp/src/manager/or-manager-console-apps/or-manager-console-apps-view.htmlindex 23edd030d..6abeb24db 100644--- a/client/src/main/webapp/src/manager/or-manager-console-apps/or-manager-console-apps-view.html+++ b/client/src/main/webapp/src/manager/or-manager-console-apps/or-manager-console-apps-view.html@@ -80,6 +80,11 @@}}+ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical");+ }+connectedCallback() {super.connectedCallback();diff --git a/client/src/main/webapp/src/or-app/or-app-events.html b/client/src/main/webapp/src/or-app/or-app-events.htmlnew file mode 100644index 000000000..d207fd3b5--- /dev/null+++ b/client/src/main/webapp/src/or-app/or-app-events.html@@ -0,0 +1,113 @@+<dom-module id="or-app-events">+ <script>+ class AppEvents extends Polymer.Element {++ static get is() {+ return "or-app-events";+ }++ static get properties() {+ return {+ app: {+ type: Object+ },+ renewalPeriodSeconds: {+ type: Number,+ value: 300+ },+ activeSubscriptions: {+ type: Object,+ value: {}+ }+ };+ }++ ready() {+ super.ready();+ }++ sendAttributeEvent(assetId, attributeName, value) {+ let attributeEvent = {+ eventType: "attribute",+ attributeState: {+ attributeRef: {entityId: assetId, attributeName: attributeName},+ value: value+ }+ }+ openremote.INSTANCE.sendServiceMessage("EVENT" + JSON.stringify(attributeEvent));+ }++ subscribeAttributeEvents(assetIds) {+ this.subscribe({+ eventType: "attribute",+ filter: {+ filterType: "attribute-entity-id",+ entityId: assetIds+ }+ });+ }++ subscribe(subscription) {+ if (subscription.eventType in this.activeSubscriptions) {+ clearInterval(this.activeSubscriptions[subscription.eventType]);+ }+ let message = "SUBSCRIBE" + JSON.stringify(subscription);+ openremote.INSTANCE.sendServiceMessage(message);+ let interval = setInterval(+ () => openremote.INSTANCE.sendServiceMessage(message), this.renewalPeriodSeconds / 2 * 1000+ );+ this.set("activeSubscriptions." + subscription.eventType, interval);+ }++ unsubscribe(eventType) {+ if (eventType in this.activeSubscriptions) {+ clearInterval(this.activeSubscriptions[eventType]);+ let message = "UNSUBSCRIBE" + JSON.stringify({eventType: eventType});+ openremote.INSTANCE.sendServiceMessage(message);+ delete this.activeSubscriptions[eventType];+ this.notifyPath("activeSubscriptions." + eventType);+ }+ }++ onConnectionClose() {+ Object.keys(this.activeSubscriptions).forEach(eventType => {+ this.unsubscribe(eventType);+ });+ this.set("activeSubscriptions", {});+ }++ onServiceMessageReceived(data) {+ if (!data)+ return;+ if (data.startsWith("UNAUTHORIZED")) {+ openremote.INSTANCE.setError("Unauthorized event subscription.");+ } else if (data.startsWith("EVENT")) {+ data = data.substring("EVENT".length);+ if (data.startsWith("[")) {+ // Handle array of events+ let events = JSON.parse(data);+ if (!Array.isArray(events)) {+ return;+ }+ events.forEach(event => {+ if (!event.eventType) {+ return;+ }+ this.dispatchEvent(new CustomEvent(event.eventType, {detail: event}))+ });+ } else {+ let event = JSON.parse(data);+ if (!event.eventType) {+ return;+ }+ this.dispatchEvent(new CustomEvent(event.eventType, {detail: event}))+ }+ }+ }+ }++ // Upgrade immediately, so you can't use jsinterop here!+ customElements.define(AppEvents.is, AppEvents);+ </script>++</dom-module>\ No newline at end of filediff --git a/client/src/main/webapp/src/or-app/or-app-security.html b/client/src/main/webapp/src/or-app/or-app-security.htmlindex 3cadb5949..e760e230c 100644--- a/client/src/main/webapp/src/or-app/or-app-security.html+++ b/client/src/main/webapp/src/or-app/or-app-security.html@@ -217,7 +217,7 @@// Clear native shell stored tokensif (this.shellNative && this.shellNative.enabled) {- this.shellNative.postNativeShellMessage({type: 'token', data: {}});+ this.shellNative.postNativeShellMessage({type: 'logout'});}// Navigate to start page on logout, drop the hash (also, Keycloak has a bug where it@@ -240,6 +240,13 @@return this.user;}+ getUserId() {+ if (this.authenticated && this.keycloak) {+ return this.keycloak.tokenParsed.sub;+ }+ return this.user;+ }+isSuperUser() {return this.authenticated && this.realm === "master" && this.hasRealmRole("admin");}diff --git a/client/src/main/webapp/src/or-app/or-app.html b/client/src/main/webapp/src/or-app/or-app.htmlindex 90320ef32..0c8dead7d 100644--- a/client/src/main/webapp/src/or-app/or-app.html+++ b/client/src/main/webapp/src/or-app/or-app.html@@ -4,6 +4,8 @@<!-- App services/dependencies --><link rel="import" href="or-shell-native.html"><link rel="import" href="or-app-security.html">+<link rel="import" href="or-app-events.html">+<link rel="import" href="or-view-component.html"><!-- Promise API polyfill on IE 11 --><script src="/static/3rdparty/es6-promise.js"></script>@@ -80,6 +82,8 @@user="{{user}}"error="{{error}}"></or-app-security>+ <or-app-events id="appEvents"></or-app-events>+<template is="dom-if" if="[[error]]"><div id="errorView" class="or-Viewport"><h1>[[defaultErrorMessage]]</h1>@@ -94,47 +98,6 @@</template><script>-- class OpenRemoteViewComponent extends Polymer.Element {- static get properties() {- return {- widgetStyle: {- type: openremote.style.WidgetStyle,- value: () => {- return openremote.WIDGET_STYLE- }- }- }- }-- ready() {- super.ready();-- // View component should flex and its children should be in a flexbox vertical layout by default- this.shadowRoot.host.classList.add("flex", "layout", "vertical");-- // View component is hidden by default, subclass decides when it's ready- this.hideComponent();- }-- showComponent() {- this.shadowRoot.host.style.visibility = "visible";- }-- hideComponent() {- this.shadowRoot.host.style.visibility = "hidden";- }-- i18n(presenter, key) {- return presenter ? presenter.messages()[key]() : "";- }-- icon(name) {- return "fa fa-" + name;- }-- }-/*** Singleton per window/document, registers itself as window.openremote.INSTANCE.*@@ -286,6 +249,7 @@// Important success and error for the promiseelement.onload = function () {+ console.debug("Loaded resource: " + url);resolve(url);};element.onerror = function () {@@ -504,6 +468,14 @@console.log("Connected to event service: " + serviceUrl);this.set("status", "CONNECTED");+ // The events component is always registered as a message consumer and connection close listener+ this.addServiceMessageConsumer(data => {+ this.getServiceEvents().onServiceMessageReceived(data);+ });+ this.addServiceConnectionCloseListener(() => {+ this.getServiceEvents().onConnectionClose();+ });+// Close socket on unload/refresh of pagewindow.addEventListener("beforeunload", () => {console.log("Page unloaded, closing event service connection");@@ -553,6 +525,10 @@}}+ getServiceEvents() {+ return this.$.appEvents;+ }+addServiceMessageConsumer(consumer) {this.webSocketConsumers.push(consumer);}@@ -625,7 +601,7 @@// jsinterop components are loaded. Here we register types defined in JS so they are// available when jsinterop components are loaded/started.window.addEventListener('AppInit', function () {- console.log("Setting type in global scope: " + is);+ console.debug("Setting type in global scope: " + is);// Sets openremote.foo.bar.MyType = element so we can have the type in GWT jsinteroplet x = openremote;for (let i = 0; i < interopNames.length; i++) {@@ -641,7 +617,7 @@// initialization (see above). Now the actual web component elements can be defined/upgraded,// this is when component constructors etc. lifecycle starts.window.addEventListener('AppReady', function () {- console.log("Upgrading element: " + is);+ console.debug("Upgrading element: " + is);customElements.define(is, element);});}diff --git a/client/src/main/webapp/src/or-app/or-style.html b/client/src/main/webapp/src/or-app/or-style.htmlindex c2af1be69..21168dbc1 100644--- a/client/src/main/webapp/src/or-app/or-style.html+++ b/client/src/main/webapp/src/or-app/or-style.html@@ -7,653 +7,781 @@<template><style include="or-theme or-icons iron-flex iron-flex-alignment iron-flex-factors iron-positioning">- ::-webkit-scrollbar {- width: 1em;- }-- * html, body {- box-sizing: border-box;- }-- html, body {- width: 100%;- height: 100vh;- min-height: 100%;- margin: 0;- overflow: hidden;- }-- *:focus {- outline: 0;- }-- .or-Viewport {- width: 100%;- height: 100vh;- min-height: 100%;- margin: 0;- }-- .or-Viewport,- .or-PopupPanel {- font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;- font-weight: 500 !important;- font-size: 0.9em;- letter-spacing: 0.02em;- }-- .or-NavItem {- margin: 0.4em 1.2em 0 1.2em;- font-size: 1.1em;- border-radius: 0 !important;- border-bottom: 0.4em solid transparent;- border-top: 0.2em solid transparent;- }-- .or-SecondaryNav {- padding: 0.4em;- min-width: 12em;- }-- .or-SecondaryNav.vertical {- padding-top: 2.8em !important;- }-- .or-SecondaryNav.horizontal {- padding: 0.4em;- height: 2em;- min-height: 2em;- }-- .or-SecondaryNavItem {- user-select: none;- -webkit-user-select: none; /* Chrome/Safari/Opera */- -moz-user-select: none; /* Firefox */- -ms-user-select: none; /* IE/Edge */- -webkit-touch-callout: none; /* iOS Safari */- cursor: pointer;- padding: 0.4em;- border-radius: 0.15em;- font-weight: 600;- display: inline-block;- margin: 0 1em;- }-- .or-SecondaryNavItem a {- text-decoration: none;- }-- .or-SecondaryNavItem:hover,- .or-SecondaryNavItem:focus {- opacity: .8;- }-- .or-SecondaryNavItem.or-FormControl:hover,- .or-SecondaryNavItem.or-FormControl:focus {- opacity: 1;- }-- .or-RightGradient::before {- background-image: -webkit-linear-gradient(left, transparent 0, rgba(0, 0, 0, 0.5) 100%);- content: "\00a0";- height: 100%;- position: absolute;- right: 0;- width: 2em;- z-index: 9;- }-- .or-LeftGradient::before {- background: -moz-linear-gradient(right, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);- background: -webkit-linear-gradient(right, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);- background: linear-gradient(to left, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);- content: "\00a0";- height: 100%;- position: absolute;- left: 0;- width: 2em;- z-index: 9;- }-- .or-MainContent {- padding: .8em .8em 0 .8em- }-- .or-MainContent:last-child {- }-- .or-PushButton,- .or-FormFileUploadLabel {- user-select: none;- -webkit-user-select: none; /* Chrome/Safari/Opera */- -moz-user-select: none; /* Firefox */- -ms-user-select: none; /* IE/Edge */- -webkit-touch-callout: none; /* iOS Safari */- cursor: pointer;- padding: 0.4em;- border-radius: 0.15em;- font-weight: 600;- display: inline-block;- white-space: nowrap;- /* https://stackoverflow.com/questions/25594630/img-moves-when-changing-opacity-on-hover */- -backface-visibility: hidden;- -webkit-backface-visibility: hidden;- -moz-backface-visibility: hidden;- -o-backface-visibility: hidden;- -webkit-transform: translateZ(0) scale(1.0, 1.0);- }-- .or-PushButton,- .or-FormFileUploadLabel,- .or-PushButton > *,- .or-FormFileUploadLabel > * {- display: inline-block;- }-- .or-PushButton:hover,- .or-FormFileUploadLabel:hover {- opacity: .8;- }-- .or-PushButton:active,- .or-FormFileUploadLabel:active {- -webkit-filter: contrast(44%);- filter: contrast(44%);- opacity: inherit;- }-- .or-PushButtonIcon + .html-face:not(:empty) {- margin-left: 0.6em;- }-- .or-PushButton.or-PushButton-up-disabled {- cursor: not-allowed;- opacity: .44;- }-- .or-PushButton.or-PushButton-up-disabled:hover,- .or-PushButton.or-PushButton-up-disabled:active {- -webkit-filter: inherit;- filter: inherit;- }-- .or-Divider {- min-height: 0.1em;- margin: 1em 0;- }-- .or-Hyperlink,- .or-FormAnchor {- display: inline-block;- white-space: nowrap;- }-- .or-HyperlinkIcon {- width: 0.8em;- }-- .or-Hyperlink a,- .or-Hyperlink a:visited,- .or-FormAnchor,- .or-FormAnchor:visited {- cursor: pointer;- font-weight: 600;- text-decoration: none;- display: inline-block;- padding: 0.4em 0.8em;- border-radius: 0.2em;- }-- .or-FormAnchor,- .or-FormAnchor:visited {- font-style: italic;- font-weight: normal;- text-decoration: underline;- }-- .or-Hyperlink a:hover,- .or-Hyperlink a:focus,- .or-FormAnchor:hover,- .or-FormAnchor:focus {- text-decoration: underline;- }-- .or-SecondaryNav .or-Hyperlink {- padding: 0;- border-radius: 0- }-- .or-SecondaryNav .or-Hyperlink a:hover,- .or-SecondaryNav .or-Hyperlink a:focus {- text-decoration: none;- }-- .or-Headline {- margin: 0 0 0.8em 0;- }-- .or-HeadlineIcon,- .or-HeadlineText {- font-size: x-large !important;- }-- .or-HeadlineText {- font-weight: 600;- }-- .or-HeadlineIcon {- margin-right: 0.4em;- }-- .or-HeadlineSub {- font-size: smaller;- font-weight: 600;- margin: 0.4em 0;- }-- .or-UnorderedList {- list-style: square inside none;- margin: 0;- padding: 0;- white-space: nowrap;- }-- .or-MessagesIcon {- font-size: larger;- }-- .or-Form {- transition: opacity 0.1s linear;- -moz-transition: opacity 0.1s linear;- -webkit-transition: opacity 0.1s linear;- }-- .or-FormBusy {- opacity: 0;- pointer-events: none;- user-select: none;- -webkit-user-select: none; /* Chrome/Safari/Opera */- -moz-user-select: none; /* Firefox */- -ms-user-select: none; /* IE/Edge */- -webkit-touch-callout: none; /* iOS Safari */- }-- .or-FormMessages {- display: table;- margin: 1em;- }-- .or-Toast .or-MessagesIcon,- .or-FormMessages .or-MessagesIcon {- margin: 0em 0.4em 0 0;- }-- .or-FormGroup {- margin-bottom: 0.4em;- padding: 0.4em;- }-- .or-FormSection.opaque .or-FormLabel,- .or-FormSection.opaque .or-FormOutputText- .or-FormGroup.opaque .or-FormLabel,- .or-FormGroup.opaque .or-FormOutputText {- opacity: 0.44;- }-- .or-FormSection .or-FormSection {- margin: 0.4em;- padding: 0.4em;- }-- .or-FormGroup.expanded .or-FormGroup {- }-- .or-FormGroup.expanded .or-FormGroup .or-FormLabel {- font-size: 0.8em;- }-- .or-FormGroupExtension {- margin: 0.8em;- }-- .or-Form .or-FormSectionLabel {- margin: 0.6em 0 0.4em 0;- font-size: 1.2em;- }-- .or-FormGroupExtension .or-FormSectionLabel {- margin: 0.8em 0 0.4em 0;- font-size: inherit;- font-weight: 600;- }-- .or-FormLabel {- width: 10em;- padding: 0.2em 0;- font-weight: 600;- white-space: normal;- overflow: hidden;- }-- .or-FormLabelIcon {- margin-right: 0.4em;- font-size: 1.2em;- opacity: 0.4;- align-self: flex-end;- }-- .or-FormInlineLabelIcon {- margin-right: 0.4em;- }-- .or-FormLabel.inline {- width: inherit;- }-- .or-FormLabel.larger {- width: 15em;- }-- .or-FormLabel.largest {- width: 25em;- }-- .or-FormField {- min-width: 10em;- }-- .or-FormField.larger {- width: 100%;- }-- .or-FormInfoLabel {- font-size: 0.7em;- font-weight: 500;- max-width: 14em;- }-- .or-FormLabel.larger ~ .or-FormInfoLabel {- max-width: 20em;- }-- .or-FormControl {- white-space: nowrap;- font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;- font-size: inherit;- border: none;- margin: 0 0.4em;- }-- .or-FormControl[disabled],- .or-FormSection.opaque .or-FormControl,- .or-FormGroup.opaque .or-FormControl {- cursor: not-allowed;- pointer-events: none;- opacity: .44;- }-- .or-FormControl.or-FormCheckBox[disabled] {- opacity: 1;- }-- .or-FormSection.opaque .or-FormCheckBox,- .or-FormGroup.opaque .or-FormCheckBox {- opacity: 0.44;- }-- .or-FormInputText,- .or-FormInputNumber {- border-bottom: 1px solid;- font-size: inherit;- }-- .or-FormInputText[readOnly],- .or-FormInputNumber[readOnly] {- border-color: transparent;- cursor: text;- }-- .or-FormInputText,- .or-FormInputNumber,- .or-FormOutputText {- padding: 0.2em 0;- }-- .or-FormOutputText {- border-bottom: 1px solid transparent;- }-- .or-FormTextArea {- font-size: 1em;- font-family: monospace;- padding: 0.4em 1.4em;- margin: 0;- white-space: pre;- resize: none;- }-- .or-FormTextArea.border {- border-width: 1px;- border-style: solid;- padding: 0.4em 0.4em !important;- }-- .or-FormFileUploadLabel input[type="file"] {- position: fixed;- top: -10000px;- }-- .or-FormButton,- .or-FormButtonDown,- .or-FormButtonDanger,- .or-FormButtonPrimary,- .or-FormFileUploadLabel {- padding: 0 0.4em;- border: 2px dotted transparent;- }-- .or-FormListBox,- .or-FormValueListBox {- font-size: inherit;- border: 1px solid;- background: transparent;- }-- .or-FormCheckBox {- height: 1.8em;- }-- .or-FormGroupActions .or-FormControl {- margin: 0.1em 0.4em;- }-- .or-FormTableHeaderCell {- text-shadow: none;- border-bottom: 1px solid;- text-align: left;- padding-right: 1em;- white-space: nowrap;- }-- .or-FormTableHoveredRow {- cursor: pointer;- }-- .or-FormTableHoveredRowCell.or-FormTableCellText {- text-decoration: underline;- }-- .or-FormTableCell {- padding: 0.4em 1.2em 0.4em 0.4em;- }-- .or-FormTableCell.nowrap {- white-space: nowrap;- }-- .or-FormTableFirstColumn {- white-space: normal;- }-- .or-FormTreeItem {- cursor: pointer;- line-height: 1.6em;- }-- .or-FormTreeItemImage {- cursor: row-resize;- }-- .or-FormTreeItemImage img {- }-- .or-FormTreeItemImageValue {- }-- .or-FormTreeItemValue {- outline: none;- white-space: nowrap;- margin-left: 0.2em;- margin-right: 0.4em;- -webkit-user-select: none;- -moz-user-select: none;- -ms-user-select: none;- user-select: none;;- }-- .or-FormTreeItemValue:hover {- opacity: .8;- }-- .or-FormTreeOpenItem {- }-- .or-FormTreeTopItem {- font-weight: 600;- cursor: pointer;- }-- .or-FormTreeTopItemImage {- }-- .or-FormTreeTopItemImageValue {- }-- .or-FormTreeKeyboardSelectedItem {- outline: none;- }-- .or-FormTreeSelectedItem {- height: auto;- overflow: visible;- }-- .or-FormTreeEmptyMessage,- .or-FormListEmptyMessage {- font-size: smaller;- font-style: italic;- text-align: center;- padding-bottom: 0.8em;- }-- .or-FormTreeShowMoreButton {- display: block;- font-size: smaller;- font-style: italic;- text-align: center;- padding-bottom: 0.8em;- text-decoration: none;- font-weight: 600;- }-- .or-FormTreeIcon {- margin-left: 0.4em;- width: 1.6em;- }-- .or-FormList {- overflow: auto;- }-- .or-FormList .or-FormListItem:last-child {- margin-bottom: 1.2em;- }-- .or-FormListItem {- border-radius: 0.3em;- margin: 0.4em;- padding: 0.4em;- }-- .or-FormListItem > .or-FormGroup:last-of-type {- margin-bottom: 0;- }-- .or-FormListEmptyMessage {- margin: 0.4em;- }-- .or-FormMessages,- .or-Toast {- font-size: smaller;- font-weight: 600;- padding: 0.8em;- border-radius: 0.25em;- -webkit-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);- -moz-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);- box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);- }- .or-FormMessages,- .or-Toast {- font-size: smaller;- font-weight: 600;- padding: 0.8em;- border-radius: 0.25em;- -webkit-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);- -moz-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);- box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);- }-- .or-ItemWithBorder {- border-width: 1px;- border-style: solid;- }-- .or-ItemWithBorder .opaque {- opacity: 0.44;- pointer-events: none;- user-select: none;- -webkit-user-select: none; /* Chrome/Safari/Opera */- -moz-user-select: none; /* Firefox */- -ms-user-select: none; /* IE/Edge */- -webkit-touch-callout: none; /* iOS Safari */- }-- .or-ConfirmationDialog {- width: 25em;- height: 10em;- }-- .or-HighlightBackground {- }-- .or-DatapointBrowser {- padding: 0.4em;- }-- .or-JsonEditor {- width: 55em;- height: 40em;- }-- .or-AdminNotificationEditor {- width: 50em;- height: 20em;- }-- .or-SimulatorElement {- }--</style>-</template>+ * html, body {+ box-sizing: border-box;+ }++ html, body {+ width: 100%;+ height: 100vh;+ min-height: 100%;+ margin: 0;+ overflow: hidden;+ }++ *:focus {+ outline: 0;+ }++ .or-Viewport {+ width: 100%;+ height: 100vh;+ min-height: 100%;+ margin: 0;+ }++ .or-Viewport,+ .or-PopupPanel {+ font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;+ font-weight: 500 !important;+ font-size: 0.9em;+ letter-spacing: 0.02em;+ }++ .or-NavItem {+ margin: 0.4em 1.2em 0 1.2em;+ font-size: 1.1em;+ border-radius: 0 !important;+ border-bottom: 0.4em solid transparent;+ border-top: 0.2em solid transparent;+ }++ .or-SecondaryNav {+ padding: 0.4em;+ min-width: 12em;+ }++ .or-SecondaryNav.vertical {+ padding-top: 2.8em !important;+ }++ .or-SecondaryNav.horizontal {+ padding: 0.4em;+ height: 2em;+ min-height: 2em;+ }++ .or-SecondaryNavItem {+ user-select: none;+ -webkit-user-select: none; /* Chrome/Safari/Opera */+ -moz-user-select: none; /* Firefox */+ -ms-user-select: none; /* IE/Edge */+ -webkit-touch-callout: none; /* iOS Safari */+ cursor: pointer;+ padding: 0.4em;+ border-radius: 0.15em;+ font-weight: 600;+ display: inline-block;+ margin: 0 1em;+ }++ .or-SecondaryNavItem a {+ text-decoration: none;+ }++ .or-SecondaryNavItem:hover,+ .or-SecondaryNavItem:focus {+ opacity: .8;+ }++ .or-SecondaryNavItem.or-FormControl:hover,+ .or-SecondaryNavItem.or-FormControl:focus {+ opacity: 1;+ }++ .or-RightGradient::before {+ background-image: -webkit-linear-gradient(left, transparent 0, rgba(0, 0, 0, 0.5) 100%);+ content: "\00a0";+ height: 100%;+ position: absolute;+ right: 0;+ width: 2em;+ z-index: 9;+ }++ .or-LeftGradient::before {+ background: -moz-linear-gradient(right, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);+ background: -webkit-linear-gradient(right, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);+ background: linear-gradient(to left, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);+ content: "\00a0";+ height: 100%;+ position: absolute;+ left: 0;+ width: 2em;+ z-index: 9;+ }++ .or-MainContent {+ padding: .8em .8em 0 .8em+ }++ .or-MainContent:last-child {+ }++ .or-PushButton,+ .or-FormFileUploadLabel {+ user-select: none;+ -webkit-user-select: none; /* Chrome/Safari/Opera */+ -moz-user-select: none; /* Firefox */+ -ms-user-select: none; /* IE/Edge */+ -webkit-touch-callout: none; /* iOS Safari */+ cursor: pointer;+ padding: 0.4em;+ border-radius: 0.15em;+ font-weight: 600;+ display: inline-block;+ white-space: nowrap;+ /* https://stackoverflow.com/questions/25594630/img-moves-when-changing-opacity-on-hover */+ -backface-visibility: hidden;+ -webkit-backface-visibility: hidden;+ -moz-backface-visibility: hidden;+ -o-backface-visibility: hidden;+ -webkit-transform: translateZ(0) scale(1.0, 1.0);+ }++ .or-PushButton,+ .or-FormFileUploadLabel,+ .or-PushButton > *,+ .or-FormFileUploadLabel > * {+ display: inline-block;+ }++ .or-PushButton:hover,+ .or-FormFileUploadLabel:hover {+ opacity: .8;+ }++ .or-PushButton:active,+ .or-FormFileUploadLabel:active {+ -webkit-filter: contrast(44%);+ filter: contrast(44%);+ opacity: inherit;+ }++ .or-PushButtonIcon + .html-face:not(:empty) {+ margin-left: 0.6em;+ }++ .or-PushButton.or-PushButton-up-disabled {+ cursor: not-allowed;+ opacity: .44;+ }++ .or-PushButton.or-PushButton-up-disabled:hover,+ .or-PushButton.or-PushButton-up-disabled:active {+ -webkit-filter: inherit;+ filter: inherit;+ }++ .or-Divider {+ min-height: 0.1em;+ margin: 1em 0;+ }++ .or-Hyperlink,+ .or-FormAnchor {+ display: inline-block;+ white-space: nowrap;+ }++ .or-HyperlinkIcon {+ width: 0.8em;+ }++ .or-Hyperlink a,+ .or-Hyperlink a:visited,+ .or-FormAnchor,+ .or-FormAnchor:visited {+ cursor: pointer;+ font-weight: 600;+ text-decoration: none;+ display: inline-block;+ padding: 0.4em 0.8em;+ border-radius: 0.2em;+ }++ .or-FormAnchor,+ .or-FormAnchor:visited {+ font-style: italic;+ font-weight: normal;+ text-decoration: underline;+ }++ .or-Hyperlink a:hover,+ .or-Hyperlink a:focus,+ .or-FormAnchor:hover,+ .or-FormAnchor:focus {+ text-decoration: underline;+ }++ .or-SecondaryNav .or-Hyperlink {+ padding: 0;+ border-radius: 0+ }++ .or-SecondaryNav .or-Hyperlink a:hover,+ .or-SecondaryNav .or-Hyperlink a:focus {+ text-decoration: none;+ }++ .or-Headline {+ margin: 0 0 0.8em 0;+ }++ .or-HeadlineIcon,+ .or-HeadlineText {+ font-size: x-large !important;+ }++ .or-HeadlineText {+ font-weight: 600;+ }++ .or-HeadlineIcon {+ margin-right: 0.4em;+ }++ .or-HeadlineSub {+ font-size: smaller;+ font-weight: 600;+ margin: 0.4em 0;+ }++ .or-UnorderedList {+ list-style: square inside none;+ margin: 0;+ padding: 0;+ white-space: nowrap;+ }++ .or-MessagesIcon {+ font-size: larger;+ }++ .or-Form {+ transition: opacity 0.1s linear;+ -moz-transition: opacity 0.1s linear;+ -webkit-transition: opacity 0.1s linear;+ }++ .or-FormBusy {+ opacity: 0;+ pointer-events: none;+ user-select: none;+ -webkit-user-select: none; /* Chrome/Safari/Opera */+ -moz-user-select: none; /* Firefox */+ -ms-user-select: none; /* IE/Edge */+ -webkit-touch-callout: none; /* iOS Safari */+ }++ .or-FormMessages {+ display: table;+ margin: 1em;+ }++ .or-Toast .or-MessagesIcon,+ .or-FormMessages .or-MessagesIcon {+ margin: 0em 0.4em 0 0;+ }++ .or-FormGroup {+ margin-bottom: 0.4em;+ padding: 0.4em;+ }++ .or-FormSection.opaque .or-FormLabel,+ .or-FormSection.opaque .or-FormOutputText+ .or-FormGroup.opaque .or-FormLabel,+ .or-FormGroup.opaque .or-FormOutputText {+ opacity: 0.44;+ }++ .or-FormSection .or-FormSection {+ margin: 0.4em;+ padding: 0.4em;+ }++ .or-FormGroup.expanded .or-FormGroup {+ }++ .or-FormGroup.expanded .or-FormGroup .or-FormLabel {+ font-size: 0.8em;+ }++ .or-FormGroupExtension {+ margin: 0.8em;+ }++ .or-Form .or-FormSectionLabel {+ margin: 0.6em 0 0.4em 0;+ font-size: 1.2em;+ }++ .or-FormGroupExtension .or-FormSectionLabel {+ margin: 0.8em 0 0.4em 0;+ font-size: inherit;+ font-weight: 600;+ }++ .or-FormLabel {+ width: 10em;+ padding: 0.2em 0;+ font-weight: 600;+ white-space: normal;+ overflow: hidden;+ }++ .or-FormLabelIcon {+ margin-right: 0.4em;+ font-size: 1.2em;+ opacity: 0.4;+ align-self: flex-end;+ }++ .or-FormInlineLabelIcon {+ margin-right: 0.4em;+ }++ .or-FormLabel.inline {+ width: inherit;+ }++ .or-FormLabel.larger {+ width: 15em;+ }++ .or-FormLabel.largest {+ width: 25em;+ }++ .or-FormField {+ min-width: 10em;+ }++ .or-FormField.larger {+ width: 100%;+ }++ .or-FormInfoLabel {+ font-size: 0.7em;+ font-weight: 500;+ max-width: 14em;+ }++ .or-FormLabel.larger ~ .or-FormInfoLabel {+ max-width: 20em;+ }++ .or-FormControl {+ white-space: nowrap;+ font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;+ font-size: inherit;+ border: none;+ margin: 0 0.4em;+ }++ .or-FormControl[disabled],+ .or-FormSection.opaque .or-FormControl,+ .or-FormGroup.opaque .or-FormControl {+ cursor: not-allowed;+ pointer-events: none;+ opacity: .44;+ }++ .or-FormControl.or-FormCheckBox[disabled] {+ opacity: 1;+ }++ .or-FormSection.opaque .or-FormCheckBox,+ .or-FormGroup.opaque .or-FormCheckBox {+ opacity: 0.44;+ }++ .or-FormInputText,+ .or-FormInputNumber {+ border-bottom: 1px solid;+ font-size: inherit;+ }++ .or-FormInputText[readOnly],+ .or-FormInputNumber[readOnly] {+ border-color: transparent;+ cursor: text;+ }++ .or-FormInputText,+ .or-FormInputNumber,+ .or-FormOutputText {+ padding: 0.2em 0;+ }++ .or-FormOutputText {+ border-bottom: 1px solid transparent;+ }++ .or-FormTextArea {+ font-size: 1em;+ font-family: monospace;+ padding: 0.4em 1.4em;+ margin: 0;+ white-space: pre;+ resize: none;+ }++ .or-FormTextArea.border {+ border-width: 1px;+ border-style: solid;+ padding: 0.4em 0.4em !important;+ }++ .or-FormFileUploadLabel input[type="file"] {+ position: fixed;+ top: -10000px;+ }++ .or-FormButton,+ .or-FormButtonDown,+ .or-FormButtonDanger,+ .or-FormButtonPrimary,+ .or-FormFileUploadLabel {+ padding: 0 0.4em;+ border: 2px dotted transparent;+ }++ .or-FormListBox,+ .or-FormValueListBox {+ font-size: inherit;+ border: 1px solid;+ background: transparent;+ }++ .or-FormCheckBox {+ height: 1.8em;+ }++ .or-FormGroupActions .or-FormControl {+ margin: 0.1em 0.4em;+ }++ .or-FormTableHeaderCell {+ text-shadow: none;+ border-bottom: 1px solid;+ text-align: left;+ padding-right: 1em;+ white-space: nowrap;+ }++ .or-FormTableHoveredRow {+ cursor: pointer;+ }++ .or-FormTableHoveredRowCell.or-FormTableCellText {+ text-decoration: underline;+ }++ .or-FormTableCell {+ padding: 0.4em 1.2em 0.4em 0.4em;+ }++ .or-FormTableCell.nowrap {+ white-space: nowrap;+ }++ .or-FormTableFirstColumn {+ white-space: normal;+ }++ .or-FormTreeItem {+ cursor: pointer;+ line-height: 1.6em;+ }++ .or-FormTreeItemImage {+ cursor: row-resize;+ }++ .or-FormTreeItemImage img {+ }++ .or-FormTreeItemImageValue {+ }++ .or-FormTreeItemValue {+ outline: none;+ white-space: nowrap;+ margin-left: 0.2em;+ margin-right: 0.4em;+ -webkit-user-select: none;+ -moz-user-select: none;+ -ms-user-select: none;+ user-select: none;;+ }++ .or-FormTreeItemValue:hover {+ opacity: .8;+ }++ .or-FormTreeOpenItem {+ }++ .or-FormTreeTopItem {+ font-weight: 600;+ cursor: pointer;+ }++ .or-FormTreeTopItemImage {+ }++ .or-FormTreeTopItemImageValue {+ }++ .or-FormTreeKeyboardSelectedItem {+ outline: none;+ }++ .or-FormTreeSelectedItem {+ height: auto;+ overflow: visible;+ }++ .or-FormTreeEmptyMessage,+ .or-FormListEmptyMessage {+ font-size: smaller;+ font-style: italic;+ text-align: center;+ padding-bottom: 0.8em;+ }++ .or-FormTreeShowMoreButton {+ display: block;+ font-size: smaller;+ font-style: italic;+ text-align: center;+ padding-bottom: 0.8em;+ text-decoration: none;+ font-weight: 600;+ }++ .or-FormTreeIcon {+ margin-left: 0.4em;+ width: 1.6em;+ }++ .or-FormList {+ overflow: auto;+ }++ .or-FormList .or-FormListItem:last-child {+ margin-bottom: 1.2em;+ }++ .or-FormListItem {+ border-radius: 0.3em;+ margin: 0.4em;+ padding: 0.4em;+ }++ .or-FormListItem > .or-FormGroup:last-of-type {+ margin-bottom: 0;+ }++ .or-FormListEmptyMessage {+ margin: 0.4em;+ }++ .or-FormMessages,+ .or-Toast {+ font-size: smaller;+ font-weight: 600;+ padding: 0.8em;+ border-radius: 0.25em;+ -webkit-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);+ -moz-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);+ box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);+ }++ .or-FormMessages,+ .or-Toast {+ font-size: smaller;+ font-weight: 600;+ padding: 0.8em;+ border-radius: 0.25em;+ -webkit-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);+ -moz-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);+ box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);+ }++ .or-ItemWithBorder {+ border-width: 1px;+ border-style: solid;+ }++ .or-ItemWithBorder .opaque {+ opacity: 0.44;+ pointer-events: none;+ user-select: none;+ -webkit-user-select: none; /* Chrome/Safari/Opera */+ -moz-user-select: none; /* Firefox */+ -ms-user-select: none; /* IE/Edge */+ -webkit-touch-callout: none; /* iOS Safari */+ }++ .or-ConfirmationDialog {+ width: 25em;+ height: 10em;+ }++ .or-HighlightBackground {+ }++ .or-DatapointBrowser {+ padding: 0.4em;+ }++ .or-JsonEditor {+ width: 55em;+ height: 40em;+ }++ .or-AdminNotificationEditor {+ width: 50em;+ height: 20em;+ }++ .or-SimulatorElement {+ }++ .or-Select {+ position: relative;+ display: inline-block;+ }++ .or-Select select {+ font-family: 'Open Sans', 'Roboto', Helvetica, Arial, Lucida, sans-serif;+ font-weight: 600;+ display: inline-block;+ cursor: pointer;+ padding: 0 0.4em;+ font-size: 1em;+ min-height: 1.5em;+ line-height: 1;+ outline: 0;+ border: 0;+ border-radius: 0;+ appearance: none;+ -webkit-appearance: none;+ -moz-appearance: none;+ box-sizing: content-box;+ -moz-box-sizing: content-box;;+ -webkit-box-sizing: content-box;;+ -webkit-tap-highlight-color: transparent;+ }++ .or-Select select::-ms-expand {+ display: none;+ }++ .or-Select select:disabled {+ opacity: 0.5;+ pointer-events: none;+ }++ .or-CheckBox {+ position: absolute;+ opacity: 0;+ margin: 0;+ cursor: pointer;+ -webkit-touch-callout: none;+ -webkit-user-select: none;+ -moz-user-select: none;+ -ms-user-select: none;+ user-select: none;+ -webkit-tap-highlight-color: transparent;+ }++ .or-CheckBox:disabled {+ cursor: default;+ }++ .or-CheckBox,+ .or-CheckBox + label,+ .or-CheckBox + label:before {+ font-size: 1em;+ display: inline-block;+ width: 1.5em;+ height: 1.5em;+ }++ .or-CheckBox + label {+ position: relative;+ padding: 0;+ pointer-events: none;+ }++ .or-CheckBox + label:before {+ content: '';+ vertical-align: text-top;+ pointer-events: none;+ }++ .or-CheckBox:checked + label:after {+ content: '';+ position: absolute;+ left: 0.4em;+ top: 0.7em;+ width: 0.2em;+ height: 0.2em;+ -webkit-transform: rotate(45deg);+ transform: rotate(45deg);+ }++ .or-Icon {+ display: inline-block;+ margin: 0 0.3em;+ }++ .or-Input {+ font-family: 'Open Sans', 'Roboto', Helvetica, Arial, Lucida, sans-serif;+ }++ .or-InputTime {+ font-weight: 600;+ font-size: 1em;+ cursor: pointer;+ white-space: nowrap;+ min-height: 1.5em;+ max-width: 5.5em;+ padding: 0 0.4em;+ border: 0;+ border-radius: 0;+ appearance: none;+ -webkit-appearance: none;+ -moz-appearance: none;+ box-sizing: content-box;+ -moz-box-sizing: content-box;;+ -webkit-box-sizing: content-box;;+ }++ .or-InputTime::-webkit-clear-button,+ .or-InputTime::-webkit-inner-spin-button {+ display: none;+ }++ .or-InputTime::-webkit-datetime-edit-text,+ .or-InputTime::-webkit-datetime-edit-fields-wrapper,+ .or-InputTime::-webkit-date-and-time-value,+ .or-InputTime::-webkit-datetime-edit-ampm-field,+ .or-InputTime::-webkit-datetime-edit-day-field,+ .or-InputTime::-webkit-datetime-edit-hour-field,+ .or-InputTime::-webkit-datetime-edit-millisecond-field,+ .or-InputTime::-webkit-datetime-edit-minute-field,+ .or-InputTime::-webkit-datetime-edit-month-field,+ .or-InputTime::-webkit-datetime-edit-second-field,+ .or-InputTime::-webkit-datetime-edit-week-field,+ .or-InputTime::-webkit-datetime-edit-year-field{+ margin: 0;+ padding: 0;+ }+ </style>+ </template></dom-module>\ No newline at end of filediff --git a/client/src/main/webapp/src/or-app/or-theme.html b/client/src/main/webapp/src/or-app/or-theme.htmlindex a3d9092a3..d82509400 100644--- a/client/src/main/webapp/src/or-app/or-theme.html+++ b/client/src/main/webapp/src/or-app/or-theme.html@@ -4,441 +4,475 @@<template><style include="colors">- ::-webkit-scrollbar-track {- background-color: var(--theme-black);- }-- ::-webkit-scrollbar-thumb {- background-color: var(--theme-lightgreen);- }-- .or-Viewport {- background-color: var(--theme-white);- }-- .or-Header {- color: var(--theme-white);- background-color: var(--theme-darkgrey);- }-- .or-Footer {- color: var(--theme-white);- background-color: var(--theme-black);- }-- .or-Footer a {- color: var(--theme-white) !important;- }-- .or-NavItem {- background: transparent;- color: var(--theme-white) !important;- }-- .or-NavItem.or-PushButton {- background: transparent;- }-- .or-NavItem.active {- background: var(--theme-black) !important;- color: var(--theme-lightgreen) !important;- border-top-color: var(--theme-lightgreen) !important;- }-- .or-SecondaryNav {- background-color: var(--theme-black);- color: var(--theme-white);- }-- .or-SecondaryNavItem {- background: transparent;- }-- .or-SecondaryNavItem.or-PushButton {- background: transparent;- color: var(--theme-white);- }-- .or-SecondaryNavItem.or-PushButton.primary {- color: var(--theme-lightgreen);- }-- .or-SecondaryNavItem.or-FormInputText,- .or-SecondaryNavItem.or-FormInputNumber {- background: var(--theme-white);- color: var(--theme-black);- }-- .or-SecondaryNavItem a {- color: var(--theme-white) !important;- }-- .or-SecondaryNavItem.active {- color: var(--theme-lightgreen) !important;- }-- .or-SecondaryNavItem.active a {- color: var(--theme-lightgreen) !important;- }-- .or-SidebarContent {- background-color: var(--theme-black);- color: var(--theme-white);- }-- .or-MainContent {-- }-- .or-PushButton,- .or-FormFileUploadLabel {- background-color: var(--theme-lightgrey);- color: var(--theme-black);- }-- .or-Hyperlink a,- .or-Hyperlink a:visited {- color: var(--theme-darkgrey);- }-- .or-UnorderedList {- color: var(--theme-darkgrey);- }-- .or-Headline {- color: var(--theme-darkgrey);- }-- .or-HeadlineSub {- color: var(--theme-mediumgrey);- }-- .or-FormMessages.error {- background-color: var(--theme-red);- color: var(--theme-white);- border-color: transparent;- }-- .or-FormMessages.success {- color: var(--theme-darkgrey);- background-color: var(--theme-lightgreen)- }-- .or-FormMessages.info {- color: var(--theme-black);- background-color: var(--theme-lightgrey)- }-- .or-FormGroup {- background-image: -webkit-linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);- background-image: -moz-linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);- background-image: linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);- }-- .or-PopupPanelContent .or-FormGroup {- background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);- background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);- background-image: linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);- }-- .or-FormGroup.expanded {- }-- .or-FormSection .or-FormSection {- background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);- background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);- background-image: linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);- }-- .or-FormSection .or-FormSection .or-FormGroup {- background: inherit- }-- .or-FormSectionLabel {- color: var(--theme-mediumgrey);- }-- .or-FormLabel.error,- .or-FormLabel.error + .or-FormInfoLabel {- color: var(--theme-red);- }-- .or-FormField.error .or-FormControl {- border-color: var(--theme-red);- }-- .or-FormField.error .or-FormOutputText {- border-color: transparent;- }-- .or-FormField.error .or-FormInfoLabel,- .or-FormField.error .or-FormInfoLabel .or-FormControl {- color: var(--theme-mediumgrey);- border-color: transparent;- }-- .or-FormControl.error {- background-color: var(--theme-red) !important;- color: var(--theme-white) !important;- }-- .or-FormControl.primary {- background-color: var(--theme-lightgreen);- }-- .or-FormLabel {- color: var(--theme-darkgrey);- }-- .or-FormField {-- }-- .or-FormInfoLabel {- color: var(--theme-mediumgrey);- }-- .or-FormControl {-- }-- .or-FormInputText,- .or-FormInputNumber {- border-color: var(--theme-darkgrey);- background: transparent;- }-- .or-FormInputText:focus,- .or-FormInputNumber:focus {- border-color: var(--theme-lightgreen);- }-- .or-FormInputText[readOnly]:focus,- .or-FormInputNumber[readOnly]:focus {- border-color: transparent;- }-- .or-FormTextArea {- background-color: var(--theme-brightgrey);- }-- .or-FormTextArea.border {- border-color: var(--theme-darkgrey);- }-- .or-FormButton {- }-- .or-FormButtonPrimary {- color: var(--theme-black);- background: var(--theme-lightgreen);- }-- .or-FormButtonDown {- color: var(--theme-lightgrey);- background: var(--theme-black);- }-- .or-FormButtonDanger {- color: var(--theme-white);- background: var(--theme-red);- }-- .or-FormButton:focus,- .or-FormButtonDanger:focus,- .or-FormButtonDown:focus,- .or-FormButtonPrimary:focus {- border-color: var(--theme-black);- }-- .or-Divider {- background-image: -webkit-linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));- background-image: -moz-linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));- background-image: linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));- }-- .or-PushButton-up-disabled:focus {- border-color: transparent;- }-- .or-FormListBox,- .or-FormValueListBox {- border-color: var(--theme-darkgrey);- }-- .or-FormListBox:focus,- .or-FormValueListBox:focus {- border-color: var(--theme-lightgreen);- }-- .or-FormCheckBox:checked {- color: var(--theme-lightgreen);- }-- .or-FormTableHeaderCell {- border-color: var(--theme-mediumgrey);- color: var(--theme-darkgrey);- }-- .or-FormTableHoveredRow {- background-color: var(--theme-lightgrey) !important;- }-- .or-FormTableEvenRow {- background-color: var(--theme-brightgrey);- }-- .or-FormTableOddRow {- background-color: var(--theme-white);- }-- .or-FormTreeItem {- color: var(--theme-white);- }-- .or-FormTreeItemImage {- }-- .or-FormTreeTopItem {- }-- .or-FormTreeKeyboardSelectedItem {- background-color: var(--theme-mediumgrey);- }-- .or-FormTreeKeyboardSelectedItem .or-FormTreeIcon {- color: var(--theme-white);- }-- .or-FormTreeSelectedItem {- background-color: var(--theme-lightgreen);- }-- .or-FormTreeSelectedItem .or-FormTreeItem {- color: var(--theme-black);- }-- .or-FormTreeEmptyMessage {- color: var(--theme-mediumgrey);- }-- .or-FormTreeShowMoreButton {- color: var(--theme-lightgreen);- }-- .or-FormTreeIcon {- color: var(--theme-mediumgrey);- }-- .or-FormAnchor,- .or-FormAnchor a:visited {- color: var(--theme-darkgrey);- }-- .or-MainContent {- background-color: var(--theme-white);- box-shadow: inset 0px 2px 4px 0px var(--theme-mediumgrey);- -webkit-box-shadow: inset 0px 2px 4px 0px var(--theme-mediumgrey);- -moz-box-shadow: inset 0px 2px 4px 0px var(--theme-mediumgrey);- }-- .or-FormList {- background-color: var(--theme-lightgrey);- }-- .or-FormListItem {- background: var(--theme-white);- }-- .or-FormListItem .warn {- color: var(--theme-yellow);- }-- .or-FormListItem .error {- color: var(--theme-red);- }-- .or-FormListEmptyMessage {- color: var(--theme-mediumgrey);- }-- .or-ToastInfo {- background-color: var(--theme-lightgrey);- color: var(--theme-black);- }-- .or-ToastSuccess {- background-color: var(--theme-lightgreen);- color: var(--theme-black);- }-- .or-ToastFailure {- background-color: var(--theme-red);- color: var(--theme-white);- }-- .or-PopupPanel {- background-color: var(--theme-brightgrey);- color: var(--theme-black);- }-- .or-PopupPanelHeader {- background-color: var(--theme-lightgreen);- color: var(--theme-black);- }-- .or-PopupPanelContent {- }-- .or-PopupPanelFooter {- background-color: var(--theme-black);- color: var(--theme-white);- }-- .or-PopupPanelGlass {- background-color: rgba(0, 0, 0, 0.44);- }-- .or-SplitPanelHandle {- background-color: var(--theme-black);- color: var(--theme-white);- }-- .or-ItemWithBorder {- border-color: var(--theme-lightgrey);- }-- .or-PopupPanelContent.or-HighlightBackground,- .or-HighlightBackground .or-ValueEditor {- background-color: var(--theme-lightgreen);- border-color: transparent;- color: white;- }-- .or-HighlightBackground .or-ValueEditor .or-FormControl {- color: var(--theme-white);- border-color: transparent;- }-- .or-BorderRed {- border-color: var(--theme-red);- }-- .or-BorderGreen {- border-color: var(--theme-mediumgreen);- }-- .or-BorderYellow {- border-color: var(--theme-yellow);- }-- .or-BorderDefault {- border-color: var(--theme-lightergrey);- }-- .or-DatapointBrowser {- }--</style>-</template>+ .or-Viewport {+ background-color: var(--theme-white);+ }++ .or-Header {+ color: var(--theme-white);+ background-color: var(--theme-darkgrey);+ }++ .or-Footer {+ color: var(--theme-white);+ background-color: var(--theme-black);+ }++ .or-Footer a {+ color: var(--theme-white) !important;+ }++ .or-NavItem {+ background: transparent;+ color: var(--theme-white) !important;+ }++ .or-NavItem.or-PushButton {+ background: transparent;+ }++ .or-NavItem.active {+ background: var(--theme-black) !important;+ color: var(--theme-lightgreen) !important;+ border-top-color: var(--theme-lightgreen) !important;+ }++ .or-SecondaryNav {+ background-color: var(--theme-black);+ color: var(--theme-white);+ }++ .or-SecondaryNavItem {+ background: transparent;+ }++ .or-SecondaryNavItem.or-PushButton {+ background: transparent;+ color: var(--theme-white);+ }++ .or-SecondaryNavItem.or-PushButton.primary {+ color: var(--theme-lightgreen);+ }++ .or-SecondaryNavItem.or-FormInputText,+ .or-SecondaryNavItem.or-FormInputNumber {+ background: var(--theme-white);+ color: var(--theme-black);+ }++ .or-SecondaryNavItem a {+ color: var(--theme-white) !important;+ }++ .or-SecondaryNavItem.active {+ color: var(--theme-lightgreen) !important;+ }++ .or-SecondaryNavItem.active a {+ color: var(--theme-lightgreen) !important;+ }++ .or-SidebarContent {+ background-color: var(--theme-black);+ color: var(--theme-white);+ }++ .or-MainContent {++ }++ .or-PushButton,+ .or-FormFileUploadLabel {+ background-color: var(--theme-lightgrey);+ color: var(--theme-black);+ }++ .or-Hyperlink a,+ .or-Hyperlink a:visited {+ color: var(--theme-darkgrey);+ }++ .or-UnorderedList {+ color: var(--theme-darkgrey);+ }++ .or-Headline {+ color: var(--theme-darkgrey);+ }++ .or-HeadlineSub {+ color: var(--theme-mediumgrey);+ }++ .or-FormMessages.error {+ background-color: var(--theme-red);+ color: var(--theme-white);+ border-color: transparent;+ }++ .or-FormMessages.success {+ color: var(--theme-darkgrey);+ background-color: var(--theme-lightgreen)+ }++ .or-FormMessages.info {+ color: var(--theme-black);+ background-color: var(--theme-lightgrey)+ }++ .or-FormGroup {+ background-image: -webkit-linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);+ background-image: -moz-linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);+ background-image: linear-gradient(45deg, var(--theme-brightgrey) 0%, var(--theme-white) 100%);+ }++ .or-PopupPanelContent .or-FormGroup {+ background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);+ background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);+ background-image: linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-brightgrey) 100%);+ }++ .or-FormGroup.expanded {+ }++ .or-FormSection .or-FormSection {+ background-image: -webkit-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);+ background-image: -moz-linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);+ background-image: linear-gradient(45deg, var(--theme-lightergrey) 0%, var(--theme-white) 100%);+ }++ .or-FormSection .or-FormSection .or-FormGroup {+ background: inherit+ }++ .or-FormSectionLabel {+ color: var(--theme-mediumgrey);+ }++ .or-FormLabel.error,+ .or-FormLabel.error + .or-FormInfoLabel {+ color: var(--theme-red);+ }++ .or-FormField.error .or-FormControl {+ border-color: var(--theme-red);+ }++ .or-FormField.error .or-FormOutputText {+ border-color: transparent;+ }++ .or-FormField.error .or-FormInfoLabel,+ .or-FormField.error .or-FormInfoLabel .or-FormControl {+ color: var(--theme-mediumgrey);+ border-color: transparent;+ }++ .or-FormControl.error {+ background-color: var(--theme-red) !important;+ color: var(--theme-white) !important;+ }++ .or-FormControl.primary {+ background-color: var(--theme-lightgreen);+ }++ .or-FormLabel {+ color: var(--theme-darkgrey);+ }++ .or-FormField {++ }++ .or-FormInfoLabel {+ color: var(--theme-mediumgrey);+ }++ .or-FormControl {++ }++ .or-FormInputText,+ .or-FormInputNumber {+ border-color: var(--theme-darkgrey);+ background: transparent;+ }++ .or-FormInputText:focus,+ .or-FormInputNumber:focus {+ border-color: var(--theme-lightgreen);+ }++ .or-FormInputText[readOnly]:focus,+ .or-FormInputNumber[readOnly]:focus {+ border-color: transparent;+ }++ .or-FormTextArea {+ background-color: var(--theme-brightgrey);+ }++ .or-FormTextArea.border {+ border-color: var(--theme-darkgrey);+ }++ .or-FormButton {+ }++ .or-FormButtonPrimary {+ color: var(--theme-black);+ background: var(--theme-lightgreen);+ }++ .or-FormButtonDown {+ color: var(--theme-lightgrey);+ background: var(--theme-black);+ }++ .or-FormButtonDanger {+ color: var(--theme-white);+ background: var(--theme-red);+ }++ .or-FormButton:focus,+ .or-FormButtonDanger:focus,+ .or-FormButtonDown:focus,+ .or-FormButtonPrimary:focus {+ border-color: var(--theme-black);+ }++ .or-Divider {+ background-image: -webkit-linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));+ background-image: -moz-linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));+ background-image: linear-gradient(left, var(--theme-white), var(--theme-lightgreen), var(--theme-white));+ }++ .or-PushButton-up-disabled:focus {+ border-color: transparent;+ }++ .or-FormListBox,+ .or-FormValueListBox {+ border-color: var(--theme-darkgrey);+ }++ .or-FormListBox:focus,+ .or-FormValueListBox:focus {+ border-color: var(--theme-lightgreen);+ }++ .or-FormCheckBox:checked {+ color: var(--theme-lightgreen);+ }++ .or-FormTableHeaderCell {+ border-color: var(--theme-mediumgrey);+ color: var(--theme-darkgrey);+ }++ .or-FormTableHoveredRow {+ background-color: var(--theme-lightgrey) !important;+ }++ .or-FormTableEvenRow {+ background-color: var(--theme-brightgrey);+ }++ .or-FormTableOddRow {+ background-color: var(--theme-white);+ }++ .or-FormTreeItem {+ color: var(--theme-white);+ }++ .or-FormTreeItemImage {+ }++ .or-FormTreeTopItem {+ }++ .or-FormTreeKeyboardSelectedItem {+ background-color: var(--theme-mediumgrey);+ }++ .or-FormTreeKeyboardSelectedItem .or-FormTreeIcon {+ color: var(--theme-white);+ }++ .or-FormTreeSelectedItem {+ background-color: var(--theme-lightgreen);+ }++ .or-FormTreeSelectedItem .or-FormTreeItem {+ color: var(--theme-black);+ }++ .or-FormTreeEmptyMessage {+ color: var(--theme-mediumgrey);+ }++ .or-FormTreeShowMoreButton {+ color: var(--theme-lightgreen);+ }++ .or-FormTreeIcon {+ color: var(--theme-mediumgrey);+ }++ .or-FormAnchor,+ .or-FormAnchor a:visited {+ color: var(--theme-darkgrey);+ }++ .or-MainContent {+ background-color: var(--theme-white);+ box-shadow: inset 0px 2px 4px 0px var(--theme-mediumgrey);+ -webkit-box-shadow: inset 0px 2px 4px 0px var(--theme-mediumgrey);+ -moz-box-shadow: inset 0px 2px 4px 0px var(--theme-mediumgrey);+ }++ .or-FormList {+ background-color: var(--theme-lightgrey);+ }++ .or-FormListItem {+ background: var(--theme-white);+ }++ .or-FormListItem .warn {+ color: var(--theme-yellow);+ }++ .or-FormListItem .error {+ color: var(--theme-red);+ }++ .or-FormListEmptyMessage {+ color: var(--theme-mediumgrey);+ }++ .or-ToastInfo {+ background-color: var(--theme-lightgrey);+ color: var(--theme-black);+ }++ .or-ToastSuccess {+ background-color: var(--theme-lightgreen);+ color: var(--theme-black);+ }++ .or-ToastFailure {+ background-color: var(--theme-red);+ color: var(--theme-white);+ }++ .or-PopupPanel {+ background-color: var(--theme-brightgrey);+ color: var(--theme-black);+ }++ .or-PopupPanelHeader {+ background-color: var(--theme-lightgreen);+ color: var(--theme-black);+ }++ .or-PopupPanelContent {+ }++ .or-PopupPanelFooter {+ background-color: var(--theme-black);+ color: var(--theme-white);+ }++ .or-PopupPanelGlass {+ background-color: rgba(0, 0, 0, 0.44);+ }++ .or-SplitPanelHandle {+ background-color: var(--theme-black);+ color: var(--theme-white);+ }++ .or-ItemWithBorder {+ border-color: var(--theme-lightgrey);+ }++ .or-PopupPanelContent.or-HighlightBackground,+ .or-HighlightBackground .or-ValueEditor {+ background-color: var(--theme-lightgreen);+ border-color: transparent;+ color: white;+ }++ .or-HighlightBackground .or-ValueEditor .or-FormControl {+ color: var(--theme-white);+ border-color: transparent;+ }++ .or-BorderRed {+ border-color: var(--theme-red);+ }++ .or-BorderGreen {+ border-color: var(--theme-mediumgreen);+ }++ .or-BorderYellow {+ border-color: var(--theme-yellow);+ }++ .or-BorderDefault {+ border-color: var(--theme-lightergrey);+ }++ .or-DatapointBrowser {+ }++ .or-Select select {+ background-color: var(--theme-lightgreen);+ color: var(--theme-black);+ }++ .or-Select select:-moz-focusring {+ color: transparent;+ text-shadow: 0 0 0 var(--theme-black);+ }++ .or-Select option:not(:checked) {+ color: var(--theme-black);+ }++ .or-CheckBox + label:before {+ background-color: var(--theme-lightgreen);+ }++ .or-CheckBox:checked + label:after {+ -webkit-box-shadow: 2px 0 0 var(--theme-black), 4px 0 0 var(--theme-black), 4px -2px 0 var(--theme-black), 4px -4px 0 var(--theme-black), 4px -6px 0 var(--theme-black), 4px -8px 0 var(--theme-black);+ box-shadow: 2px 0 0 var(--theme-black), 4px 0 0 var(--theme-black), 4px -2px 0 var(--theme-black), 4px -4px 0 var(--theme-black), 4px -6px 0 var(--theme-black), 4px -8px 0 var(--theme-black);+ background-color: var(--theme-black);+ }++ .or-CheckBox:disabled + label:before,+ .or-CheckBox:disabled:hover + label:before {+ -webkit-box-shadow: none;+ box-shadow: none;+ background-color: var(--theme-lightergrey);+ }++ .or-CheckBox:disabled:checked + label:after {+ -webkit-box-shadow: 2px 0 0 var(--theme-mediumgrey), 4px 0 0 var(--theme-mediumgrey), 4px -2px 0 var(--theme-mediumgrey), 4px -4px 0 var(--theme-mediumgrey), 4px -6px 0 var(--theme-mediumgrey), 4px -8px 0 var(--theme-mediumgrey);+ box-shadow: 2px 0 0 var(--theme-mediumgrey), 4px 0 0 var(--theme-mediumgrey), 4px -2px 0 var(--theme-mediumgrey), 4px -4px 0 var(--theme-mediumgrey), 4px -6px 0 var(--theme-mediumgrey), 4px -8px 0 var(--theme-mediumgrey);+ background-color: var(--theme-mediumgrey);+ }++ .or-InputTime {+ background-color: var(--theme-lightgreen);+ color: var(--theme-black);+ }++ </style>+ </template></dom-module>\ No newline at end of filediff --git a/client/src/main/webapp/src/or-app/or-view-component.html b/client/src/main/webapp/src/or-app/or-view-component.htmlnew file mode 100644index 000000000..bca908090--- /dev/null+++ b/client/src/main/webapp/src/or-app/or-view-component.html@@ -0,0 +1,90 @@+<!-- Intl polyfill -->+<script src="/static/bower_components/intl/dist/Intl.js"></script>++<!-- Intl langage TODO How can we do this dynamically? -->+<script src="/static/bower_components/intl/locale-data/jsonp/en.js"></script>++<!-- Provides Polymer.AppLocalizeBehavior -->+<link rel="import" href="/static/bower_components/app-localize-behavior/app-localize-behavior.html">++<dom-module id="or-view-component">+ <script>+ class OpenRemoteViewComponent extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior], Polymer.Element) {+ static get properties() {+ return {+ widgetStyle: {+ type: openremote.style.WidgetStyle,+ value: () => {+ return openremote.WIDGET_STYLE+ }+ },+ // Default language for localize()+ language: {+ type: String,+ value: () => {+ let defaultLang = "en";+ let metas = document.getElementsByTagName('meta');+ if (metas) {+ for (let i = 0; i < metas.length; i++) {+ let meta = metas[i];+ if (meta.attributes.name &&+ meta.attributes.name.value === "or-language" &&+ meta.attributes.content &&+ meta.attributes.content.value) {+ return meta.attributes.content.value;+ }+ }+ }+ return defaultLang;+ }+ },+ // Yes, we want the key returned if localize(key) can't find an alternative...+ useKeyIfMissing: {+ type: Boolean,+ value: true+ },+ // URL of locales.json to load+ localesResource: {+ type: String+ }+ }+ }++ ready() {+ super.ready();++ // Load locales resources for localize() function+ if (this.loadResources) {+ if (this.localesResource) {+ this.loadResources(this.resolveUrl(this.localesResource));+ }+ } else {+ console.error("Missing Polymer.AppLocalizeBehavior, did you load the component?");+ }++ // View component is hidden by default, subclass decides when it's ready+ this.hideComponent();+ }++ // Subclass MUST call this at some point, usually in overriding connectedCallback()+ showComponent() {+ this.shadowRoot.host.style.visibility = "visible";+ }++ hideComponent() {+ this.shadowRoot.host.style.visibility = "hidden";+ }++ // GWT i18n resources, not the same as app-localize-behavior and localize()+ i18n(presenter, key) {+ return presenter ? presenter.messages()[key]() : "";+ }++ icon(name) {+ return "fa fa-" + name;+ }++ }+ </script>++</dom-module>\ No newline at end of filediff --git a/console/android/build.gradle b/console/android/build.gradleindex 494920f95..78c6fdfcc 100644--- a/console/android/build.gradle+++ b/console/android/build.gradle@@ -1,9 +1,9 @@buildscript {repositories {- jcenter()+ google()}dependencies {- classpath 'com.android.tools.build:gradle:3.0.0'+ classpath 'com.android.tools.build:gradle:3.0.1'}}diff --git a/console/android/gradle/wrapper/gradle-wrapper.jar b/console/android/gradle/wrapper/gradle-wrapper.jarindex 05ef575b0..13372aef5 100644Binary files a/console/android/gradle/wrapper/gradle-wrapper.jar and b/console/android/gradle/wrapper/gradle-wrapper.jar differdiff --git a/console/android/gradle/wrapper/gradle-wrapper.properties b/console/android/gradle/wrapper/gradle-wrapper.propertiesindex 0235ab959..1b8bc60f0 100644--- a/console/android/gradle/wrapper/gradle-wrapper.properties+++ b/console/android/gradle/wrapper/gradle-wrapper.properties@@ -1,6 +1,6 @@-#Mon Jan 18 13:00:36 CET 2016+#Tue Oct 31 15:17:22 CET 2017distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/dists-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zipdiff --git a/deployment/manager/consoles/customerA/.bowerrc b/deployment/manager/consoles/customerA/.bowerrcnew file mode 100644index 000000000..4f776c251--- /dev/null+++ b/deployment/manager/consoles/customerA/.bowerrc@@ -0,0 +1,9 @@+{+ "ignoredDependencies": [+ "polymer",+ "iron-flex-layout",+ "app-localize-behavior",+ "intl",+ "chart.js"+ ]+}\ No newline at end of filediff --git a/deployment/manager/consoles/customerA/bower.json b/deployment/manager/consoles/customerA/bower.jsonindex 8dbf3f72c..d446f1796 100644--- a/deployment/manager/consoles/customerA/bower.json+++ b/deployment/manager/consoles/customerA/bower.json@@ -1,11 +1,11 @@{- "name": "customer-a-demo",+ "name": "smarthome-example","version": "3.0.0","homepage": "http://openremote.com/","authors": ["OpenRemote Inc. <[email protected]>"],- "description": "OR Manager",+ "description": "OpenRemote SmartHome Example App","main": "index.html","license": "APGLv3","ignore": [@@ -16,5 +16,7 @@"tests"],"dependencies": {+ "app-route": "PolymerElements/app-route#^2.0.3",+ "moment": "moment#^2.20.1"}}\ No newline at end of filediff --git a/deployment/manager/consoles/customerA/examples.html b/deployment/manager/consoles/customerA/examples.htmlnew file mode 100644index 000000000..369284f7c--- /dev/null+++ b/deployment/manager/consoles/customerA/examples.html@@ -0,0 +1,204 @@+<!doctype html>+<html>+<head>+ <title>OpenRemote Console Application</title>++ <meta http-equiv="content-type" content="text/html; charset=UTF-8">++ <!-- ############## Required: Load WebComponents polyfill and components ############### -->+ <script src="/static/bower_components/webcomponentsjs/webcomponents-lite.js"></script>++ <link rel="import" href="/static/src/or-app/or-app.html">+ <link rel="import" href="/static/src/or-asset-list/or-asset-list.html">+ <!-- Optional: You can import other OpenRemote modules here -->++ <!-- Optional: Load more application resources after authentication -->+ <script>+ window.addEventListener('AppReady', function (e) {+ console.log("Loading customerA console app resources...");+ let app = e.detail.app;++ // Load resources in parallel+ Promise.all([+ app.load.css("/static/3rdparty/mapbox-gl-js/0.42.2/mapbox-gl.css"),+ app.load.js("/static/3rdparty/mapbox-gl-js/0.42.2/mapbox-gl.js"),++ app.load.js("/static/bower_components/chart.js/dist/Chart.js"),++ app.load.js("/static/3rdparty/sprintf/1.0.3/sprintf.min.js")+ ]).then(() => {++ /*+ // Load resources sequentially+ app.load.js("/resource1")+ .then(() => {+ return app.load.js("/resource2")+ })+ .catch(e => {+ app.set("error", e);+ });+ */++ }).catch(e => {+ app.set("error", e);+ });++ })+ </script>++ <style type="text/css">+ /* Recommended: Avoid flickering during loading/styling by hiding children of or-app */+ or-app > * {+ visibility: hidden;+ }++ /* Optional: Create some styles only for your app */+ .myAppHeadline {+ display: block;+ text-decoration: none;+ padding: 1em;+ font-size: x-large;+ background: var(--theme-lightgreen);+ color: var(--theme-black);+ }+ </style>++</head>++<!-- Optional: You should use flexbox layout classes everywhere, starting with the body -->+<body class="layout vertical">++<!-- ############## Required: One <or-app> should wrap your frontend, you can enforce login/authentication ############## -->+<or-app login tenant-realm="customerA">++ <!-- With or-Viewport you get OpenRemote default fonts -->+ <div class="flex layout vertical or-Viewport">++ <!-- You can use your own styles or the OpenRemote styles and theme -->+ <a href="#" class="myAppHeadline">+ The OpenRemote console application of the <code>customerA</code> tenant+ </a>++ <!-- This is a container element that has some padding and visual separation from other containers -->+ <div class="or-MainContent">++ <p>+ On your OpenRemote installation, edit the HTML content in+ <code>deployment/manager/consoles/customerA/</code>.+ </p>+ <p>+ You can duplicate the <code>customerA</code> directory to create new console applications for other+ tenants/realms.+ </p>+ <p>+ View the source in your web browser and follow the examples on this page to write your own OpenRemote+ application, it's easy with <a href="https://www.webcomponents.org/">Web Components</a>.+ </p>+ </div>++ <!-- Switch to horizontal layout but flex vertical first and take as much vertical space as needed -->+ <div class="flex layout horizontal">++ <!-- Flex and take as much horizontal space as possible -->+ <div class="flex layout vertical">++ <!-- Execute an asset query and show a nice scrollable list -->+ <or-asset-list class="myAssetList flex or-MainContent or-FormList"+ select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"+ asset-type="urn:openremote:asset:residence">++ <!-- Render each asset with a template -->+ <template>+ <div class="or-FormListItem layout horizontal center justified">+ <div>Residence: {{asset.name}}</div>+ <div>Parent: {{asset.parentName}}</div>+ <div>Created On: {{asset.createdOn}}</div>+ </div>+ </template>++ </or-asset-list>++ <!-- Execute an asset query and show a nice scrollable list -->+ <or-asset-list class="myAssetList flex or-MainContent or-FormList"+ select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"+ asset-type="urn:openremote:asset:room">++ <!-- Render each asset with a template -->+ <template>+ <div class="or-FormListItem layout horizontal center justified">+ <div>Room: {{asset.name}}</div>+ <div>Parent: {{asset.parentName}}</div>+ <div>Created On: {{asset.createdOn}}</div>+ </div>+ </template>++ </or-asset-list>++ </div>++ <!-- Flex and take as much horizontal space as possible, show scrollbars if content doesn't fit. -->+ <div class="flex or-MainContent scroll">++ <!-- TODO Work on this -->+ <h3 style="color: var(--theme-red);">Note: This is under development and incomplete!</h3>++ <!-- Execute AssetQuery and subscribe for attribute changes -->+ <or-asset type="room" id="blabla">++ <!-- Bind asset attributes to elements -->+ <p>+ Temperature of the room is: <span data-attribute="currentTemp"></span>+ </p>++ <form>+ Set desired temperature:+ <input data-attribute="setTemp" data-validate>+ <submit data-asset-action></submit>+ <!-- Defaults to 'update' as this is what restricted users can do -->+ </form>++ <!-- Show hide elements based on boolean asset attribute -->+ <p data-visible="humidityBool">+ Humidity too high!+ </p>+ <p data-attached="co2Bool">+ Too much CO2!+ </p>+ </or-asset>+ </div>++ </div>++ <div class="or-MainContent">+ <div class="layout horizontal or-FormGroup">+ <div class="or-FormField">++ <button class="or-FormControl or-FormButton or-PushButton"+ onclick="openremote.INSTANCE.toasts.showToast(+ new openremote.toast.Toast(+ openremote.toast.Toast.Type.SUCCESS,+ 'Welcome ' + openremote.INSTANCE.user + ', on ' + openremote.INSTANCE.tenantRealm + '. It is ' + new Date() + '.',+ 3000+ )+ )">Show a toast+ </button>++ <button class="or-FormControl or-FormButton or-PushButton"+ onclick="document.querySelectorAll('.myAssetList').forEach((assetList) => {assetList.executeQuery()})">+ Refresh asset lists+ </button>++ <button class="or-FormControl or-FormButtonDanger or-PushButton"+ onclick="document.querySelector('or-app').logout()">Logout+ </button>++ </div>+ </div>+ </div>++ </div>++</or-app>++</body>+</html>\ No newline at end of filediff --git a/deployment/manager/consoles/customerA/index.html b/deployment/manager/consoles/customerA/index.htmlindex 4a1edd630..de83de63d 100644--- a/deployment/manager/consoles/customerA/index.html+++ b/deployment/manager/consoles/customerA/index.html@@ -1,50 +1,22 @@<!doctype html><html><head>- <title>OpenRemote Console Application</title>+ <title>OpenRemote SmartHome Example</title>+ <!-- Some sensible meta tags --><meta http-equiv="content-type" content="text/html; charset=UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1, user-scalable=no">+ <meta name="apple-mobile-web-app-capable" content="yes">+ <meta name="mobile-web-app-capable" content="yes">++ <!-- The language of the SmartHome app -->+ <meta name="or-language" content="en"><!-- ############## Required: Load WebComponents polyfill and components ############### --><script src="/static/bower_components/webcomponentsjs/webcomponents-lite.js"></script>- <link rel="import" href="/static/src/or-app/or-app.html">- <link rel="import" href="/static/src/or-asset-list/or-asset-list.html">- <!-- Optional: You can import other OpenRemote modules here -->-- <!-- Optional: Load more application resources after authentication -->- <script>- window.addEventListener('AppReady', function (e) {- console.log("Loading customerA console app resources...");- let app = e.detail.app;-- // Load resources in parallel- Promise.all([- app.load.css("/static/3rdparty/mapbox-gl-js/0.42.2/mapbox-gl.css"),- app.load.js("/static/3rdparty/mapbox-gl-js/0.42.2/mapbox-gl.js"),-- app.load.js("/static/bower_components/chart.js/dist/Chart.js"),-- app.load.js("/static/3rdparty/sprintf/1.0.3/sprintf.min.js")- ]).then(() => {-- /*- // Load resources sequentially- app.load.js("/resource1")- .then(() => {- return app.load.js("/resource2")- })- .catch(e => {- app.set("error", e);- });- */-- }).catch(e => {- app.set("error", e);- });-- })- </script>+ <!-- Load the SmartHome app -->+ <link rel="import" href="/console/customerA/smart-home/smart-home-app.html"><style type="text/css">/* Recommended: Avoid flickering during loading/styling by hiding children of or-app */@@ -52,149 +24,29 @@visibility: hidden;}- /* Optional: Create some styles only for your app */- .myAppHeadline {- display: block;- text-decoration: none;- padding: 1em;- font-size: x-large;- background: var(--theme-lightgreen);- color: var(--theme-black);+ /* Styles for the SmartHome app */+ html {+ height: 100%;+ }++ body {+ min-height: 100%;+ background: var(--theme-mediumgrey);+ font-family: 'Open Sans', 'Roboto', Helvetica, Arial, Lucida, sans-serif;}</style></head>-<!-- Optional: You should use flexbox layout classes everywhere, starting with the body --><body class="layout vertical">-<!-- ############## Required: One <or-app> should wrap your frontend, you can enforce login/authentication ############## --><or-app login tenant-realm="customerA">- <!-- With or-Viewport you get OpenRemote default fonts -->- <div class="flex layout vertical or-Viewport">-- <!-- You can use your own styles or the OpenRemote styles and theme -->- <a href="#" class="myAppHeadline">- The OpenRemote console application of the <code>customerA</code> tenant- </a>-- <!-- This is a container element that has some padding and visual separation from other containers -->- <div class="or-MainContent">-- <h3 style="color: var(--theme-red);">Note: This is under development and incomplete.</h3>-- <p>- On your OpenRemote installation, edit the HTML content in- <code>deployment/manager/consoles/customerA/</code>.- </p>- <p>- You can duplicate the <code>customerA</code> directory to create new console applications for other- tenants/realms.- </p>- <p>- View the source in your web browser and follow the examples on this page to write your own OpenRemote- application, it's easy with <a href="https://www.webcomponents.org/">Web Components</a>.- </p>- </div>-- <!-- Switch to horizontal layout but flex vertical first and take as much vertical space as needed -->- <div class="flex layout horizontal">-- <!-- Flex and take as much horizontal space as possible -->- <div class="flex layout vertical">-- <!-- Execute an asset query and show a nice scrollable list -->- <or-asset-list class="myAssetList flex or-MainContent or-FormList"- select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"- asset-type="urn:openremote:asset:residence">-- <!-- Render each asset with a template -->- <template>- <div class="or-FormListItem layout horizontal center justified">- <div>Residence: {{asset.name}}</div>- <div>Parent: {{asset.parentName}}</div>- <div>Created On: {{asset.createdOn}}</div>- </div>- </template>-- </or-asset-list>-- <!-- Execute an asset query and show a nice scrollable list -->- <or-asset-list class="myAssetList flex or-MainContent or-FormList"- select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"- asset-type="urn:openremote:asset:room">-- <!-- Render each asset with a template -->- <template>- <div class="or-FormListItem layout horizontal center justified">- <div>Room: {{asset.name}}</div>- <div>Parent: {{asset.parentName}}</div>- <div>Created On: {{asset.createdOn}}</div>- </div>- </template>-- </or-asset-list>-- </div>-- <!-- Flex and take as much horizontal space as possible, show scrollbars if content doesn't fit. -->- <div class="flex or-MainContent scroll">- <!-- Execute AssetQuery and subscribe for attribute changes -->- <or-asset type="room" id="blabla">-- <!-- Bind asset attributes to elements -->- <p>- Temperature of the room is: <span data-attribute="currentTemp"></span>- </p>-- <form>- Set desired temperature:- <input data-attribute="setTemp" data-validate>- <submit data-asset-action></submit>- <!-- Defaults to 'update' as this is what restricted users can do -->- </form>-- <!-- Show hide elements based on boolean asset attribute -->- <p data-visible="humidityBool">- Humidity too high!- </p>- <p data-attached="co2Bool">- Too much CO2!- </p>- </or-asset>- </div>-- </div>-- <div class="or-MainContent">- <div class="layout horizontal or-FormGroup">- <div class="or-FormField">-- <button class="or-FormControl or-FormButton or-PushButton"- onclick="openremote.INSTANCE.toasts.showToast(- new openremote.toast.Toast(- openremote.toast.Toast.Type.SUCCESS,- 'Welcome ' + openremote.INSTANCE.user + ', on ' + openremote.INSTANCE.tenantRealm + '. It is ' + new Date() + '.',- 3000- )- )">Show a toast- </button>-- <button class="or-FormControl or-FormButton or-PushButton"- onclick="document.querySelectorAll('.myAssetList').forEach((assetList) => {assetList.executeQuery()})">- Refresh asset lists- </button>-- <button class="or-FormControl or-FormButtonDanger or-PushButton"- onclick="document.querySelector('or-app').logout()">Logout- </button>-- </div>- </div>- </div>-- </div>+ <smart-home-app>+ <!-- You can override the logo+ <img slot="logo" height="20" src="mylogo.png"/>+ -->+ </smart-home-app></or-app>diff --git a/deployment/manager/consoles/customerA/smart-home/img/co2.png b/deployment/manager/consoles/customerA/smart-home/img/co2.pngnew file mode 100644index 000000000..20f89dd60Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/co2.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/eye.png b/deployment/manager/consoles/customerA/smart-home/img/eye.pngnew file mode 100644index 000000000..228c524f4Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/eye.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/eye_large.png b/deployment/manager/consoles/customerA/smart-home/img/eye_large.pngnew file mode 100644index 000000000..9269aacd6Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/eye_large.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/eye_large_active.png b/deployment/manager/consoles/customerA/smart-home/img/eye_large_active.pngnew file mode 100644index 000000000..e7596d0d5Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/eye_large_active.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/home_large_energy.png b/deployment/manager/consoles/customerA/smart-home/img/home_large_energy.pngnew file mode 100644index 000000000..1d522e134Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/home_large_energy.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/home_on.png b/deployment/manager/consoles/customerA/smart-home/img/home_on.pngnew file mode 100644index 000000000..955131fcdBinary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/home_on.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/humidity.png b/deployment/manager/consoles/customerA/smart-home/img/humidity.pngnew file mode 100644index 000000000..f0304e259Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/humidity.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/star.png b/deployment/manager/consoles/customerA/smart-home/img/star.pngnew file mode 100644index 000000000..374592cd5Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/star.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/temperature.png b/deployment/manager/consoles/customerA/smart-home/img/temperature.pngnew file mode 100644index 000000000..7abb2b09aBinary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/temperature.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/img/ventilation.png b/deployment/manager/consoles/customerA/smart-home/img/ventilation.pngnew file mode 100644index 000000000..68f4b4539Binary files /dev/null and b/deployment/manager/consoles/customerA/smart-home/img/ventilation.png differdiff --git a/deployment/manager/consoles/customerA/smart-home/locales.json b/deployment/manager/consoles/customerA/smart-home/locales.jsonnew file mode 100644index 000000000..8badc0f4c--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/locales.json@@ -0,0 +1,45 @@+{+ "en": {+ },+ "nl": {+ "Scenes": "Home",+ "Energy": "Start",+ "Security": "Veilig",+ "Climate": "Klimaat",+ "Settings": "Settings",+ "Log out": "Log uit",+ "All Smart": "Alles Slim",+ "At Home": "Thuis",+ "Away": "Weg",+ "Evening": "Avond",+ "Night": "Nacht",+ "Smart Switch A": "Afwas",+ "Smart Switch B": "Was",+ "Smart Switch C": "Droger",+ "Now on": "Nu aan",+ "On at": "Aan om",+ "Ready at": "Klaar om",+ "tomorrow": "morgen",+ "Mode": "Mode",+ "Begin/end of cycle": "Begin/end of cycle",+ "Green": "Groen",+ "Usage today": "Huidig verbruik",+ "Zone & Battery": "Zon & Batterij",+ "Grid": "Netwerk",+ "Alarm": "Alarm",+ "Presence detected": "Activiteit",+ "No presence": "Geen Activiteit",+ "Kitchen": "Keuken",+ "Living Room": "Woonkamer",+ "Hallway": "Gang",+ "Bedroom": "Slaapkamer",+ "Bedroom 2": "Slaapkamer 2",+ "Bathroom": "Badkamer",+ "Ventilation": "Ventilatie",+ "Ventilation Mode": "Ventilation Mode",+ "Auto": "Auto",+ "Low": "Laag",+ "Medium": "Medium",+ "High": "Hoge"+ }+}diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-app.html b/deployment/manager/consoles/customerA/smart-home/smart-home-app.htmlnew file mode 100644index 000000000..32681b234--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-app.html@@ -0,0 +1,222 @@+<!-- The OpenRemote web components -->+<link rel="import" href="/static/src/or-app/or-app.html">++<!-- Dependencies of this app -->+<script src="/static/3rdparty/sprintf/1.0.3/sprintf.min.js"></script>+<script src="../bower_components/moment/moment.js"></script>++<link rel="import" href="../bower_components/app-route/app-location.html">++<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-header.html">+<link rel="import" href="smart-home-body.html">+<link rel="import" href="smart-home-scenes.html">+<link rel="import" href="smart-home-energy.html">+<link rel="import" href="smart-home-security.html">+<link rel="import" href="smart-home-climate.html">+<link rel="import" href="smart-home-settings.html">++<dom-module id="smart-home-app">+ <template>+ <style include="smart-home-style">+ </style>++ <app-location use-hash-as-path route="{{appLocation}}"></app-location>++ <smart-home-header active-nav="[[view]]" hide-nav$="[[isActiveView(view, 'settings')]]">++ <template is="dom-if" if="[[!isActiveView(view, 'settings')]]">+ <slot slot="leftItem"+ name="logo">+ <a href="https://www.openremote.com/"+ class="layout horizontal center"+ style=" text-decoration: none;">+ <svg style="pointer-events: none; display: block; width: 2em; height:2em; margin-right: 0.4em;"+ viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet">+ <path fill="#ffffff"+ d="M11.93,21.851c-5.551,0-10.066-4.515-10.066-10.065h2.108c0,4.388,3.57,7.958,7.958,7.958 c4.387,0,7.958-3.57,7.958-7.958c0-4.388-3.57-7.958-7.958-7.958V1.72c5.55,0,10.066,4.517,10.066,10.066 C21.996,17.336,17.48,21.851,11.93,21.851L11.93,21.851z"/>+ <path fill="#919194"+ d="M10.406,19.088c-1.95-0.406-3.626-1.549-4.717-3.215s-1.469-3.66-1.062-5.61 c0.407-1.951,1.55-3.626,3.217-4.718c1.667-1.092,3.659-1.469,5.61-1.062c4.027,0.84,6.62,4.799,5.779,8.825l-2.063-0.429 c0.603-2.889-1.257-5.73-4.147-6.333c-1.4-0.292-2.829-0.022-4.025,0.762C7.802,8.091,6.982,9.293,6.69,10.693 c-0.291,1.398-0.021,2.828,0.762,4.024c0.783,1.196,1.985,2.016,3.385,2.307L10.406,19.088L10.406,19.088z"/>+ <path fill="#cccccc"+ d="M11.936,16.622c-0.082,0-0.164-0.001-0.245-0.004c-1.29-0.065-2.478-0.628-3.346-1.585 c-0.868-0.958-1.31-2.195-1.246-3.487l2.104,0.105c-0.036,0.728,0.214,1.427,0.704,1.967c0.488,0.54,1.16,0.858,1.888,0.894 c0.725,0.033,1.426-0.213,1.966-0.703c0.541-0.489,0.858-1.159,0.895-1.887c0.075-1.503-1.088-2.787-2.591-2.862l0.105-2.104 c2.664,0.132,4.724,2.406,4.592,5.07c-0.064,1.291-0.628,2.478-1.585,3.345C14.28,16.183,13.137,16.622,11.936,16.622L11.936,16.622 z"/>+ </svg>+ <span style="color: var(--theme-white); font-size: 1.1em;">OpenRemote</span>+ </a>+ </slot>+ <a slot="rightItem"+ href="#settings"><span class="or-Icon fa fa-cog"></span></a>+ </template>++ <template is="dom-if" if="[[isActiveView(view, 'settings')]]">+ <a slot="leftItem"+ href="#scenes"><span class="or-Icon fa fa-arrow-left"></span>[[localize('Settings')]]</a>+ <div slot="rightItem"+ on-click="logout"><span class="or-Icon fa fa-sign-out"></span>[[localize('Log out')]]+ </div>+ </template>++ </smart-home-header>++ <smart-home-body>++ <smart-home-scenes hidden$="[[!isActiveView(view, 'scenes')]]"+ residence="[[residence]]"></smart-home-scenes>++ <smart-home-energy hidden$="[[!isActiveView(view, 'energy')]]"+ residence="[[residence]]"+ rooms="[[rooms]]"></smart-home-energy>++ <smart-home-security hidden$="[[!isActiveView(view, 'security')]]"+ residence="[[residence]]"+ rooms="[[rooms]]"></smart-home-security>++ <smart-home-climate hidden$="[[!isActiveView(view, 'climate')]]"+ residence="[[residence]]"+ rooms="[[rooms]]"></smart-home-climate>++ <smart-home-settings hidden$="[[!isActiveView(view, 'settings')]]"+ residence="[[residence]]"></smart-home-settings>++ </smart-home-body>+ </template>++ <script>+ class SmartHomeApp extends SmartHomeComponent {+ static get is() {+ return "smart-home-app";+ }++ static get properties() {+ return {+ appLocation: {+ type: Object,+ observer: "onAppLocationChange"+ },+ /**+ * The name of the active view (#view hash in window location).+ */+ view: {+ type: String+ },+ /**+ * The name of the active sub-view (#view:subView hash in window location).+ */+ subView: {+ type: String+ },+ /**+ * The residence asset of the current user.+ */+ residence: {+ type: Object+ },+ /**+ * The room assets of the current user.+ */+ rooms: {+ type: Array,+ value: []+ }+ }+ }++ ready() {+ super.ready();++ this.shadowRoot.host.classList.add("flex", "layout", "vertical");++ console.log("Ready, initialising application state");+ openremote.INSTANCE.requests.sendAndReturn(+ (requestParams) => {+ let query = {+ select: {include: "ALL"},+ userId: openremote.INSTANCE.getSecurity().getUserId()+ }+ openremote.REST.AssetResource.queryAssets(requestParams, query);+ },+ 200,+ (response) => {+ if (!response) {+ openremote.INSTANCE.set("error", "No assets assigned to user.");+ return;+ }+ response.forEach(asset => {+ // Take the first residence asset+ if (asset.type === "urn:openremote:asset:residence" && !this.residence) {+ this.set("residence", asset);+ }+ // And any room assets+ if (asset.type === "urn:openremote:asset:room") {+ this.push("rooms", asset);+ this.notifyPath("rooms");+ }+ })+ if (!this.residence) {+ openremote.INSTANCE.set("error", "No residence asset found for user.");+ }++ // Subscribe to attribute events on residence and all rooms+ openremote.INSTANCE.getServiceEvents().addEventListener("attribute", e => {+ this.onServiceAttributeEvent(e.detail);+ });+ let subscribedAssetIds = [this.residence.id];+ this.rooms.forEach(room => {+ subscribedAssetIds.push(room.id);+ })+ openremote.INSTANCE.getServiceEvents().subscribeAttributeEvents(subscribedAssetIds);+ }+ );+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ onAppLocationChange(appLocation) {+ // TODO The "state" case is a bug in Keycloak 2.x with Firefox that's difficult to track down+ if (!appLocation.path || appLocation.path.startsWith('state')) {+ window.location.hash = "#scenes" // Default page+ } else {+ let views = appLocation.path.split(":");+ this.set("view", views.length >= 1 ? views[0] : undefined);+ this.set("subView", views.length >= 2 ? views[1] : undefined);+ }+ }++ isActiveView(activeView, view) {+ return activeView === view;+ }++ onServiceAttributeEvent(e) {+ // Use attribute event to update residence or room asset attribute value/valueTimestamp+ if (!e.attributeState)+ return+ let assetId = e.attributeState.attributeRef.entityId;+ let attributeName = e.attributeState.attributeRef.attributeName;++ // Update residence+ if (assetId === this.residence.id && attributeName in this.residence.attributes) {+ this.set("residence.attributes." + attributeName + ".value", e.attributeState.value);+ this.set("residence.attributes." + attributeName + ".valueTimestamp", e.timestamp);+ }++ // Update rooms+ this.rooms.forEach(room => {+ if (assetId === room.id && attributeName in room.attributes) {+ this.set("rooms." + this.rooms.indexOf(room) + ".attributes." + attributeName + ".value", e.attributeState.value);+ this.set("rooms." + this.rooms.indexOf(room) + ".attributes." + attributeName + ".valueTimestamp", e.timestamp);+ }+ });+ }++ logout() {+ openremote.INSTANCE.logout();+ }+ }++ defineAppElement(SmartHomeApp, SmartHomeApp.is, "SmartHomeApp");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-body.html b/deployment/manager/consoles/customerA/smart-home/smart-home-body.htmlnew file mode 100644index 000000000..b870a4e99--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-body.html@@ -0,0 +1,36 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">++<dom-module id="smart-home-body">+ <template>+ <style include="smart-home-style">+ :host {+ margin-bottom: 10px;+ }+ </style>++ <slot></slot>++ </template>++ <script>+ class SmartHomeBody extends SmartHomeComponent {+ static get is() {+ return "smart-home-body";+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical", "scroll");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }+ }++ defineAppElement(SmartHomeBody, SmartHomeBody.is, "SmartHomeBody");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-climate.html b/deployment/manager/consoles/customerA/smart-home/smart-home-climate.htmlnew file mode 100644index 000000000..db3115990--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-climate.html@@ -0,0 +1,363 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-section.html">+<link rel="import" href="smart-home-smart.html">++<dom-module id="smart-home-climate">+ <template>+ <style include="smart-home-style">++ .roomLabel {+ padding: 0 10px;+ }++ .roomItem,+ .ventilationItem {+ margin: 10px 0;+ }++ .ventilationLabel {+ margin: 0 10px;+ }++ .attributeValue {+ margin-left: 20px;+ font-size: 1.2em;+ line-height: 1;+ white-space: nowrap;+ }+ </style>++ <smart-home-smart residence="[[residence]]"></smart-home-smart>++ <smart-home-section>+ <template is="dom-repeat" items="[[roomsTemperature]]">+ <div class="layout horizontal center roomItem">+ <div class="layout vertical center-center">+ <img height="30" src="smart-home/img/temperature.png"/>+ </div>+ <div class="flex layout horizontal center roomLabel">+ [[localize(item.roomName)]]+ </div>+ <template is="dom-if" if="[[item.targetTemperature]]">+ <div class="targetTemperature">+ <div class="or-Select">+ <select value="{{item.targetTemperature::change}}"+ on-change="onTargetTemperatureChange"+ title="Target Temperature">+ <!-- TODO dom-repeat here is tricky, no matter where the items are computed, it's not working -->+ <option value="11">[[formatAttributeValue(item.targetTemperatureFormat,11.0)]]+ </option>+ <option value="11.5">[[formatAttributeValue(item.targetTemperatureFormat,11.5)]]+ </option>+ <option value="12">[[formatAttributeValue(item.targetTemperatureFormat,12.0)]]+ </option>+ <option value="12.5">[[formatAttributeValue(item.targetTemperatureFormat,12.5)]]+ </option>+ <option value="13">[[formatAttributeValue(item.targetTemperatureFormat,13.0)]]+ </option>+ <option value="13.5">[[formatAttributeValue(item.targetTemperatureFormat,13.5)]]+ </option>+ <option value="14">[[formatAttributeValue(item.targetTemperatureFormat,14.0)]]+ </option>+ <option value="14.5">[[formatAttributeValue(item.targetTemperatureFormat,14.5)]]+ </option>+ <option value="15">[[formatAttributeValue(item.targetTemperatureFormat,15.0)]]+ </option>+ <option value="15.5">[[formatAttributeValue(item.targetTemperatureFormat,15.5)]]+ </option>+ <option value="16">[[formatAttributeValue(item.targetTemperatureFormat,16.0)]]+ </option>+ <option value="16.5">[[formatAttributeValue(item.targetTemperatureFormat,16.5)]]+ </option>+ <option value="17">[[formatAttributeValue(item.targetTemperatureFormat,17.0)]]+ </option>+ <option value="17.5">[[formatAttributeValue(item.targetTemperatureFormat,17.5)]]+ </option>+ <option value="18">[[formatAttributeValue(item.targetTemperatureFormat,18.0)]]+ </option>+ <option value="18.5">[[formatAttributeValue(item.targetTemperatureFormat,18.5)]]+ </option>+ <option value="19">[[formatAttributeValue(item.targetTemperatureFormat,19.0)]]+ </option>+ <option value="19.5">[[formatAttributeValue(item.targetTemperatureFormat,19.5)]]+ </option>+ <option value="20">[[formatAttributeValue(item.targetTemperatureFormat,20.0)]]+ </option>+ <option value="20.5">[[formatAttributeValue(item.targetTemperatureFormat,20.5)]]+ </option>+ <option value="21">[[formatAttributeValue(item.targetTemperatureFormat,21.0)]]+ </option>+ <option value="21.5">[[formatAttributeValue(item.targetTemperatureFormat,21.5)]]+ </option>+ <option value="22">[[formatAttributeValue(item.targetTemperatureFormat,22.0)]]+ </option>+ <option value="22.5">[[formatAttributeValue(item.targetTemperatureFormat,22.5)]]+ </option>+ <option value="23">[[formatAttributeValue(item.targetTemperatureFormat,23.0)]]+ </option>+ <option value="23.5">[[formatAttributeValue(item.targetTemperatureFormat,23.5)]]+ </option>+ <option value="24">[[formatAttributeValue(item.targetTemperatureFormat,24.0)]]+ </option>+ <option value="24.5">[[formatAttributeValue(item.targetTemperatureFormat,24.5)]]+ </option>+ <option value="25">[[formatAttributeValue(item.targetTemperatureFormat,25.0)]]+ </option>+ <option value="25.5">[[formatAttributeValue(item.targetTemperatureFormat,25.5)]]+ </option>+ <option value="26">[[formatAttributeValue(item.targetTemperatureFormat,26.0)]]+ </option>+ <option value="26.5">[[formatAttributeValue(item.targetTemperatureFormat,26.5)]]+ </option>+ <option value="27">[[formatAttributeValue(item.targetTemperatureFormat,27.0)]]+ </option>+ <option value="27.5">[[formatAttributeValue(item.targetTemperatureFormat,27.5)]]+ </option>+ <option value="28">[[formatAttributeValue(item.targetTemperatureFormat,28.0)]]+ </option>+ <option value="28.5">[[formatAttributeValue(item.targetTemperatureFormat,28.5)]]+ </option>+ <option value="29">[[formatAttributeValue(item.targetTemperatureFormat,29.0)]]+ </option>+ <option value="29.5">[[formatAttributeValue(item.targetTemperatureFormat,29.5)]]+ </option>+ <option value="30">[[formatAttributeValue(item.targetTemperatureFormat,30.0)]]+ </option>+ <option value="30.5">[[formatAttributeValue(item.targetTemperatureFormat,30.5)]]+ </option>+ <option value="31">[[formatAttributeValue(item.targetTemperatureFormat,31.0)]]+ </option>+ </select>+ </div>+ </div>+ </template>+ <div class="attributeValue">+ [[formatAttributeValue(item.currentTemperatureFormat, item.currentTemperature)]]+ </div>+ </div>+ </template>+ </smart-home-section>++ <smart-home-section>+ <template is="dom-repeat" items="[[roomsCO2]]">+ <div class="layout horizontal center roomItem">+ <div class="layout vertical center-center">+ <img height="30" src="smart-home/img/co2.png"/>+ </div>+ <div class="flex layout horizontal center roomLabel">+ [[localize(item.roomName)]]+ </div>+ <div class="attributeValue">+ [[formatAttributeValue(item.co2LevelFormat, item.co2Level)]]+ </div>+ </div>+ </template>+ </smart-home-section>++ <smart-home-section>+ <template is="dom-repeat" items="[[roomsHumidity]]">+ <div class="layout horizontal center roomItem">+ <div class="layout vertical center-center">+ <img height="30" src="smart-home/img/humidity.png"/>+ </div>+ <div class="flex layout horizontal center roomLabel">+ [[localize(item.roomName)]]+ </div>+ <div class="attributeValue">+ [[formatAttributeValue(item.humidityFormat, item.humidity)]]+ </div>+ </div>+ </template>+ </smart-home-section>++ <template is="dom-if" if="[[ventilationMode]]">+ <smart-home-section>+ <div class="layout horizontal center ventilationItem">+ <div class="layout vertical center-center">+ <img height="30" src="smart-home/img/ventilation.png"/>+ </div>+ <div class="flex layout horizontal ventilationLabel">+ [[localize('Ventilation')]]+ </div>+ <div class="ventilationMode">+ <div class="or-Select">+ <select value="{{ventilationMode::change}}"+ title="[[localize('Ventilation Mode')]]">+ <option value="AUTO">[[localize('Auto')]]</option>+ <option value="LOW">[[localize('Low')]]</option>+ <option value="MEDIUM">[[localize('Medium')]]</option>+ <option value="HIGH">[[localize('High')]]</option>+ </select>+ </div>+ </div>+ </div>+ </smart-home-section>+ </template>++ </template>++ <script>+ class SmartHomeClimate extends SmartHomeComponent {+ static get is() {+ return "smart-home-climate";+ }++ static get properties() {+ return {+ roomsTemperature: {+ type: Array,+ computed: "computeRoomsTemperature(rooms.*)"+ },+ roomsCO2: {+ type: Array,+ computed: "computeRoomsCO2(rooms.*)"+ },+ roomsHumidity: {+ type: Array,+ computed: "computeRoomsHumidity(rooms.*)"+ },+ ventilationMode: {+ type: String,+ observer: "onVentilationModeChange"+ }+ }+ }++ static get observers() {+ return [+ "onResidenceChange(residence.*)"+ ]+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ computeRoomsTemperature(targetTemperateOptions) {+ let roomsTemperature = [];+ if (!this.rooms)+ return roomsTemperature;+ this.rooms.forEach(room => {+ if ("currentTemperature" in room.attributes || "targetTemperature" in room.attributes) {+ roomsTemperature.push({+ roomId: room.id,+ roomName: room.name,+ currentTemperature: room.attributes.currentTemperature ? room.attributes.currentTemperature.value : null,+ currentTemperatureFormat: room.attributes.currentTemperature.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0],+ targetTemperature: room.attributes.targetTemperature ? room.attributes.targetTemperature.value : null,+ targetTemperatureFormat: room.attributes.targetTemperature ? room.attributes.targetTemperature.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0] : null,+ });+ }+ })+ return roomsTemperature;+ }++ computeRoomsCO2() {+ let roomsCO2 = [];+ if (!this.rooms)+ return roomsCO2;+ this.rooms.forEach(room => {+ if ("co2Level" in room.attributes) {+ roomsCO2.push({+ roomId: room.id,+ roomName: room.name,+ co2Level: room.attributes.co2Level.value,+ co2LevelFormat: room.attributes.co2Level.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0],+ });+ }+ })+ return roomsCO2;+ }++ computeRoomsHumidity() {+ let roomsHumidity = [];+ if (!this.rooms)+ return roomsHumidity;+ this.rooms.forEach(room => {+ if ("humidity" in room.attributes) {+ roomsHumidity.push({+ roomId: room.id,+ roomName: room.name,+ humidity: room.attributes.humidity.value,+ humidityFormat: room.attributes.humidity.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0],+ });+ }+ })+ return roomsHumidity;+ }++ formatAttributeValue(formatString, value) {+ return value ? sprintf(formatString, value) : "-";+ }++ onResidenceChange(changeRecord) {+ let ventilationMode = null;+ if ("ventilationAuto" in this.residence.attributes && this.residence.attributes.ventilationAuto.value) {+ ventilationMode = "AUTO";+ } else if ("ventilationLevel" in this.residence.attributes) {+ if (!this.residence.attributes.ventilationLevel.value) {+ ventilationMode = "LOW";+ } else if (this.residence.attributes.ventilationLevel.value <= 64) {+ ventilationMode = "LOW";+ } else if (this.residence.attributes.ventilationLevel.value <= 128) {+ ventilationMode = "MEDIUM";+ } else if (this.residence.attributes.ventilationLevel.value <= 255) {+ ventilationMode = "HIGH";+ }+ }+ this.set("ventilationMode", ventilationMode);+ }++ onTargetTemperatureChange(e) {+ // Must use async operation as roomTemperature.targetTemperature will only be set after this listener returns+ setTimeout(() => {+ let roomTemperature = e.model.item;+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ roomTemperature.roomId, "targetTemperature", parseInt(roomTemperature.targetTemperature)+ );+ }, 1);+ }++ onVentilationModeChange() {+ if (this.ventilationMode === "AUTO") {+ if (!this.residence.attributes.ventilationAuto.value) {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, "ventilationAuto", true+ );+ }+ return;+ }+ let ventilationLevel = null;+ if (this.ventilationMode === "LOW") {+ ventilationLevel = 64;+ } else if (this.ventilationMode === "MEDIUM") {+ ventilationLevel = 128;+ } else if (this.ventilationMode === "HIGH") {+ ventilationLevel = 255;+ }++ if (this.residence.attributes.ventilationAuto.value) {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, "ventilationAuto", false+ );+ }++ if (this.residence.attributes.ventilationLevel.value !== ventilationLevel) {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, "ventilationLevel", ventilationLevel+ );+ }+ }+ }++ defineAppElement(SmartHomeClimate, SmartHomeClimate.is, "SmartHomeClimate");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-component.html b/deployment/manager/consoles/customerA/smart-home/smart-home-component.htmlnew file mode 100644index 000000000..de255ce35--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-component.html@@ -0,0 +1,14 @@+<dom-module id="smart-home-component">+ <script>+ class SmartHomeComponent extends OpenRemoteViewComponent {+ static get properties() {+ return {+ localesResource: {+ type: String,+ value: "locales.json"+ }+ }+ }+ }+ </script>+</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-energy.html b/deployment/manager/consoles/customerA/smart-home/smart-home-energy.htmlnew file mode 100644index 000000000..46557595b--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-energy.html@@ -0,0 +1,247 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-section.html">+<link rel="import" href="smart-home-smart.html">++<dom-module id="smart-home-energy">+ <template>+ <style include="smart-home-style">++ .smartSwitchItem {+ margin: 10px 0;+ }++ .smartSwitchLabel {+ padding: 0 10px;+ }++ .smartSwitchMode {+ }++ .smartSwitchTomorrow {+ padding-left: 5px;+ font-size: 0.7em;+ }++ .smartSwitchTimeInput {+ margin-left: 5px;+ }++ </style>++ <smart-home-smart residence="[[residence]]"></smart-home-smart>++ <smart-home-section>+ <template is="dom-repeat" items="[[smartSwitches]]">+ <div class="layout horizontal center smartSwitchItem">+ <div><img height="30" src="smart-home/img/home_on.png"/></div>+ <div class="flex layout horizontal smartSwitchLabel">+ [[item.label]]+ </div>+ <div class="layout horizontal smartSwitchMode">+ <div class="or-Select">+ <select value="{{item.mode::change}}"+ on-change="onSmartSwitchModeChange"+ title="[[localize('Mode')]]">+ <option value="NOW_ON">[[localize('Now on')]]</option>+ <option value="ON_AT">[[localize('On at')]]</option>+ <option value="READY_AT">[[localize('Ready at')]]</option>+ </select>+ </div>+ </div>+ <template is="dom-if" if="[[item.hourMinuteVisible]]">+ <div class="layout horizontal center">+ <template is="dom-if" if="[[item.hourMinuteTomorrow]]">+ <div class="smartSwitchTomorrow">([[localize('tomorrow')]])</div>+ </template>+ <input class="or-Input or-InputTime smartSwitchTimeInput"+ title="[[localize('Begin/end of cycle')]]"+ type="time"+ step="60"+ required+ value="{{item.hourMinute::input}}"+ on-input="onSmartSwitchHourMinuteChange"/>+ </div>+ </template>+ </div>+ </template>+ </smart-home-section>++ <!-- TODO This section is not functional, not bound to any assets -->+ <smart-home-section>+ <div class="layout horizontal center">+ <div class="flex" style="position: relative; padding-left: 10px;">+ <div style="position: absolute;">+ <div style="position: relative; left: 40px; top: 65px;">12%</div>+ <div style="position: relative; top: 65px; left: 41px; font-size: x-small;">[[localize('Green')]]</div>+ </div>+ <img width="110" height="110" src="smart-home/img/home_large_energy.png"/>+ </div>+ <div class="layout vertical" style="font-size: smaller; margin-right: 5px;">++ <div class="layout horizontal" style="margin: 5px 0;">+ <div class="flex" style="padding-right: 20px;">[[localize('Usage today')]]</div>+ <div>418W</div>+ </div>++ <div class="layout horizontal" style="margin: 5px 0; color: var(--theme-mediumgrey)">+ <div class="flex">[[localize('Zone & Battery')]]</div>+ <div>9%</div>+ </div>++ <div style="margin-bottom:5px;width:87%;height:10px; background-color: var(--theme-lightgreen);"></div>+ <div class="" style="width:17%;height:10px; background-color: var(--theme-mediumgrey)"></div>++ <div class="layout horizontal" style="margin: 5px 0; color: var(--theme-mediumgrey)">+ <div class="flex">[[localize('Grid')]]</div>+ <div>91%</div>+ </div>+ </div>+ </div>+ </smart-home-section>++ </template>++ <script>+ class SmartHomeEnergy extends SmartHomeComponent {+ static get is() {+ return "smart-home-energy";+ }++ static get properties() {+ return {+ smartSwitches: {+ type: Array,+ computed: "computeSmartSwitches(rooms.*)"+ },+ smartSwitchHourMinuteChangeDebouncer: {+ type: Object,+ value: {}+ }+ }+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ computeSmartSwitches(rooms) {+ let smartSwitches = [];+ if (!this.rooms)+ return smartSwitches;+ this.rooms.forEach(room => {+ if ("smartSwitchModeA" in room.attributes && "smartSwitchBeginEndA" in room.attributes) {+ smartSwitches.push(+ this.computeSmartSwitch(room.id, this.localize("Smart Switch A"), "A", room.attributes.smartSwitchModeA.value, room.attributes.smartSwitchBeginEndA.value)+ );+ }+ if ("smartSwitchModeB" in room.attributes && "smartSwitchBeginEndB" in room.attributes) {+ smartSwitches.push(+ this.computeSmartSwitch(room.id, this.localize("Smart Switch B"), "B", room.attributes.smartSwitchModeB.value, room.attributes.smartSwitchBeginEndB.value)+ );+ }+ if ("smartSwitchModeC" in room.attributes && "smartSwitchBeginEndC" in room.attributes) {+ smartSwitches.push(+ this.computeSmartSwitch(room.id, this.localize("Smart Switch C"), "C", room.attributes.smartSwitchModeC.value, room.attributes.smartSwitchBeginEndC.value)+ );+ }+ })+ return smartSwitches;+ }++ computeSmartSwitch(roomId, label, attributeSuffix, mode, beginEnd) {+ return {+ roomId: roomId,+ label: label,+ suffix: attributeSuffix,+ mode: mode ? mode : "NOW_ON", // Default to NOW_ON when mode is empty+ hourMinute: beginEnd ? moment(beginEnd).format("HH:mm") : null,+ hourMinuteVisible: mode && (mode === "ON_AT" || mode === "READY_AT"),+ hourMinuteTomorrow: beginEnd ? moment(beginEnd).isAfter(moment(), "day") : false,+ }+ }++ onSmartSwitchModeChange(e) {+ // Must use async operation as smartSwitch.mode will only be set after this listener returns+ setTimeout(() => {+ let smartSwitch = e.model.item;++ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ smartSwitch.roomId, "smartSwitchMode" + smartSwitch.suffix, smartSwitch.mode+ );++ let beginEndTimestamp = this.computeSmartSwitchBeginEndTimestamp(smartSwitch.mode, smartSwitch.hourMinute);+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ smartSwitch.roomId, "smartSwitchBeginEnd" + smartSwitch.suffix, beginEndTimestamp+ );+ }, 1);+ }++ onSmartSwitchHourMinuteChange(e) {+ // Must use async operation as smartSwitch.hourMinute will only be set after this listener returns+ setTimeout(() => {+ let smartSwitch = e.model.item;++ // If entered time is empty, switch to now on+ if (!smartSwitch.hourMinute) {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ smartSwitch.roomId, "smartSwitchMode" + smartSwitch.suffix, "NOW_ON"+ );+ return;+ }++ let beginEndTimestamp = this.computeSmartSwitchBeginEndTimestamp(smartSwitch.mode, smartSwitch.hourMinute);++ // Delay/debounce sending the change to service, the user is probably still editing+ // the hour/minute (cursor keys, spinner button)+ this.smartSwitchHourMinuteChangeDebouncer[smartSwitch] = Polymer.Debouncer.debounce(+ this.smartSwitchHourMinuteChangeDebouncer[smartSwitch],+ Polymer.Async.timeOut.after(3000),+ () => {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ smartSwitch.roomId, "smartSwitchBeginEnd" + smartSwitch.suffix, beginEndTimestamp+ );+ });+ }, 1);+ }++ computeSmartSwitchBeginEndTimestamp(mode, hourMinute) {+ // Get the moment of the user-supplied hour/minute or current time +2m+ let hourMinuteMoment = hourMinute ? moment(hourMinute, "HH:mm") : moment().add(2, "minutes");++ // Try to correct hour/minute depending on selected mode+ if (!mode || mode === "NOW_ON") {++ // No mode or now on, empty begin/end timestamp+ hourMinuteMoment = null;++ } else if (mode === "ON_AT") {++ // If it's not one minute in the future (time it takes to process event on server), add one day+ if (hourMinuteMoment.isBefore(moment().add(1, "minutes"))) {+ hourMinuteMoment = hourMinuteMoment.add(1, "days");+ }++ } else if (mode === "READY_AT") {++ // If cycle can't finish in the next (2.5h cycle duration, +1m for event processing), add one day+ if (hourMinuteMoment.isBefore(moment().add(151, "minutes"))) {+ hourMinuteMoment = hourMinuteMoment.add(1, "days");+ }+ }++ return hourMinuteMoment ? parseInt(hourMinuteMoment.format("x")) : null;+ }++ }++ defineAppElement(SmartHomeEnergy, SmartHomeEnergy.is, "SmartHomeEnergy");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-header.html b/deployment/manager/consoles/customerA/smart-home/smart-home-header.htmlnew file mode 100644index 000000000..dc2528077--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-header.html@@ -0,0 +1,107 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">++<dom-module id="smart-home-header">+ <template>+ <style include="smart-home-style">++ .header {+ background-color: var(--theme-darkgrey);+ padding: 7px 15px;+ min-height: 34px;+ }++ .headerItem ::slotted(*) {+ color: var(--theme-white);+ text-decoration: none;+ font-size: 20px;+ cursor: pointer;+ }++ .nav {+ background-color: var(--theme-white);+ }++ .navItem {+ color: var(--theme-mediumgrey);+ text-align: center;+ padding: 10px;+ cursor: pointer;+ text-decoration: none;+ border-top: 3px solid transparent;+ border-bottom: 3px solid transparent;+ }++ .navItem.active {+ color: var(--theme-black);+ border-bottom: 3px solid var(--theme-lightgreen);+ font-weight: 600;+ }++ </style>++ <div class="flex-none layout horizontal center header">+ <div class="flex layout horizontal center">++ <div class="flex layout horizontal headerItem">+ <slot name="leftItem"></slot>+ </div>++ <div class="layout horizontal headerItem">+ <slot name="rightItem"></slot>+ </div>++ </div>+ </div>++ <template is="dom-if" if="[[!hideNav]]">+ <div class="flex-none layout horizontal nav">+ <a href="#scenes" class$="[[getNavItemClass(activeNav, 'scenes')]]">{{localize('Home')}}</a>+ <a href="#energy" class$="[[getNavItemClass(activeNav, 'energy')]]">{{localize('Energy')}}</a>+ <a href="#security" class$="[[getNavItemClass(activeNav, 'security')]]">{{localize('Security')}}</a>+ <a href="#climate" class$="[[getNavItemClass(activeNav, 'climate')]]">{{localize('Climate')}}</a>+ </div>+ </template>++ </template>++ <script>+ class SmartHomeHeader extends SmartHomeComponent {+ static get is() {+ return "smart-home-header";+ }++ static get properties() {+ return {+ hideNav: {+ type: Boolean,+ value: false+ },+ activeNav: {+ type: String+ },+ }+ }++ ready() {+ super.ready();++ this.shadowRoot.host.classList.add("flex-none", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ getNavItemClass(active, item) {+ return active === item+ ? "flex layout horizontal center-center navItem active"+ : "flex layout horizontal center-center navItem";+ }+ }++ defineAppElement(SmartHomeHeader, SmartHomeHeader.is, "SmartHomeHeader");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-scenes.html b/deployment/manager/consoles/customerA/smart-home/smart-home-scenes.htmlnew file mode 100644index 000000000..54fca677c--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-scenes.html@@ -0,0 +1,96 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-section.html">+<link rel="import" href="smart-home-smart.html">++<dom-module id="smart-home-scenes">+ <template>+ <style include="smart-home-style">++ .sceneItem {+ font-weight: 600;+ width: 100px;+ height: 100px;+ margin: 10px;+ cursor: pointer;+ -webkit-user-select: none;+ -moz-user-select: none;+ -ms-user-select: none;+ user-select: none;+ box-sizing: border-box;+ -moz-box-sizing: border-box;+ -webkit-box-sizing: border-box;+ background-color: var(--theme-darkgrey);+ color: var(--theme-white);+ }++ .sceneItem.selected {+ background-color: var(--theme-lightergrey);+ color: var(--theme-mediumgrey);+ }++ .sceneItem.active {+ background-color: var(--theme-lightgreen);+ color: var(--theme-black);+ }++ </style>++ <smart-home-smart residence="[[residence]]"></smart-home-smart>++ <smart-home-section>+ <div class="layout horizontal center-center">+ <div id="HOME"+ class$="[[getItemClass(residence.attributes.lastExecutedScene.value, 'HOME')]]"+ on-click="switchScene">{{localize('At Home')}}</div>+ <div id="AWAY"+ class$="[[getItemClass(residence.attributes.lastExecutedScene.value, 'AWAY')]]"+ on-click="switchScene">{{localize('Away')}}</div>+ </div>+ <div class="layout horizontal center-center">+ <div id="EVENING"+ class$="[[getItemClass(residence.attributes.lastExecutedScene.value, 'EVENING')]]"+ on-click="switchScene">{{localize('Evening')}}</div>+ <div id="NIGHT"+ class$="[[getItemClass(residence.attributes.lastExecutedScene.value, 'NIGHT')]]"+ on-click="switchScene">{{localize('Night')}}</div>+ </div>+ </smart-home-section>++ </template>++ <script>+ class SmartHomeScenes extends SmartHomeComponent {+ static get is() {+ return "smart-home-scenes";+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ getItemClass(scene, item) {+ return scene === item+ ? "layout horizontal center-center sceneItem active"+ : "layout horizontal center-center sceneItem";+ }++ switchScene(e) {+ let sceneItem = Polymer.dom(e).localTarget;+ sceneItem.classList.add("selected");+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, sceneItem.id.toLowerCase() + "Scene", "REQUEST_START"+ );+ }+ }++ defineAppElement(SmartHomeScenes, SmartHomeScenes.is, "SmartHomeScenes");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-section.html b/deployment/manager/consoles/customerA/smart-home/smart-home-section.htmlnew file mode 100644index 000000000..3f7ee6ef0--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-section.html@@ -0,0 +1,40 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">++<dom-module id="smart-home-section">+ <template>+ <style include="smart-home-style">+ :host {+ background-color: var(--theme-white);+ border-radius: 10px;+ margin: 10px 10px 0 10px;+ padding: 10px;+ -webkit-box-shadow: 4px 4px 15px 0px rgba(0,0,0,0.2);+ -moz-box-shadow: 4px 4px 15px 0px rgba(0,0,0,0.2);+ box-shadow: 4px 4px 15px 0px rgba(0,0,0,0.2);+ }+ </style>+ <slot></slot>+ </template>++ <script>+ class SmartHomeSection extends SmartHomeComponent {+ static get is() {+ return "smart-home-section";+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex-none", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }+ }++ defineAppElement(SmartHomeSection, SmartHomeSection.is, "SmartHomeSection");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-security.html b/deployment/manager/consoles/customerA/smart-home/smart-home-security.htmlnew file mode 100644index 000000000..ce2cbcc38--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-security.html@@ -0,0 +1,134 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-section.html">+<link rel="import" href="smart-home-smart.html">++<dom-module id="smart-home-security">+ <template>+ <style include="smart-home-style">++ .alarm {+ margin: 10px 0;+ }++ .residencePresenceStatus {+ padding: 10px 20px;+ }++ .roomLabel {+ padding: 0 10px;+ }++ .presenceStatus {+ color: var(--theme-mediumgrey);+ }++ .roomPresenceStatusItem {+ margin: 10px 0;+ }++ </style>++ <smart-home-smart residence="[[residence]]"></smart-home-smart>++ <smart-home-section>++ <div class="layout horizontal center alarm">+ <template is="dom-if" if="[[residence.attributes.presenceDetected.value]]">+ <img height="80" src="smart-home/img/eye_large_active.png"/>+ </template>+ <template is="dom-if" if="[[!residence.attributes.presenceDetected.value]]">+ <img height="80" src="smart-home/img/eye_large.png"/>+ </template>+ <div class="flex layout vertical residencePresenceStatus">+ <div>[[localize('Alarm')]]</div>+ <div class="presenceStatus">+ [[computePresenceStatus(residence.attributes.presenceDetected.value)]]+ </div>+ </div>+ <div class="layout horizontal">+ <input class="or-CheckBox"+ id="alarmEnabled"+ type="checkbox"+ on-change="onAlarmEnabledChange"+ checked="[[residence.attributes.alarmEnabled.value]]"/>+ <label for="alarmEnabled"></label>+ </div>+ </div>++ <div class="layout vertical">+ <template is="dom-repeat" items="[[roomsPresenceStatus]]">+ <div class="layout horizontal center roomPresenceStatusItem">+ <div class="layout vertical center-center">+ <img height="30" src="smart-home/img/eye.png"/>+ </div>+ <div class="flex layout horizontal roomLabel">+ [[localize(item.roomName)]]+ </div>+ <div class="presenceStatus">+ [[computePresenceStatus(item.presenceDetected)]]+ </div>+ </div>+ </template>+ </div>++ </smart-home-section>++ </template>++ <script>+ class SmartHomeSecurity extends SmartHomeComponent {+ static get is() {+ return "smart-home-security";+ }++ static get properties() {+ return {+ roomsPresenceStatus: {+ type: Array,+ computed: "computeRoomsPresenceStatus(rooms.*)"+ }+ }+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ onAlarmEnabledChange() {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, "alarmEnabled", this.$.alarmEnabled.checked+ );+ }++ computePresenceStatus(presenceDetected) {+ return presenceDetected === true ? this.localize("Presence detected") : this.localize("No presence");+ }++ computeRoomsPresenceStatus(rooms) {+ let roomsPresenceStatus = [];+ if (!this.rooms)+ return roomsPresenceStatus;+ this.rooms.forEach(room => {+ if ("presenceDetected" in room.attributes) {+ roomsPresenceStatus.push({+ roomId: room.id,+ roomName: room.name,+ presenceDetected: room.attributes.presenceDetected.value+ });+ }+ })+ return roomsPresenceStatus;+ }+ }++ defineAppElement(SmartHomeSecurity, SmartHomeSecurity.is, "SmartHomeSecurity");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-settings.html b/deployment/manager/consoles/customerA/smart-home/smart-home-settings.htmlnew file mode 100644index 000000000..64ca29f8c--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-settings.html@@ -0,0 +1,36 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-section.html">++<dom-module id="smart-home-settings">+ <template>+ <style include="smart-home-style">+ </style>++ <smart-home-section class="center-center">+ <div>[[residence.name]]</div>+ </smart-home-section>++ </template>++ <script>+ class SmartHomeSettings extends SmartHomeComponent {+ static get is() {+ return "smart-home-settings";+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }+ }++ defineAppElement(SmartHomeSettings, SmartHomeSettings.is, "SmartHomeSettings");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-smart.html b/deployment/manager/consoles/customerA/smart-home/smart-home-smart.htmlnew file mode 100644index 000000000..12b65242d--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-smart.html@@ -0,0 +1,63 @@+<link rel="import" href="smart-home-component.html">+<link rel="import" href="smart-home-style.html">+<link rel="import" href="smart-home-section.html">++<dom-module id="smart-home-smart">+ <template>+ <style include="smart-home-style">+ .smartLabel {+ margin: 0 10px;+ }+ </style>++ <smart-home-section>+ <div class="layout horizontal center">+ <img height="30" src="smart-home/img/star.png"/>+ <!-- "All Smart" currently means enabling/disabling automatic scene switching based on schedule -->+ <div class="flex layout horizontal smartLabel">[[localize('All Smart')]]</div>+ <div class="layout horizontal">+ <input class="or-CheckBox"+ id="smartToggle"+ type="checkbox"+ on-change="onSmartToggleChange"+ checked="[[residence.attributes.sceneTimerEnabled.value]]"/>+ <label for="smartToggle"></label>+ </div>+ </div>+ </smart-home-section>++ </template>++ <script>+ class SmartHomeSmart extends SmartHomeComponent {+ static get is() {+ return "smart-home-smart";+ }++ ready() {+ super.ready();+ this.shadowRoot.host.classList.add("flex-none", "layout", "vertical");+ }++ connectedCallback() {+ super.connectedCallback();+ this.showComponent();+ }++ onSmartToggleChange() {+ if (this.$.smartToggle.checked) {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, "enableSceneTimer", "REQUEST_START"+ );+ } else {+ openremote.INSTANCE.getServiceEvents().sendAttributeEvent(+ this.residence.id, "disableSceneTimer", "REQUEST_START"+ );+ }+ }+ }++ defineAppElement(SmartHomeSmart, SmartHomeSmart.is, "SmartHomeSmart");+ </script>++</dom-module>diff --git a/deployment/manager/consoles/customerA/smart-home/smart-home-style.html b/deployment/manager/consoles/customerA/smart-home/smart-home-style.htmlnew file mode 100644index 000000000..9f860fd2f--- /dev/null+++ b/deployment/manager/consoles/customerA/smart-home/smart-home-style.html@@ -0,0 +1,6 @@+<dom-module id="smart-home-style">+ <template>+ <style include="or-style">+ </style>+ </template>+</dom-module>\ No newline at end of filediff --git a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.javaindex a3e4d84fb..09822db20 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java@@ -37,11 +37,13 @@ import org.openremote.manager.rules.RulesService;import org.openremote.manager.security.ManagerIdentityService;import org.openremote.model.Constants;import org.openremote.model.ValidationFailure;-import org.openremote.model.asset.*;+import org.openremote.model.asset.Asset;+import org.openremote.model.asset.AssetAttribute;+import org.openremote.model.asset.AssetResource;+import org.openremote.model.asset.AssetType;import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.attribute.AttributeEvent.Source;import org.openremote.model.attribute.AttributeExecuteStatus;-import org.openremote.model.rules.AssetState;import org.openremote.model.security.ClientRole;import org.openremote.model.value.Value;import org.openremote.model.value.Values;@@ -53,6 +55,7 @@ import java.util.List;import java.util.Optional;import java.util.logging.Level;import java.util.logging.Logger;+import java.util.stream.Collectors;import static org.openremote.container.concurrent.GlobalLock.withLock;import static org.openremote.manager.asset.AssetProcessingException.Reason.*;@@ -183,6 +186,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer// Restricted users can only get attribute events for their linked assetsif (!assetStorageService.isUserAsset(auth.getUserId(), assetId))return false;+ // TODO Restricted clients should only receive events for RESTRICTED_READ attributes!} else {// Regular users can only get attribute events for assets in their realmif (!asset.getTenantRealm().equals(auth.getAuthenticatedRealm()))@@ -501,9 +505,15 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSerprotected void publishClientEvent(Asset asset, AssetAttribute attribute) {// TODO Catch "queue full" exception (e.g. when producing thousands of INFO messages in rules)?- clientEventService.publishEvent(new AttributeEvent(- asset.getId(), attribute.getNameOrThrow(), attribute.getValue().orElse(null), timerService.getCurrentTimeMillis()- ));+ clientEventService.publishEvent(+ attribute.isAccessRestrictedRead(),+ new AttributeEvent(+ asset.getId(),+ attribute.getNameOrThrow(),+ attribute.getValue().orElse(null),+ timerService.getCurrentTimeMillis()+ )+ );}@Overridediff --git a/manager/src/main/java/org/openremote/manager/event/ClientEventService.java b/manager/src/main/java/org/openremote/manager/event/ClientEventService.javaindex 84ed9e3d5..2621feac9 100644--- a/manager/src/main/java/org/openremote/manager/event/ClientEventService.java+++ b/manager/src/main/java/org/openremote/manager/event/ClientEventService.java@@ -20,7 +20,6 @@package org.openremote.manager.event;import org.apache.camel.Exchange;-import org.apache.camel.LoggingLevel;import org.apache.camel.builder.RouteBuilder;import org.openremote.container.Container;import org.openremote.container.ContainerService;@@ -30,6 +29,7 @@ import org.openremote.container.security.AuthContext;import org.openremote.container.timer.TimerService;import org.openremote.container.web.socket.WebsocketConstants;import org.openremote.manager.concurrent.ManagerExecutorService;+import org.openremote.manager.security.ManagerIdentityService;import org.openremote.model.Constants;import org.openremote.model.event.shared.CancelEventSubscription;import org.openremote.model.event.shared.EventSubscription;@@ -38,6 +38,7 @@ import org.openremote.model.event.shared.UnauthorizedEventSubscription;import org.openremote.model.syslog.SyslogEvent;import java.util.Collection;+import java.util.Collections;import java.util.concurrent.CopyOnWriteArraySet;import java.util.logging.Logger;@@ -101,9 +102,12 @@ public class ClientEventService implements ContainerService {public static final String CLIENT_EVENT_QUEUE = "seda://ClientEventQueue?multipleConsumers=false&waitForTaskToComplete=NEVER&purgeWhenStopping=true&discardIfNoConsumers=true&size=25000";+ public static final String HEADER_ACCESS_RESTRICTED = ClientEventService.class.getName() + ".HEADER_ACCESS_RESTRICTED";+final protected Collection<EventSubscriptionAuthorizer> eventSubscriptionAuthorizers = new CopyOnWriteArraySet<>();protected TimerService timerService;protected MessageBrokerService messageBrokerService;+ protected ManagerIdentityService identityService;protected EventSubscriptions eventSubscriptions;protected boolean stopped;@@ -112,6 +116,7 @@ public class ClientEventService implements ContainerService {public void init(Container container) throws Exception {timerService = container.getService(TimerService.class);messageBrokerService = container.getService(MessageBrokerService.class);+ identityService = container.getService(ManagerIdentityService.class);eventSubscriptions = new EventSubscriptions(container.getService(TimerService.class),@@ -154,7 +159,8 @@ public class ClientEventService implements ContainerService {AuthContext authContext = exchange.getIn().getHeader(Constants.AUTH_CONTEXT, AuthContext.class);if (eventSubscriptionAuthorizers.stream().anyMatch(authorizer -> authorizer.apply(authContext, subscription))) {- eventSubscriptions.update(sessionKey, subscription);+ boolean restrictedUser = identityService.getIdentityProvider().isRestrictedUser(authContext.getUserId());+ eventSubscriptions.update(sessionKey, restrictedUser, subscription);} else {LOG.warning("Unauthorized subscription from '"+ authContext.getUsername() + "' in realm '" + authContext.getAuthenticatedRealm()@@ -209,6 +215,13 @@ public class ClientEventService implements ContainerService {}public void publishEvent(SharedEvent event) {+ publishEvent(true, event);+ }++ /**+ * @param accessRestricted <code>true</code> if this event can be received by restricted user sessions.+ */+ public void publishEvent(boolean accessRestricted, SharedEvent event) {// Only publish if service is not stoppedif (stopped) {return;@@ -219,7 +232,8 @@ public class ClientEventService implements ContainerService {if (!(event instanceof SyslogEvent)) {LOG.fine("Publishing: " + event);}- messageBrokerService.getProducerTemplate().sendBody(CLIENT_EVENT_QUEUE, event);+ messageBrokerService.getProducerTemplate()+ .sendBodyAndHeader(CLIENT_EVENT_QUEUE, event, HEADER_ACCESS_RESTRICTED, accessRestricted);}}diff --git a/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java b/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.javaindex d452e526d..e20bd3f8a 100644--- a/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java+++ b/manager/src/main/java/org/openremote/manager/event/EventSubscriptions.java@@ -32,6 +32,8 @@ import org.openremote.model.event.shared.SharedEvent;import java.util.*;import java.util.logging.Logger;+import static org.openremote.manager.event.ClientEventService.HEADER_ACCESS_RESTRICTED;+/*** Manages subscriptions to events for WebSocket sessions.*/@@ -54,9 +56,9 @@ public class EventSubscriptions {);}- public void update(EventSubscription eventSubscription) {+ public void update(boolean restrictedUser, EventSubscription eventSubscription) {cancel(eventSubscription.getEventType());- add(new SessionSubscription(timerService.getCurrentTimeMillis(), eventSubscription));+ add(new SessionSubscription(restrictedUser, timerService.getCurrentTimeMillis(), eventSubscription));}public void cancel(String eventType) {@@ -65,16 +67,18 @@ public class EventSubscriptions {}class SessionSubscription {+ final boolean restrictedUser;final long timestamp;final EventSubscription subscription;- public SessionSubscription(long timestamp, EventSubscription subscription) {+ public SessionSubscription(boolean restrictedUser, long timestamp, EventSubscription subscription) {+ this.restrictedUser = restrictedUser;this.timestamp = timestamp;this.subscription = subscription;}- public boolean matches(SharedEvent event) {- return subscription.getEventType().equals(event.getEventType());+ public boolean matches(boolean accessibleForRestrictedUsers, SharedEvent event) {+ return (!restrictedUser || accessibleForRestrictedUsers) && subscription.getEventType().equals(event.getEventType());}/**@@ -98,13 +102,13 @@ public class EventSubscriptions {}, 5000, 1000);}- public void update(String sessionKey, EventSubscription subscription) {+ public void update(String sessionKey, boolean restrictedUser, EventSubscription subscription) {synchronized (this.sessionSubscriptions) {// TODO Check if the user can actually subscribe to the events it wants, how do we do that?LOG.fine("For session '" + sessionKey + "', updating: " + subscription);SessionSubscriptions sessionSubscriptions =this.sessionSubscriptions.computeIfAbsent(sessionKey, k -> new SessionSubscriptions());- sessionSubscriptions.update(subscription);+ sessionSubscriptions.update(restrictedUser, subscription);}}@@ -134,6 +138,8 @@ public class EventSubscriptions {if (event == null)return messageList;+ boolean accessibleForRestrictedUsers = exchange.getIn().getHeader(HEADER_ACCESS_RESTRICTED, false, Boolean.class);+Set<Map.Entry<String, SessionSubscriptions>> sessionSubscriptionsSet;synchronized (this.sessionSubscriptions) {sessionSubscriptionsSet = new HashSet<>(sessionSubscriptions.entrySet());@@ -144,7 +150,8 @@ public class EventSubscriptions {SessionSubscriptions subscriptions = entry.getValue();for (SessionSubscription sessionSubscription : subscriptions) {- if (!sessionSubscription.matches(event))++ if (!sessionSubscription.matches(accessibleForRestrictedUsers, event))continue;if (sessionSubscription.subscription.getFilter() == nulldiff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.javaindex 4b6e7842a..fd29c5dc2 100644--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java@@ -112,7 +112,6 @@ public abstract class AbstractManagerSetup implements Setup {.setMeta(new MetaItem(LABEL, Values.create("Last executed scene")),new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),- new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),new MetaItem(READ_ONLY, Values.create(true)),new MetaItem(RULE_STATE, Values.create(true)),new MetaItem(SHOW_ON_DASHBOARD, Values.create(true))@@ -120,8 +119,6 @@ public abstract class AbstractManagerSetup implements Setup {new AssetAttribute("lastDetectedScene", AttributeType.STRING, Values.create("home")).setMeta(new MetaItem(LABEL, Values.create("Last detected scene by rules")),- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),- new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),new MetaItem(READ_ONLY, Values.create(true)),new MetaItem(RULE_STATE, Values.create(true)))@@ -156,15 +153,13 @@ public abstract class AbstractManagerSetup implements Setup {),new AssetAttribute("firstPresenceDetected", TIMESTAMP_MILLIS).setMeta(- new MetaItem(LABEL, Values.create("First time someone was present in the room")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true))+ new MetaItem(LABEL, Values.create("First time movement was detected")),+ new MetaItem(RULE_STATE, Values.create(true))),new AssetAttribute("lastPresenceDetected", TIMESTAMP_MILLIS).setMeta(- new MetaItem(LABEL, Values.create("Last time someone was present in the room")),- new MetaItem(RULE_STATE, Values.create(true)),- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true))+ new MetaItem(LABEL, Values.create("Last time movement was detected")),+ new MetaItem(RULE_STATE, Values.create(true))));}@@ -215,7 +210,7 @@ public abstract class AbstractManagerSetup implements Setup {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 C"))+ new MetaItem(FORMAT, Values.create("%0.1f° C"))).addMeta(shouldBeLinked ? agentLinker.get() : null));}@@ -231,7 +226,7 @@ public abstract class AbstractManagerSetup implements Setup {new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),- new MetaItem(FORMAT, Values.create("%0.1f C"))+ new MetaItem(FORMAT, Values.create("%0.1f° C"))).addMeta(shouldBeLinked ? agentLinker.get() : null));}@@ -479,7 +474,6 @@ public abstract class AbstractManagerSetup implements Setup {.setMeta(new MetaItem(LABEL, Values.create("Scene timer enabled")),new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),- new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),new MetaItem(READ_ONLY, Values.create(true))),diff --git a/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java b/manager/src/main/java/org/openremote/manager/web/ManagerWebService.javaindex b0c57e642..7408d3d2c 100644--- a/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java+++ b/manager/src/main/java/org/openremote/manager/web/ManagerWebService.java@@ -21,6 +21,8 @@ package org.openremote.manager.web;import io.undertow.server.HttpHandler;import io.undertow.servlet.api.DeploymentInfo;+import io.undertow.util.Headers;+import io.undertow.util.StatusCodes;import org.openremote.container.Container;import org.openremote.container.security.IdentityService;import org.openremote.container.web.WebService;@@ -66,7 +68,30 @@ public class ManagerWebService extends WebService {// Serve the Console client files unsecuredconsolesDocRoot = Paths.get(getString(container.getConfig(), CONSOLES_DOCROOT, CONSOLES_DOCROOT_DEFAULT));- addRoute(addDeployment(devMode, identityService, consolesDocRoot, CONSOLE_PATH), CONSOLE_PATH, CONSOLE_PATTERN);+ HttpHandler consoleHandler = addDeployment(devMode, identityService, consolesDocRoot, CONSOLE_PATH);+ // Special case for Console client files: When certain files are requested, serve them from the /static/*+ // resources already deployed in Manager. In other words: Console apps should not have their own Polymer etc.+ // resources but use the files we also use in platform components.+ String[] consoleStaticResources = {+ "/bower_components/polymer/polymer.html",+ "/bower_components/polymer/polymer-element.html",+ "/bower_components/iron-flex-layout/iron-flex-layout.html",+ "/bower_components/iron-flex-layout/iron-flex-layout-classes.html",+ "/bower_components/chart.js/dist/Chart.js",+ // TODO Add all the other stuff but Intl is many files, no idea how we deal with this... good approach?+ };+ addRoute(exchange -> {+ for (String consoleStaticResource : consoleStaticResources) {+ if (exchange.getRequestPath().endsWith(consoleStaticResource)) {+ exchange.setStatusCode(StatusCodes.FOUND);+ exchange.getResponseHeaders().put(Headers.LOCATION, "/static" + consoleStaticResource);+ exchange.endExchange();+ return;+ }+ }+ consoleHandler.handleRequest(exchange);+ }, CONSOLE_PATH, CONSOLE_PATTERN+ );// Serve the UI deployment files unsecureduiDocRoot = Paths.get(getString(container.getConfig(), UI_DOCROOT, UI_DOCROOT_DEFAULT));diff --git a/manager/src/main/resources/demo/rules/DemoApartmentPresencePrediction.drl b/manager/src/main/resources/demo/rules/DemoApartmentPresencePrediction.drlindex 172bb2c9e..ebe5a43b8 100644--- a/manager/src/main/resources/demo/rules/DemoApartmentPresencePrediction.drl+++ b/manager/src/main/resources/demo/rules/DemoApartmentPresencePrediction.drl@@ -9,233 +9,334 @@ global java.util.logging.Logger LOG;global org.openremote.model.rules.Assets assets;global org.openremote.container.util.Util util;-/*-New:-- // ROOM- presenceDetected // true/false- presenceDetectedInteger // 1 on motion sense, 0 after 2 seconds. This behavior models typical PIR sensor- lastPresenceDetectedTimeStamp // Unix timestamp milliseconds-- // RESIDENCE- selfLearning // true/false- vacationDays // 0..123-- homeSceneStartMonday // "17:30:00"- homeSceneStartTuesday // "17:45:00"- ...- awaySceneStartMonday // "08:30:00"- awaySceneStartTuesday // "08:30:00"-- rule "..."- when- $dayOfWeek : util.formatDate("DAY_OF_WEEK", drools.clock.currentTime)- AssetState(type == RESIDENCE, attributeName matches "homeSceneStart" + $dayOfWeek, valueChanged)- then- ...- end--Old:-- presenceDetected // "on"- presenceDetectedInteger // 0, 1- lastPresenceDetectedTimeStamp // "-", hh:mm- presenceDetectedUI // "Yes"/"No", Latches for 15mins; translates to somebody/nobody is in the office-- VACATION_DAYS // "0"-- UI_ESTIMATED_TIME_ARRIVAL // This is today- UI_ESTIMATED_TIME_DEPARTURE // This is today- UI_ESTIMATED_TIME_ARRIVAL.mon // "9:00"- UI_ESTIMATED_TIME_DEPARTURE.mon // "17:00"- UI_ESTIMATED_TIME_ARRIVAL.tue // "9:00"- UI_ESTIMATED_TIME_DEPARTURE.tue // "17:00"- UI_ESTIMATED_TIME_ARRIVAL.wed // "9:00"- UI_ESTIMATED_TIME_DEPARTURE.wed // "17:00"- ...-- homeActualSceneStartTime // "-", e.g. "08:53"- awayActualSceneStartTime // "-", e.g. "18:22"-- currentScene // "-", Possible values are "-", "Departure", "Arrive"-*/---// ##########################################################################################################--// This rule converts any manufacturer dependent movement sensor into standardized PIR behaviour.-// Here emulate PIR from motionCount by Enervalis-rule "person sense"-when- AssetEvent(type == AssetType.ROOM, attributeName == "motionCount", isValueGreaterThanOldValue() )- $room: AssetEvent($id: id, type == AssetType.ROOM, attributeName=="presenceDetectedInteger", getValueAsNumber() !=1)-then- LOG.info("@"+(new java.util.Date(drools.getWorkingMemory().getSessionClock().getCurrentTime())).toString());- assets.dispatch( new AttributeEvent($id, "lastPresenceDetectedTimeStamp", Values.create(1) ) );+import java.util.*+import java.time.LocalDateTime+import java.time.Instant+import java.time.ZoneId+import java.time.format.DateTimeFormatter++declare CustomClock+ @role(event)+ @expires(45s)+ clock: LocalDateTime+ time: String+ dowPrev: String+ dow: String+ dowNext: String+end++declare Scene+ @role(event)+ @expires(12h)+ scene: String // scene name+ est: String // estimated time of scene - from the table+ ast: String // actual time of scene - masuredend-// This rule models monostable PIR sensor behaviour, which goes to off state after 2s timeout-rule "no person sense"- timer(int: 2s)+rule "PP: Update table"when- AssetEvent(type == AssetType.ROOM, attributeName == "motionCount", isValueGreaterThanOldValue())- AssetEvent($id: id, type == AssetType.ROOM, $s:attributeName=="presenceDetectedInteger", getValueAsNumber()!=0)+ // Chcek if we are self learning+ AssetState(attributeName == "autoSceneSchedule", isValueTrue())+ // Rule's detected scene+ $s: Scene($scene: scene, $estimated_time: est, $actual_time: ast != "-")+ // Get estimated the table reference+ CustomClock($dow: dow) // TODO goes wrong when updating scene after midnight and the ast is before midnight. We need dowPrev for this case.+ AssetState($ref: id, type == AssetType.RESIDENCE, $an: attributeName matches ($scene + "SceneTime" + $dow))then- LOG.info("@"+(new java.util.Date(drools.getWorkingMemory().getSessionClock().getCurrentTime())).toString());- assets.dispatch( new AttributeEvent($id, "lastPresenceDetectedTimeStamp", Values.create(0)) );+ // Mark operation done+ $s.setAst("-");+ update($s);+ // protect against errors, e.g. too large gaps, over midnight pass+ String actual_time = _MaxTimeAdjustment($estimated_time, $actual_time);+ LOG.info("PP: "+$scene+" EST="+$estimated_time+", AST="+$actual_time+", cor="+actual_time);+ // Take arbitrary coefficient which works good+ Double alpha = 2.0/(3+1); // 3 stays for 3 days exponential average+ // Calculate exponential moving average from the known formula+ long new_estimated_time = (long) (alpha*util.parseTimestamp(actual_time) ++ (1-alpha)*util.parseTimestamp($estimated_time));+ String new_estimated_time_str = util.formatTimestampWithSeconds(new_estimated_time);+ LOG.info("PP: updated time for "+$scene+" from "+$estimated_time+" to "+new_estimated_time_str+" by measured (cor)"+actual_time);+ // Update the value in the table+ assets.dispatch( new AttributeEvent($ref, $an, Values.create(new_estimated_time_str)) );end-// Fetch last time when presence was detected. This time is used for period window adjustment.-rule "last move sense timestamp fetch"-when- AssetEvent($id: id, type == AssetType.ROOM, attributeName=="presenceDetectedInteger", getValueAsNumber()==1, isValueChanged() )++rule "PP: Set custom clock fields"+ timer (cron: 0 * * * * ? *)then- long currentTime = drools.getWorkingMemory().getSessionClock().getCurrentTime();- LOG.info("Move sense on "+$id+" @"+(new java.util.Date(currentTime)).toString() );- assets.dispatch(- // we want that this time stamp is persistent in memory because periods are quite long and it- // is likely that a rule engine can restart in this time. Experience learns that this can- // disturb the prediction time.- new AttributeEvent($id, "lastPresenceDetectedTimeStamp", Values.create(currentTime))- );+ CustomClock cc = new CustomClock();++ Instant instant = Instant.ofEpochMilli( drools.getWorkingMemory().getSessionClock().getCurrentTime() );+ LocalDateTime res = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());+ cc.setClock(res);+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");++ cc.setTime( cc.getClock().format(formatter) );+ cc.setDow( cc.getClock().getDayOfWeek().toString() );+ cc.setDowNext( cc.getClock().getDayOfWeek().plus(1).toString() );+ cc.setDowPrev( cc.getClock().getDayOfWeek().plus(-1).toString() );++ insert(cc);end-// Set the presence state which was previously used in the UI "Somebody is in the office"-rule "Presence"++rule "PP: Get current scheduled scene home"when- AssetEvent(type == AssetType.ROOM, $s:attributeName=="presenceDetectedInteger", getValueAsNumber()==1)- AssetState(type == AssetType.RESIDENCE, attributeName=="currentScene", getValueAsString()=="Departure") // within expected attendance schedule- AssetState($id: id, type == AssetType.RESIDENCE, attributeName=="presenceDetectedUI", getValueAsString()!="Yes")+ CustomClock($dow: dow, $t: time)+ AssetState(attributeName matches ("home.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState(attributeName matches ("away.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ not Scene(scene == "home");+ // There should be movement in the living room+ AssetState(attributeName == "presenceDetected", name == "Living Room", type == AssetType.ROOM, isValueTrue() )+ // The first movement in the living room is the actual scene start+ AssetState(attributeName == "firstPresenceDetected", type == AssetType.ROOM, name == "Living Room", $ast: getValueTimestamp(), value != null, isValueGreaterThan(0) )then- assets.dispatch( new AttributeEvent($id, "presenceDetectedUI", Values.create("Yes")) );+ Scene s = new Scene();+ s.setScene("home");+ s.setEst($ts);+ String ast = util.formatTimestampWithSeconds($ast);+ LOG.info("PP: HOME @ AST"+" "+ast);+ s.setAst(ast);+ insert(s);end-rule "Absence after 15 min"- timer(int: 15m)++rule "PP: Get current scheduled scene away"when- AssetEvent($id: id, type == AssetType.ROOM, $s:attributeName=="presenceDetectedInteger", getValueAsNumber()==0)+ CustomClock($dow: dow, $t: time)+ AssetState(attributeName matches ("away.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState(attributeName matches ("evening.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ not Scene(scene == "away");+ // There should be no movement in the whole apartment+ AssetState(attributeName == "presenceDetected", type == AssetType.RESIDENCE, valueFalse )+ // Actual scene start is the last movement in the Living Room+ AssetState($id: id, attributeName == "lastPresenceDetected", type == AssetType.ROOM, name == "Living Room", $ast: getValueTimestamp(), value != null)+ AssetState(id==$id, attributeName == "firstPresenceDetected", isValueGreaterThan(0))then- assets.dispatch( new AttributeEvent($id, "presenceDetectedUI", Values.create("No")) );+ Scene s = new Scene();+ s.setScene("away");+ s.setEst($ts);+ String ast = util.formatTimestampWithSeconds($ast);+ LOG.info("PP: AWAY @ AST"+" "+ast);+ s.setAst(ast);+ insert(s);+ // Clear first movements in all rooms+ assets.dispatch( new AttributeEvent($id, "firstPresenceDetected", Values.create(0)) );end-// ##########################################################################################################--// The office hours starts from Arrival till Departure. This is comparable to Home or Evening scene in blok61.-// The outside office hours are from Departure till the next day Arrival. Comparable to Away and Night.-// There were 2 in memory variables (now AssetStates) which holds actual arrival and departure time. They need-// to be reset before scene begins to fetch the actual time which is later used to correct the estimated time-// in moving average calculations.-// There are 4 rules below, one for each scene, the actual start time of a scene is reset when the preceding scene-// starts. Perhaps we can use as a trigger one more preceding scene which give as less trouble with earlier-// scene starting.-rule "reset homeActualSceneStartTime"+rule "PP: Get current scheduled scene evening"when- AssetState(attributeName=="currentScene", type == AssetType.RESIDENCE, getValueAsString()=="night")- AssetState($id: id, attributeName=="homeActualSceneStartTime", type == AssetType.RESIDENCE, getValueAsString() != "-")+ CustomClock($dow: dow, $t: time)+ AssetState(attributeName matches ("evening.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState(attributeName matches ("night.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ not Scene(scene == "evening");+ // There should be presence in the apartment+ AssetState(attributeName == "presenceDetected", type == AssetType.RESIDENCE, isValueTrue() )+ // Actual scene start is the first movement in the living room+ AssetState(attributeName == "firstPresenceDetected", type == AssetType.ROOM, name == "Living Room", $ast: getValueTimestamp(), value != null, isValueGreaterThan(0) )then- assets.dispatch( new AttributeEvent($id, "homeActualSceneStartTime", Values.create("-")) );+ Scene s = new Scene();+ s.setScene("evening");+ s.setEst($ts);+ String ast = util.formatTimestampWithSeconds($ast);+ LOG.info("PP: EVENING @ AST"+" "+ast);+ s.setAst(ast);+ insert(s);end-rule "reset awayActualSceneStartTime"++rule "PP: Get current scheduled scene night"when- AssetState(attributeName=="currentScene", type == AssetType.RESIDENCE, getValueAsString()=="home")- AssetState($id: id, attributeName=="awayActualSceneStartTime", type == AssetType.RESIDENCE, getValueAsString() != "-")+ CustomClock($dow: dow, $dowNext: dowNext, $t: time)+ AssetState(attributeName matches ("night.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState(attributeName matches ("home.*"+$dowNext), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ not Scene(scene == "night");+ // No presence in the living room+ AssetState($id: id, attributeName == "presenceDetected", name == "Living Room", type == AssetType.ROOM, valueFalse )+ // Scene start is the last movement in the living room+ AssetState(id == $id, attributeName == "lastPresenceDetected", type == AssetType.ROOM, name == "Living Room", $ast: getValueTimestamp(), value != null)+ AssetState(id == $id, attributeName == "firstPresenceDetected", isValueGreaterThan(0))then- assets.dispatch( new AttributeEvent($id, "awayActualSceneStartTime", Values.create("-")) );+ Scene s = new Scene();+ s.setScene("night");+ s.setEst($ts);+ String ast = util.formatTimestampWithSeconds($ast);+ LOG.info("PP: NIGHT @ AST"+" "+ast);+ s.setAst(ast);+ insert(s);+ // Clear first movements everywhere except the bedroom+ assets.dispatch( new AttributeEvent($id, "firstPresenceDetected", Values.create(0)) );end-rule "reset eveningActualSceneStartTime"++function String _ShiftTimeWithSeconds(Object o, int min){+ if(o==null){+ return("-");+ }+ String mt = o.toString();+ SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");+ Date date = null;+ if(mt.substring(0,1).equals("-")){+ date = new Date();+ date.setTime(date.getTime()+60*60000);+ }else{+ date = sdf.parse(mt);+ date.setTime(date.getTime()+min*60000);+ }+ return(sdf.format(date));+}+++function long _GetTime(Object o){+ if(o==null){+ return(0L);+ }+ String mt = o.toString();+ SimpleDateFormat sdf;+ if(mt.length()==8){+ sdf = new SimpleDateFormat("HH:mm:ss");+ }else if(mt.length()==5){+ sdf = new SimpleDateFormat("HH:mm");+ }else{+ return(0L);+ }+ Date date = null;+ date = sdf.parse(mt);+ return(date.getTime());+}++function boolean _TradingTimes(Object now, Object start, Object endt){+ long _now = _GetTime(now);+ long _start = _GetTime(start);+ long _end = _GetTime(endt);+ while(_start < _now){ _start += 86400000L; }+ while(_end < _now){ _end += 86400000L; }+ return(_end < _start);+}++function String _MaxTimeAdjustment(Object estimated, Object actual){+// This function checks if the actual time is within range +- 60min of estimated time and adjust it if necessary.+ int MAX = 60; // maximum difference in minutes+ if(estimated==null) return("-");+ if(actual==null) return(estimated.toString());+ long _estimated = _GetTime(estimated);+ long _actual = _GetTime(actual);+ if(_TradingTimes(actual, _ShiftTimeWithSeconds(estimated, -MAX), _ShiftTimeWithSeconds(estimated, MAX))){+ // Within 1h+ return(actual.toString());+ }+ // Here we have a shift > 1h and < 12h, so ceil it to 1h+ if(java.lang.Math.abs(_estimated-_actual) > 12*60*60000){+ // we need good over the midnight passing+ _estimated = _GetTime(_ShiftTimeWithSeconds(estimated, 12*60));+ _actual = _GetTime(_ShiftTimeWithSeconds(actual, 12*60));+ }else if(java.lang.Math.abs(_estimated-_actual) == 12*60*60000){+ // exactly 12h difference -> do not adjust+ return(estimated.toString());+ }++ if(_estimated > _actual){+ return(_ShiftTimeWithSeconds(estimated, -MAX));+ }+ // else <=+ return(_ShiftTimeWithSeconds(estimated, MAX));+}++// TODO special care must be taken for the night scene as it can start before or after midnight.++// TODO below with over the midnight scenes+rule "PP: Get current scheduled scene still previous evening"+// From table find out in which scene we should be+// scenes are prevevening-prevnight-home-away-evening-nightwhen- AssetState(attributeName=="currentScene", type == AssetType.RESIDENCE, getValueAsString()=="away")- AssetState($id: id, attributeName=="eveningActualSceneStartTime", type == AssetType.RESIDENCE, getValueAsString() != "-")+ CustomClock($dow: dow, $dowPrev: dowPrev, $t: time)+ AssetState(attributeName matches ("evening.*"+$dowPrev), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState(attributeName matches ("night.*"+$dowPrev), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))then- assets.dispatch( new AttributeEvent($id, "eveningActualSceneStartTime", Values.create("-")) );+// LOG.info("@"+$c.toString() );end-rule "reset nightActualSceneStartTime"+rule "PP: Get current scheduled scene prev night"+// From table find out in which scene we should be+// scenes are prevevening-prevnight-home-away-evening-nightwhen- AssetState(attributeName=="currentScene", type == AssetType.RESIDENCE, getValueAsString()=="evening")- AssetState($id: id, attributeName=="nightActualSceneStartTime", type == AssetType.RESIDENCE, getValueAsString() != "-")+ CustomClock($dow: dow, $dowPrev: dowPrev, $t: time)+ AssetState(attributeName matches ("night.*"+$dowPrev), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState(attributeName matches ("home.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))then- assets.dispatch( new AttributeEvent($id, "nightActualSceneStartTime", Values.create("-")) );+// LOG.info("@"+$c.toString() );end-// Removed rules:-// rule "Move ETD to ET at arrive init"-// rule "Move ETD to ET at arrive"-// because they were used for the old UI display.-rule "fetch the actual scene start time"+rule "PP: dash scene home"when-// $timestamp : util.formatTimestamp(drools.clock.currentTime)- AssetState(attributeName=="currentScene", type == AssetType.RESIDENCE, $scene: getValueAsString())-//TODO AssetState($id:id, $attributeName: attributeName==$scene."ActualSceneStartTime", getValueAsString() == "-")- // TODO the actual arrive state was detected by presence sensor. Now we have 2 scenes when presence is- // detected and 2 when absence is detected- AssetEvent($id: id, type == AssetType.ROOM, attributeName=="presenceDetectedInteger", getValueAsNumber()==1)+ CustomClock($dow: dow, $t: time)+ AssetState($ref: id, attributeName matches ("home.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState($ref == id, attributeName matches ("away.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ $apartment: AssetState($ref == id, type == AssetType.RESIDENCE, attributeName == "lastDetectedScene", $val: getValueAsString() != "home", $val != "away")then- assets.dispatch( new AttributeEvent($id, "nightActualSceneStartTime", Values.create(drools.getWorkingMemory().getSessionClock().getCurrentTime()) ));+ LOG.info("PP: dash home in "+$apartment.toString());+ assets.dispatch( new AttributeEvent($ref, "lastDetectedScene", Values.create("home")) );end-rule "fetch earlier actual home scene start time up to 30 min v02"++rule "PP: before scene home to reset the first presence"when- // Earliest home scene start time is 4AM-// TODO $timestamp : util.formatTimestamp(drools.clock.currentTime) >= util.parseTimestamp("04:00")- AssetState($id: id, $attributeName: attributeName=="homeActualSceneStartTime", getValueAsString() == "-")- AssetState(attributeName=="currentScene", type == AssetType.RESIDENCE, getValueAsString() == "night")- AssetEvent(type == AssetType.ROOM, attributeName=="presenceDetectedInteger", getValueAsNumber()==1)- // Take the current value from the scene table- AssetState($ref: attributeRef, type == AssetType.RESIDENCE, attributeName matches ("homeSceneStart" + util.formatDayOfWeek(drools.getWorkingMemory().getSessionClock().getCurrentTime())),- $estimated_time: getValueAsNumber() -30 <= util.parseTimestamp(drools.getWorkingMemory().getSessionClock().getCurrentTime()) )//,-// drools.getWorkingMemory().getSessionClock().getCurrentTime() >= util.parseTimestamp("04:00") )+ CustomClock($dow: dow, $t: time)+ AssetState(attributeName matches ("home.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString(), _TradingTimes($t, _ShiftTimeWithSeconds($ts,-30), _ShiftTimeWithSeconds($ts,-29)))+ $room: AssetState($ref: id, type == AssetType.ROOM, attributeName == "firstPresenceDetected", isValueGreaterThan(0) )+ AssetState($ref == id, type == AssetType.ROOM, attributeName == "presenceDetected", valueFalse)then- assets.dispatch( new AttributeEvent($id, "homeActualSceneStartTime", Values.create(drools.getWorkingMemory().getSessionClock().getCurrentTime()) ));+ LOG.info("PP: home reset first presence in "+$room.toString());+ assets.dispatch( new AttributeEvent($ref, "firstPresenceDetected", Values.create(0)) );end-// Removed rule for switching scene after departure-// rule "Move - to ET at end of work"-// scenes are switched by timer protocol--// Removed rule-// rule "Move - to ET on vacation"-// it was indication in UI that vacation are active-// Removed rules-// rule "fetch actual departure time"-// rule "fetch later departure time"-// as "departure" is simply a start of a new scene and these should be covered by previous rules.-// TODO scene switch could be earlier and later. Both cases need be tested for each scene.-// As we have 2 presence scenes (home, evening) and 2 absence scenes (away, night) probably would be easier-// to have 2 sets of rules, like in the office separate rules for Arrival adjustment time and Departure.+rule "PP: dash scene away"+when+ CustomClock($dow: dow, $t: time)+ AssetState($ref: id, attributeName matches ("away.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState($ref == id, attributeName matches ("evening.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ $apartment: AssetState($ref == id, type == AssetType.RESIDENCE, attributeName == "lastDetectedScene", $val: getValueAsString() != "away", $val != "evening")+then+ LOG.info("PP: dash away in "+$apartment.toString());+ assets.dispatch( new AttributeEvent($ref, "lastDetectedScene", Values.create("away")) );+end-// TODO special care must be taken for the Night scene as it can start before or after midnight.-rule "adjust estimated times at next scene change"+rule "PP: dash scene evening"when- // Question: isn't AssetType checking relevant here? attributeName should be unique here or not?- // We are in the self learning mode- AssetState(attributeName == "selfLearning", type == AssetType.RESIDENCE, isValueTrue() )- // We don't do this when on Vacations- AssetState(attributeName == "vacationDays", type == AssetType.RESIDENCE, isValueGreaterThan(0) )- // Let's get in which scene are we now- AssetState(attributeName == "currentScene", type == AssetType.RESIDENCE, $scene: getValueAsString() )- // For which day of week are we calculating this?- // Take the current value from the scene table- AssetState($ref: id, type == AssetType.RESIDENCE, attributeName matches ($scene + "SceneStart" + util.formatDayOfWeek(drools.getWorkingMemory().getSessionClock().getCurrentTime())), $estimated_time: getValueAsNumber())- // Now take the lastPresenceDetected (TODO here we will need probably a different logic dependent on scene)- AssetState(attributeName == "lastPresenceDetected", type == AssetType.ROOM, $actual_time: getValueAsNumber(), isValueGreaterThan(0) )+ CustomClock($dow: dow, $t: time)+ AssetState($ref: id, attributeName matches ("evening.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState($ref == id, attributeName matches ("night.*"+$dow), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ $apartment: AssetState($ref == id, type == AssetType.RESIDENCE, attributeName == "lastDetectedScene", $val: getValueAsString() != "evening", $val != "night")then- // Take arbitrary coefficient which works good- Double alpha = 2.0/(3+1); // 3 stays for 3 days exponential average- // Calculate exponential moving average from the known formula- long new_estimated_time = (long) (alpha*util.parseTimestamp($actual_time) + (1-alpha)*util.parseTimestamp($estimated_time));- // Update value in the table- assets.dispatch( new AttributeEvent($ref, "newEstimatedTime", Values.create(new_estimated_time)) );+ LOG.info("PP: dash evening in "+$apartment.toString());+ assets.dispatch( new AttributeEvent($ref, "lastDetectedScene", Values.create("evening")) );end-// ##########################################################################################################+rule "PP: before scene evening to reset the first presence"+when+ CustomClock($dow: dow, $t: time)+ AssetState(attributeName matches ("evening.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString(), _TradingTimes($t, _ShiftTimeWithSeconds($ts,-30), _ShiftTimeWithSeconds($ts,-29)))+ $room: AssetState($ref: id, type == AssetType.ROOM, attributeName == "firstPresenceDetected", isValueGreaterThan(0) )+ AssetState($ref == id, type == AssetType.ROOM, attributeName == "presenceDetected", valueFalse)+then+ LOG.info("PP: evening reset first presence in "+$room.toString());+ assets.dispatch( new AttributeEvent($ref, "firstPresenceDetected", Values.create(0)) );+end+rule "PP: dash scene night"+when+ CustomClock($dow: dow, $dowNext: dowNext, $t: time)+ AssetState($ref: id, attributeName matches ("night.*"+$dow), type == AssetType.RESIDENCE, $ts: getValueAsString())+ AssetState($ref == id, attributeName matches ("home.*"+$dowNext), type == AssetType.RESIDENCE, $te: getValueAsString(), _TradingTimes($t, $ts, $te))+ $apartment: AssetState($ref == id, type == AssetType.RESIDENCE, attributeName == "lastDetectedScene", $val: getValueAsString() != "night", $val != "home")+then+ LOG.info("PP: dash night in "+$apartment.toString());+ assets.dispatch( new AttributeEvent($ref, "lastDetectedScene", Values.create("night")) );+end\ No newline at end of filediff --git a/manager/src/main/resources/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy b/manager/src/main/resources/demo/rules/DemoResidenceNotifyAlarmTrigger.groovyindex 12cdb7606..ddf212382 100644--- a/manager/src/main/resources/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy+++ b/manager/src/main/resources/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy@@ -20,6 +20,7 @@ Users users = binding.users@ToString(includeNames = true)class AlarmTrigger {String residenceId+ String residenceNameString roomName}@@ -29,6 +30,7 @@ class AlarmTrigger {@ToString(includeNames = true)class AlertSilence {static String DURATION = "30m"+ String residenceNameString residenceId}@@ -54,7 +56,9 @@ rules.add()}).map({ roomWithPresence ->roomWithPresence.get()}).findFirst().map({ roomWithPresence ->- facts.bind("residenceId", roomWithPresence.parentId).bind("roomName", roomWithPresence.name)+ facts.bind("residenceId", roomWithPresence.parentId)+ .bind("residenceName", roomWithPresence.parentName)+ .bind("roomName", roomWithPresence.name)true}).orElse(false)})@@ -62,9 +66,10 @@ rules.add(){ facts ->AlarmTrigger alarmTrigger = new AlarmTrigger(residenceId: facts.bound("residenceId"),+ residenceName: facts.bound("residenceName"),roomName: facts.bound("roomName"))- LOG.info("Alarm enabled and presence detected, creating: " + alarmTrigger)+ LOG.info("Alarm enabled and presence detected in residence, creating: $alarmTrigger")facts.put(alarmTrigger)})@@ -141,9 +146,10 @@ rules.add()title: "Apartment Alarm",message: "Aanwezigheid in " + alarmTrigger.roomName + " (" + facts.clock.time + ").")- alert.addLinkAction("Details", "#/Veilig")+ alert.addLinkAction("Details", "#security")alert.addActuatorAction("Alarm uit", alarmTrigger.residenceId, "alarmEnabled", Values.create(false).toJson())+ // This only includes users which have a device notification token (registered console device)!List<String> userIds = users.query().asset(new UserQuery.AssetPredicate(alarmTrigger.residenceId))@@ -154,10 +160,11 @@ rules.add()users.storeAndNotify(userId, alert)})- AlertSilence alertSilence = new AlertSilence(residenceId: alarmTrigger.residenceId)+ AlertSilence alertSilence = new AlertSilence(+ residenceName: alarmTrigger.residenceName,+ residenceId: alarmTrigger.residenceId+ )facts.putTemporary(AlertSilence.DURATION, alertSilence)-- facts.remove(alarmTrigger)})rules.add()diff --git a/manager/src/main/resources/demo/rules/DemoResidencePresenceDetection.groovy b/manager/src/main/resources/demo/rules/DemoResidencePresenceDetection.groovyindex d5ddb0803..d539830f9 100644--- a/manager/src/main/resources/demo/rules/DemoResidencePresenceDetection.groovy+++ b/manager/src/main/resources/demo/rules/DemoResidencePresenceDetection.groovy@@ -39,6 +39,10 @@ rules.add()}).findFirst().map({ roomWithMotionSensorTriggered ->facts.bind("room", roomWithMotionSensorTriggered)+ true++ /* Results in many false negatives when somebody is moving in the room but+ windows are open, and therefore CO2 is not increasing// and there is a CO2 sensor in the roomfacts.matchFirstAssetState(@@ -58,6 +62,7 @@ rules.add()coLevel.isValueGreaterThanOldValue()}).count() >= 2 // at least 2}).orElse(true) // or we don't have a CO2 sensor+ */}).orElse(false)})@@ -94,7 +99,7 @@ rules.add()).filter({ coLevelFact ->// with increasing valuescoLevelFact.getFact().isValueGreaterThanOldValue()- // in the last 12 minutes≤+ // in the last 12 minutes}).filter(facts.clock.last("12m")).count() == 0}).orElse(true) // or we don't have a CO2 sensordiff --git a/manager/src/main/resources/demo/rules/DemoResidenceSmartSwitch.groovy b/manager/src/main/resources/demo/rules/DemoResidenceSmartSwitch.groovyindex 9e086fec1..e66a08f12 100644--- a/manager/src/main/resources/demo/rules/DemoResidenceSmartSwitch.groovy+++ b/manager/src/main/resources/demo/rules/DemoResidenceSmartSwitch.groovy@@ -74,9 +74,9 @@ rules.add()AssetState beginEnd = facts.bound("beginEnd")LOG.info("Empty smart switch begin/end, clearing start/stop time and disabling actuator: " + beginEnd)String smartSwitchName = getSmartSwitchName(beginEnd)- facts.updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StartTime + smartSwitchName)- .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StopTime + smartSwitchName)- .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.Enabled + smartSwitchName)+ facts.updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StartTime + smartSwitchName, 0)+ .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StopTime + smartSwitchName, 0)+ .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.Enabled + smartSwitchName, 0)})rules.add()@@ -130,7 +130,7 @@ rules.add()startTime.isPresent() &&// the value is not the same as the expected start timestartTime.flatMap({ it.valueAsNumber }).map({- (it * 1000) != expectedStartTime+ it != Math.floor(expectedStartTime / 1000)}).orElse(true) // or actuator start time is empty}).orElse(false)}).findFirst().map({ beginEnd ->@@ -142,9 +142,9 @@ rules.add(){ facts ->AssetState beginEnd = facts.bound("beginEnd")// Start time is user-provided begin/end (in seconds)- def startSeconds = beginEnd.valueAsNumber.map({ it / 1000 }).orElse(0)- // Stop time is start time plus (CYCLE_TIME_SECONDS + 1m)- def stopSeconds = startSeconds + (CYCLE_TIME_SECONDS + 60)+ def startSeconds = Math.floor(beginEnd.valueAsNumber.map({ it / 1000 }).orElse(0))+ // Stop time is start time plus CYCLE_TIME_SECONDS+ def stopSeconds = startSeconds + CYCLE_TIME_SECONDSLOG.info("Smart switch mode is ON_AT, enabling actuator with start/stop times " +LocalDateTime.ofInstant(Instant.ofEpochMilli((long) startSeconds * 1000), ZoneId.systemDefault()) +"/" +@@ -153,39 +153,7 @@ rules.add()String smartSwitchName = getSmartSwitchName(beginEnd)facts.updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StartTime + smartSwitchName, startSeconds).updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StopTime + smartSwitchName, stopSeconds)- .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.Enabled + smartSwitchName, Values.create(1))- })--rules.add()- .name("Set future end time of cycle when mode is READY_AT and cycle can't finish until end time")- .when(- { facts ->- smartSwitchAttributesMatch(- facts, SmartSwitchAttribute.Mode- ).filter({ mode ->- SmartSwitchMode.matches(mode, SmartSwitchMode.READY_AT)- }).map({ modeReadyAt ->- smartSwitchAttributeMatch(facts, modeReadyAt, SmartSwitchAttribute.BeginEnd)- }).filter({ beginEnd ->- // Computed stop time (desired end time of cycle minus duration) is in the past- beginEnd.flatMap({ it.valueAsNumber })- .map({ it - ((CYCLE_TIME_SECONDS + 60) * 1000) })- .map({ it < facts.clock.timestamp })- .orElse(false)- }).findFirst().map({ beginEnd ->- facts.bind("beginEnd", beginEnd.get())- true- }).orElse(false)- })- .then(- { facts ->- AssetState beginEnd = facts.bound("beginEnd")- def newBeginEnd = facts.clock.timestamp + ((CYCLE_TIME_SECONDS + 60) * 1000)- LOG.info("Smart switch mode is READY_AT, increasing insufficient begin/end time to " +- LocalDateTime.ofInstant(Instant.ofEpochMilli((long) newBeginEnd), ZoneId.systemDefault()) +- ": " + beginEnd)- String smartSwitchName = getSmartSwitchName(beginEnd)- facts.updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.BeginEnd + smartSwitchName, newBeginEnd)+ .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.Enabled + smartSwitchName, 1)})rules.add()@@ -203,8 +171,8 @@ rules.add()beginEnd.flatMap({it.valueAsNumber}).filter({- // is now or in future- it >= facts.clock.timestamp+ // allows the cycle to complete in future+ (it - (CYCLE_TIME_SECONDS * 1000)) >= facts.clock.timestamp}).map({ expectedStopTime ->// and actuator stop time attributedef stopTime = beginEnd.flatMap({@@ -214,7 +182,7 @@ rules.add()stopTime.isPresent() &&// the value is not the same as the expected stop timestopTime.flatMap({ it.valueAsNumber }).map({- (it * 1000) != expectedStopTime+ it != Math.floor(expectedStopTime / 1000)}).orElse(true) // or actuator stop time is empty}).orElse(false)}).findFirst().map({ beginEnd ->@@ -226,9 +194,9 @@ rules.add(){ facts ->AssetState beginEnd = facts.bound("beginEnd")// Start time is current time (in seconds)- def startSeconds = (double) facts.clock.timestamp / 1000+ def startSeconds = Math.floor((double) facts.clock.timestamp / 1000)// Stop time is user-provided smart switch time (in seconds)- def stopSeconds = beginEnd.valueAsNumber.map({ it / 1000 }).orElse(0)+ def stopSeconds = Math.floor(beginEnd.valueAsNumber.map({ it / 1000 }).orElse(0))LOG.info("Smart switch mode is READY_AT, enabling actuator with start/stop times " +LocalDateTime.ofInstant(Instant.ofEpochMilli((long) startSeconds * 1000), ZoneId.systemDefault()) + "/" +LocalDateTime.ofInstant(Instant.ofEpochMilli((long) stopSeconds * 1000), ZoneId.systemDefault()) +@@ -237,7 +205,7 @@ rules.add()String smartSwitchName = getSmartSwitchName(beginEnd)facts.updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StartTime + smartSwitchName, startSeconds).updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.StopTime + smartSwitchName, stopSeconds)- .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.Enabled + smartSwitchName, Values.create(1))+ .updateAssetState(beginEnd.id, "smartSwitch" + SmartSwitchAttribute.Enabled + smartSwitchName, 1)})rules.add()@@ -251,9 +219,9 @@ rules.add()}).map({ modeOnAtOrReadyAt ->smartSwitchAttributeMatch(facts, modeOnAtOrReadyAt, SmartSwitchAttribute.StopTime)}).filter({ stopTime ->- // Actuator stop time attribute is present and value (in seconds) is in the past+ // Actuator stop time attribute is present and value (in seconds) is not zero and in the paststopTime.flatMap({ it.valueAsNumber }).map({- (it * 1000) < facts.clock.timestamp+ it > 0 && (it * 1000) < facts.clock.timestamp}).orElse(false)}).findFirst().map({ stopTime ->facts.bind("stopTime", stopTime.get())diff --git a/profile/README.md b/profile/README.mdindex 596d24af6..b92df0b27 100644--- a/profile/README.md+++ b/profile/README.md@@ -2,13 +2,13 @@The profiles extend each other, your project should also extend them:-* [deploy.yml](/deploy.yml) - The root profile with default settings, should be extended only+* [deploy.yml](/profile/deploy.yml) - The root profile with default settings, should be extended only- * [demo.yml](/demo.yml) - A transient demo stack for x86 hosts, copy and modify for permanent installation+ * [demo.yml](/profile/demo.yml) - A transient demo stack for x86 hosts, copy and modify for permanent installation- * [demo-rpi.yml](/demo-rpi.yml) - Settings for deployment on Raspberry Pi3 aarch32 host+ * [demo-rpi.yml](/profile/demo-rpi.yml) - Settings for deployment on Raspberry Pi3 aarch32 host- * [dev.yml](/dev.yml) - A transient development stack with all services, uses local bind mounts+ * [dev.yml](/profile/dev.yml) - A transient development stack with all services, uses local bind mounts- * [dev-testing.yml](/dev-testing.yml) - A transient development minimal services stack used to run build tests and work in IDE+ * [dev-testing.yml](/profile/dev-testing.yml) - A transient development minimal services stack used to run build tests and work in IDEdiff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovyindex 846fbe948..85c17a5f9 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy@@ -674,7 +674,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiapartment1Livingroom.id == managerDemoSetup.apartment1LivingroomIdapartment1Livingroom.name == "Living Room"def resultAttributes = apartment1Livingroom.getAttributesList()- resultAttributes.size() == 7+ resultAttributes.size() == 5def currentTemperature = apartment1Livingroom.getAttribute("currentTemperature").get()currentTemperature.getType().get() == AttributeType.TEMPERATURE_CELCIUS!currentTemperature.getValue().isPresent()@@ -685,7 +685,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrairesultMeta.stream().filter(isMetaNameEqualTo(RULE_STATE)).findFirst().get().getValueAsBoolean().get()resultMeta.stream().filter(isMetaNameEqualTo(STORE_DATA_POINTS)).findFirst().get().getValueAsBoolean().get()resultMeta.stream().filter(isMetaNameEqualTo(SHOW_ON_DASHBOARD)).findFirst().get().getValueAsBoolean().get()- resultMeta.stream().filter(isMetaNameEqualTo(FORMAT)).findFirst().get().getValueAsString().get() == "%0.1f C"+ resultMeta.stream().filter(isMetaNameEqualTo(FORMAT)).findFirst().get().getValueAsString().get() == "%0.1f° C"when: "an asset is retrieved by ID in a foreign realm"assetResource.get(null, managerDemoSetup.thingId)diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovyindex 8820fd082..1f41818b6 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy@@ -118,7 +118,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets.size() == 5assets.get(0).id == managerDemoSetup.apartment1Idassets.get(1).id == managerDemoSetup.apartment1LivingroomId- assets.get(1).getAttributesList().size() == 7+ assets.get(1).getAttributesList().size() == 5!assets.get(1).getAttribute("motionSensor").isPresent()!assets.get(1).getAttribute("currentTemperature").get().getValue().isPresent()assets.get(1).getAttribute("currentTemperature").get().meta.size() == 1@@ -167,7 +167,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets[1].tenantDisplayName == nullassets[1].coordinates == nullassets[1].path == null- assets[1].getAttributesList().size() == 8+ assets[1].getAttributesList().size() == 7assets[1].getAttribute("ventilationAuto").isPresent()assets[1].getAttribute("ventilationLevel").isPresent()assets[1].getAttribute("alarmEnabled").isPresent()@@ -175,7 +175,6 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets[1].getAttribute("autoSceneSchedule").isPresent()assets[1].getAttribute("lastExecutedScene").isPresent()assets[1].getAttribute("presenceDetected").isPresent()- assets[1].getAttribute("lastDetectedScene").isPresent()assets[1].getAttribute("alarmEnabled").get().meta.size() == 1assets[1].getAttribute("alarmEnabled").get().getMetaItem(AssetMeta.LABEL).isPresent()assets[1].getAttribute("alarmEnabled").get().getLabelOrName().get() == "Alarm enabled"@@ -408,7 +407,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets.size() == 5assets.get(0).id == managerDemoSetup.apartment1Idassets.get(1).id == managerDemoSetup.apartment1LivingroomId- assets.get(1).getAttributesList().size() == 7+ assets.get(1).getAttributesList().size() == 5!assets.get(1).getAttribute("currentTemperature").get().getValue().isPresent()assets.get(1).getAttribute("currentTemperature").get().meta.size() == 6!assets.get(1).getAttribute("targetTemperature").get().getValue().isPresent()@@ -601,7 +600,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {asset.getAttribute("co2Level").isPresent()asset.getAttribute("co2Level").get().meta.size() == 11asset.getAttribute("lastPresenceDetected").isPresent()- asset.getAttribute("lastPresenceDetected").get().meta.size() == 3+ asset.getAttribute("lastPresenceDetected").get().meta.size() == 2asset.getAttribute("motionSensor").isPresent()asset.getAttribute("motionSensor").get().meta.size() == 7@@ -626,11 +625,10 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {asset.tenantDisplayName == keycloakDemoSetup.customerATenant.displayNameasset.coordinates.length == 2asset.path != null- asset.getAttributesList().size() == 2+ asset.getAttributesList().size() == 1asset.getAttribute("co2Level").isPresent()asset.getAttribute("co2Level").get().meta.size() == 8- asset.getAttribute("lastPresenceDetected").isPresent()- asset.getAttribute("lastPresenceDetected").get().meta.size() == 2+ !asset.getAttribute("lastPresenceDetected").isPresent()!asset.getAttribute("motionSensor").isPresent()when: "a query is executed to select an asset with an attribute of a certain value"diff --git a/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy b/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovyindex c0f43dbd9..4e0ea8ca1 100644--- a/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy+++ b/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy@@ -76,11 +76,11 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gwwhen: "a client websocket connection and attached event bus and service"def accessToken = {authenticate(- container,- MASTER_REALM,- KEYCLOAK_CLIENT_ID,- MASTER_REALM_ADMIN_USER,- getString(container.getConfig(), SETUP_ADMIN_PASSWORD, SETUP_ADMIN_PASSWORD_DEFAULT)+ container,+ MASTER_REALM,+ KEYCLOAK_CLIENT_ID,+ MASTER_REALM_ADMIN_USER,+ getString(container.getConfig(), SETUP_ADMIN_PASSWORD, SETUP_ADMIN_PASSWORD_DEFAULT)).token}List<SharedEvent> collectedSharedEvents = []@@ -94,7 +94,7 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gwand: "an existing protocol configuration is disabled"def agent = assetStorageService.find(managerDemoSetup.agentId, true)agent.getAttribute(managerDemoSetup.agentProtocolConfigName).get().addMeta(- new MetaItem(AssetMeta.DISABLED)+ new MetaItem(AssetMeta.DISABLED))agent = assetStorageService.merge(agent)@@ -121,14 +121,14 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gwand: "the existing protocol configuration is re-enabled"agent.getAttribute(managerDemoSetup.agentProtocolConfigName).get().getMeta().removeIf(- isMetaNameEqualTo(AssetMeta.DISABLED)+ isMetaNameEqualTo(AssetMeta.DISABLED))agent = assetStorageService.merge(agent)then: "the protocol should be CONNECTED but no new events should have been received"conditions.eventually {assert agentService.getProtocolConnectionStatus(- new AttributeRef(managerDemoSetup.agentId, managerDemoSetup.agentProtocolConfigName)+ new AttributeRef(managerDemoSetup.agentId, managerDemoSetup.agentProtocolConfigName)) == ConnectionStatus.CONNECTEDassert collectedSharedEvents.isEmpty()}@@ -193,21 +193,22 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gwand: "an internal attribute event subscription is made"List<AttributeEvent> internalReceivedEvents = []internalClientEventService.getEventSubscriptions().update(- ClientEventTest.class.getName(),- new EventSubscription<>(- AttributeEvent.class,- new AttributeEvent.EntityIdFilter(managerDemoSetup.thingId),- {attributeEvent ->- internalReceivedEvents.add(attributeEvent as AttributeEvent)- }- ))+ ClientEventTest.class.getName(),+ false,+ new EventSubscription<>(+ AttributeEvent.class,+ new AttributeEvent.EntityIdFilter(managerDemoSetup.thingId),+ { attributeEvent ->+ internalReceivedEvents.add(attributeEvent as AttributeEvent)+ }+ ))and: "the subscribed asset is modified"def currentValue = asset.getAttribute(managerDemoSetup.thingLightToggleAttributeName).get().getValueAsBoolean().get()assetProcessingService.sendAttributeEvent(new AttributeEvent(- managerDemoSetup.thingId,- managerDemoSetup.thingLightToggleAttributeName,- Values.create(!currentValue)))+ managerDemoSetup.thingId,+ managerDemoSetup.thingLightToggleAttributeName,+ Values.create(!currentValue)))// TODO: Only 1 attribute event should reach the subscribers belowthen: "an attribute event should have been received by the internal subscriber"diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovyindex 50dc48ab8..7e6ac9cb9 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy@@ -124,7 +124,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCoassert alerts[0].message.startsWith("Aanwezigheid in Living Room")assert alerts[0].actions.length() == 2assert alerts[0].actions.getObject(0).orElse(null) == new AlertAction("Details", ActionType.LINK).objectValue- assert alerts[0].appUrl == "#/Veilig"+ assert alerts[0].appUrl == "#security"assert alerts[0].actions.getObject(1).orElse(null) == new AlertAction("Alarm uit", ActionType.ACTUATOR, managerDemoSetup.apartment1Id, "alarmEnabled", Values.create(false).toJson()).objectValue}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovyindex 27dc60d54..edc21e335 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovy@@ -200,6 +200,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon)simulatorProtocol.putValue(motionSensorTrigger)+ /* See rules, this leads to many false negatives when windows are open in the roomthen: "presence should not be detected"new PollingConditions(initialDelay: 3, timeout: 5, delay: 1).eventually {def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)@@ -229,6 +230,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConadvancePseudoClock(5, MINUTES, container)}+ */then: "presence should be detected and the last motion sensor trigger is the last detected timestamp"conditions.eventually {@@ -237,13 +239,40 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConassert roomAsset.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected}- when: "motion sensor is not triggered (nobody moving in the room but maybe present)"+ when: "motion sensor is not triggered (someone might be resting in the room)"def motionSensorNoTrigger = new AttributeEvent(managerDemoSetup.apartment1LivingroomId, "motionSensor", Values.create(0))simulatorProtocol.putValue(motionSensorNoTrigger)- and: "there is no CO2 level increase for a while (nobody present in the room)"+ and: "the CO2 level increases (someone breathing in the room)"+ // The CO2 level increments 3 times, 5 minutes apart+ for (i in 1..3) {++ def co2LevelIncrement = new AttributeEvent(+ managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(400 + i)+ )+ simulatorProtocol.putValue(co2LevelIncrement)++ // Wait for event to be processed+ conditions.eventually {+ assert apartment1Engine.assetEvents.any() {+ it.fact.matches(co2LevelIncrement, SENSOR, true)+ }+ assert noEventProcessedIn(assetProcessingService, 500)+ }++ advancePseudoClock(5, MINUTES, container)+ }++ then: "presence should be detected and the last motion sensor trigger is the last detected timestamp"+ conditions.eventually {+ def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)+ assert roomAsset.getAttribute("presenceDetected").get().getValueAsBoolean().get()+ assert roomAsset.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected+ }++ when: "there is no CO2 level increase for a while (nobody resting in the room)"advancePseudoClock(20, MINUTES, container)then: "presence should be gone but the last timestamp still available"@@ -257,39 +286,39 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConstopContainer(container)}- /* TODO Migrate to JS, didn't compile even with Drools- def "Presence prediction rules compilation"() {-- given: "the container environment is started"- def conditions = new PollingConditions(timeout: 100, delay: 1)- def serverPort = findEphemeralPort()- def container = startContainerWithPseudoClock(defaultConfig(serverPort), defaultServices())- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)- def rulesService = container.getService(RulesService.class)- def assetStorageService = container.getService(AssetStorageService.class)- def rulesetStorageService = container.getService(RulesetStorageService.class)- def simulatorProtocol = container.getService(SimulatorProtocol.class)- RulesEngine apartment1Engine = null+ /* TODO Migrate to JS, didn't compile even with Drools+ def "Presence prediction rules compilation"() {++ given: "the container environment is started"+ def conditions = new PollingConditions(timeout: 100, delay: 1)+ def serverPort = findEphemeralPort()+ def container = startContainerWithPseudoClock(defaultConfig(serverPort), defaultServices())+ def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)+ def rulesService = container.getService(RulesService.class)+ def assetStorageService = container.getService(AssetStorageService.class)+ def rulesetStorageService = container.getService(RulesetStorageService.class)+ def simulatorProtocol = container.getService(SimulatorProtocol.class)+ RulesEngine apartment1Engine = null++ and: "some rules"+ Ruleset ruleset = new AssetRuleset(+ "Demo Apartment - Presence Detection with motion sensor",+ managerDemoSetup.apartment1Id,+ getClass().getResource("/demo/rules/DemoApartmentPresencePrediction.drl").text+ )+ rulesetStorageService.merge(ruleset)- and: "some rules"- Ruleset ruleset = new AssetRuleset(- "Demo Apartment - Presence Detection with motion sensor",- managerDemoSetup.apartment1Id,- getClass().getResource("/demo/rules/DemoApartmentPresencePrediction.drl").text- )- rulesetStorageService.merge(ruleset)+ expect: "the rule engines to become available and be running"+ conditions.eventually {+ apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)+ assert apartment1Engine != null+ assert apartment1Engine.isRunning()+ // assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1+ }- expect: "the rule engines to become available and be running"- conditions.eventually {- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)- assert apartment1Engine != null- assert apartment1Engine.isRunning()-// assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1+ cleanup: "the server should be stopped"+ stopContainer(container)}-- cleanup: "the server should be stopped"- stopContainer(container)- }- */+ */}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovyindex 73d5f7799..a6ca6857b 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy@@ -20,6 +20,8 @@ import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STclass ResidenceSmartSwitchTest extends Specification implements ManagerContainerTrait {+ static final double CYCLE_TIME_SECONDS = 2.5 * 60 * 60+def "Set mode ON_AT and begin/end cycle time in future"() {given: "the container environment is started"@@ -108,8 +110,8 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerdef kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "ON_AT"assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)oneMinuteInFutureMillis- assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == oneMinuteInFutureMillis/1000- assert kitchen.getAttribute("smartSwitchStopTimeA").get().getValueAsNumber().get() == (oneMinuteInFutureMillis/1000) + (2.5 * 60 * 60) + 60+ assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == Math.floor((double)oneMinuteInFutureMillis/1000)+ assert kitchen.getAttribute("smartSwitchStopTimeA").get().getValueAsNumber().get() == Math.floor((double)oneMinuteInFutureMillis/1000) + CYCLE_TIME_SECONDSassert kitchen.getAttribute("smartSwitchEnabledA").get().getValueAsNumber().get() == 1assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchBeginEndB").get().getValue().isPresent()@@ -131,9 +133,9 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerdef kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "NOW_ON"assert !kitchen.getAttribute("smartSwitchBeginEndA").get().getValue().isPresent()- assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()- assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()- assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()+ assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == 0+ assert kitchen.getAttribute("smartSwitchStopTimeA").get().getValueAsNumber().get() == 0+ assert kitchen.getAttribute("smartSwitchEnabledA").get().getValueAsNumber().get() == 0assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchBeginEndB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()@@ -248,7 +250,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerstopContainer(container)}- def "Set mode READY_AT and begin/end cycle time in past"() {+ def "Set mode READY_AT and begin/end cycle time in future"() {given: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 1)@@ -318,21 +320,20 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerassert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()}- when: "begin/end cycle time is set to past"- long fiveMinutesInPastMillis = getClockTimeOf(container) - (5 * 60 * 1000)+ when: "begin/end cycle time is set to future"+ long threeHoursInFutureMillis = getClockTimeOf(container) + (3 * 60 * 60 * 1000)assetProcessingService.sendAttributeEvent(- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInPastMillis))+ new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(threeHoursInFutureMillis)))noEventProcessedIn(assetProcessingService, 500)- then: "mode should be READY_AT and actuator not enabled with correct start/stop time"+ then: "mode should be READY_AT and actuator enabled with correct start/stop time"conditions.eventually {- def expectedTimeMillis = getClockTimeOf(container) + ((2.5 * 60 * 60) + 60) * 1000def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"- assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)expectedTimeMillis- assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == (double)getClockTimeOf(container)/1000- assert kitchen.getAttribute("smartSwitchStopTimeA").get().getValueAsNumber().get() == (double)(expectedTimeMillis/1000)+ assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)threeHoursInFutureMillis+ assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == Math.floor((double)getClockTimeOf(container)/1000)+ assert kitchen.getAttribute("smartSwitchStopTimeA").get().getValueAsNumber().get() == Math.floor((double)(threeHoursInFutureMillis/1000))assert kitchen.getAttribute("smartSwitchEnabledA").get().getValueAsNumber().get() == 1assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()@@ -352,16 +353,214 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerdef kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "NOW_ON"assert !kitchen.getAttribute("smartSwitchBeginEndA").get().getValue().isPresent()+ assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == 0+ assert kitchen.getAttribute("smartSwitchStopTimeA").get().getValueAsNumber().get() == 0+ assert kitchen.getAttribute("smartSwitchEnabledA").get().getValueAsNumber().get() == 0+ assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchBeginEndB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchBeginEndC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()+ }++ cleanup: "the server should be stopped"+ stopContainer(container)+ }++ def "Set mode READY_AT and begin/end cycle time in past"() {++ given: "the container environment is started"+ def conditions = new PollingConditions(timeout: 10, delay: 1)+ def serverPort = findEphemeralPort()+ def container = startContainerWithPseudoClock(defaultConfig(serverPort), defaultServices())+ def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)+ def rulesService = container.getService(RulesService.class)+ def assetStorageService = container.getService(AssetStorageService.class)+ def assetProcessingService = container.getService(AssetProcessingService.class)+ def rulesetStorageService = container.getService(RulesetStorageService.class)+ RulesEngine apartment1Engine = null++ and: "some rules"+ Ruleset ruleset = new AssetRuleset(+ "Demo Apartment - Smart Start",+ managerDemoSetup.apartment1Id,+ getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text,+ Ruleset.Lang.GROOVY+ )+ rulesetStorageService.merge(ruleset)++ expect: "the rule engines to become available and be running"+ conditions.eventually {+ apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)+ assert apartment1Engine != null+ assert apartment1Engine.isRunning()+ assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1+ }++ and: "smart switches should be off"+ conditions.eventually {+ def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)+ assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()+ }++ when: "mode is set to READY_AT"+ assetProcessingService.sendAttributeEvent(+ new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))+ )+ noEventProcessedIn(assetProcessingService, 500)++ then: "mode should be READY_AT but actuator not enabled"+ conditions.eventually {+ def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)+ assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"+ assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()+ }++ when: "begin/end cycle time is set to past"+ long fiveMinutesInPastMillis = getClockTimeOf(container) - (5 * 60 * 1000)+ assetProcessingService.sendAttributeEvent(+ new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInPastMillis))+ )+ noEventProcessedIn(assetProcessingService, 500)++ then: "mode should be READY_AT but actuator not enabled"+ conditions.eventually {+ def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)+ assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"+ assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)fiveMinutesInPastMillis+ assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()+ }++ cleanup: "the server should be stopped"+ stopContainer(container)+ }++ def "Set mode READY_AT and insufficient begin/end cycle time"() {++ given: "the container environment is started"+ def conditions = new PollingConditions(timeout: 10, delay: 1)+ def serverPort = findEphemeralPort()+ def container = startContainerWithPseudoClock(defaultConfig(serverPort), defaultServices())+ def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)+ def rulesService = container.getService(RulesService.class)+ def assetStorageService = container.getService(AssetStorageService.class)+ def assetProcessingService = container.getService(AssetProcessingService.class)+ def rulesetStorageService = container.getService(RulesetStorageService.class)+ RulesEngine apartment1Engine = null++ and: "some rules"+ Ruleset ruleset = new AssetRuleset(+ "Demo Apartment - Smart Start",+ managerDemoSetup.apartment1Id,+ getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text,+ Ruleset.Lang.GROOVY+ )+ rulesetStorageService.merge(ruleset)++ expect: "the rule engines to become available and be running"+ conditions.eventually {+ apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)+ assert apartment1Engine != null+ assert apartment1Engine.isRunning()+ assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1+ }++ and: "smart switches should be off"+ conditions.eventually {+ def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)+ assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()+ }++ when: "mode is set to READY_AT"+ assetProcessingService.sendAttributeEvent(+ new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))+ )+ noEventProcessedIn(assetProcessingService, 500)++ then: "mode should be READY_AT but actuator not enabled"+ conditions.eventually {+ def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)+ assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"+ assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()+ assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()+ }++ when: "begin/end cycle time is set insufficient future time"+ long fiveMinutesInFuture = getClockTimeOf(container) + (5 * 60 * 1000)+ assetProcessingService.sendAttributeEvent(+ new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInFuture))+ )+ noEventProcessedIn(assetProcessingService, 500)++ then: "mode should be READY_AT but actuator not enabled"+ conditions.eventually {+ def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)+ assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"+ assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)fiveMinutesInFutureassert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledA").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchModeB").get().getValue().isPresent()- assert !kitchen.getAttribute("smartSwitchBeginEndB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStartTimeB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStopTimeB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledB").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchModeC").get().getValue().isPresent()- assert !kitchen.getAttribute("smartSwitchBeginEndC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStartTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()