Skip to content

armgit / core

Public Imported from GitHub
0

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

Feature/ci cd (#605)

Rich Turnerf8e6ece8d0fa
diff --git a/.ci_cd/README.md b/.ci_cd/README.md
new file mode 100644
index 000000000..dd22cd7ba
--- /dev/null
+++ b/.ci_cd/README.md
@@ -0,0 +1,26 @@
+# CI/CD workflow files
+The files in this directory are used by the [deploy workflow](../.github/workflows/deploy.yml) which provides a standard
+github workflow for deploying this repo on a linux host via SSH.
+
+# `/env` Directory
+Environment variable files that will be loaded into the workflow to configure the behaviour of the workflow and are also
+passed through to the host and loaded whenever remote commands are executed via SSH on the host.
+
+The naming convention should be as follows:
+
+* `env/.env` - File containing environment variables that will be loaded for any deployment
+* `${environment}.env` - File containing environment specific environment variables will be loaded if `environment` input
+is set for the workflow run; these will be loaded after the `env` file and so can override any value defined there as well
+as being able to add new environment specific values
+
+# `host_init` Directory
+Contains scripts/files required to initialise the host ready for running the stack (e.g. download map tiles etc.);
+the workflow looks for one of the following bash scripts (in priority order):
+
+* `host_init/${environment}.sh` - Bash script for environment specific host initialisation
+* `host_init/init.sh` - Bash script that can be used by any environment as a fallback if no environment specific script
+exists
+
+If an initialisation script is found then the entire `host_init` directory will be copied to the host and the script
+will be executed; by copying the entire directory additional files can be included and called from the initialisation
+script as required.
diff --git a/.ci_cd/env/.env b/.ci_cd/env/.env
new file mode 100644
index 000000000..c8f23cecd
--- /dev/null
+++ b/.ci_cd/env/.env
@@ -0,0 +1 @@
+CLEAN_INSTALL=true
diff --git a/.ci_cd/env/.gitignore b/.ci_cd/env/.gitignore
new file mode 100644
index 000000000..e69de29bb
diff --git a/gitlab-ci/README.md b/.ci_cd/gitlab-ci/README.md
similarity index 100%
rename from gitlab-ci/README.md
rename to .ci_cd/gitlab-ci/README.md
diff --git a/gitlab-ci/aws-cloudformation.template.arm64.yml b/.ci_cd/gitlab-ci/aws-cloudformation.template.arm64.yml
similarity index 100%
rename from gitlab-ci/aws-cloudformation.template.arm64.yml
rename to .ci_cd/gitlab-ci/aws-cloudformation.template.arm64.yml
diff --git a/gitlab-ci/aws-mail.py b/.ci_cd/gitlab-ci/aws-mail.py
similarity index 100%
rename from gitlab-ci/aws-mail.py
rename to .ci_cd/gitlab-ci/aws-mail.py
diff --git a/gitlab-ci/gitlab-ci-submodule.yml b/.ci_cd/gitlab-ci/gitlab-ci-submodule.yml
similarity index 100%
rename from gitlab-ci/gitlab-ci-submodule.yml
rename to .ci_cd/gitlab-ci/gitlab-ci-submodule.yml
diff --git a/.ci_cd/host_init/.gitignore b/.ci_cd/host_init/.gitignore
new file mode 100644
index 000000000..e69de29bb
diff --git a/mvp/aws-cloudformation.template.yml b/.ci_cd/mvp/aws-cloudformation.template.yml
similarity index 100%
rename from mvp/aws-cloudformation.template.yml
rename to .ci_cd/mvp/aws-cloudformation.template.yml
diff --git a/mvp/aws-ubuntu-cloudformation.template.yml b/.ci_cd/mvp/aws-ubuntu-cloudformation.template.yml
similarity index 100%
rename from mvp/aws-ubuntu-cloudformation.template.yml
rename to .ci_cd/mvp/aws-ubuntu-cloudformation.template.yml
diff --git a/mvp/mvp-docker-compose-awslogs.yml b/.ci_cd/mvp/mvp-docker-compose-awslogs.yml
similarity index 97%
rename from mvp/mvp-docker-compose-awslogs.yml
rename to .ci_cd/mvp/mvp-docker-compose-awslogs.yml
index ba2ef9e18..b6db7ae03 100644
--- a/mvp/mvp-docker-compose-awslogs.yml
+++ b/.ci_cd/mvp/mvp-docker-compose-awslogs.yml
@@ -99,8 +99,8 @@ services:
SETUP_EMAIL_USER: ${EMAIL_USER}
SETUP_EMAIL_PASSWORD: ${EMAIL_PASSWORD}
SETUP_EMAIL_PORT: ${SETUP_EMAIL_PORT:-587}
- SETUP_EMAIL_FROM_KEYCLOAK: no-reply@${DOMAINNAME}
- SETUP_EMAIL_FROM_DEFAULT: admin@${DOMAINNAME}
+ SETUP_EMAIL_TO: ${SETUP_EMAIL_TO}
+ SETUP_EMAIL_FROM: ${SETUP_EMAIL_FROM}
<<: *awslogs
keycloak:
diff --git a/mvp/mvp-docker-compose.yml b/.ci_cd/mvp/mvp-docker-compose.yml
similarity index 100%
rename from mvp/mvp-docker-compose.yml
rename to .ci_cd/mvp/mvp-docker-compose.yml
diff --git a/swarm/README.md b/.ci_cd/swarm/README.md
similarity index 100%
rename from swarm/README.md
rename to .ci_cd/swarm/README.md
diff --git a/swarm/aws-swarm-docker-compose.yml b/.ci_cd/swarm/aws-swarm-docker-compose.yml
similarity index 100%
rename from swarm/aws-swarm-docker-compose.yml
rename to .ci_cd/swarm/aws-swarm-docker-compose.yml
diff --git a/swarm/docker-swarm-template.yml b/.ci_cd/swarm/docker-swarm-template.yml
similarity index 100%
rename from swarm/docker-swarm-template.yml
rename to .ci_cd/swarm/docker-swarm-template.yml
diff --git a/swarm/k8s.yml b/.ci_cd/swarm/k8s.yml
similarity index 100%
rename from swarm/k8s.yml
rename to .ci_cd/swarm/k8s.yml
diff --git a/swarm/kube-docker-compose.yml b/.ci_cd/swarm/kube-docker-compose.yml
similarity index 100%
rename from swarm/kube-docker-compose.yml
rename to .ci_cd/swarm/kube-docker-compose.yml
diff --git a/swarm/minikube/keycloak-deployment.yaml b/.ci_cd/swarm/minikube/keycloak-deployment.yaml
similarity index 100%
rename from swarm/minikube/keycloak-deployment.yaml
rename to .ci_cd/swarm/minikube/keycloak-deployment.yaml
diff --git a/swarm/minikube/keycloak-service.yaml b/.ci_cd/swarm/minikube/keycloak-service.yaml
similarity index 100%
rename from swarm/minikube/keycloak-service.yaml
rename to .ci_cd/swarm/minikube/keycloak-service.yaml
diff --git a/swarm/minikube/manager-deployment.yaml b/.ci_cd/swarm/minikube/manager-deployment.yaml
similarity index 100%
rename from swarm/minikube/manager-deployment.yaml
rename to .ci_cd/swarm/minikube/manager-deployment.yaml
diff --git a/swarm/minikube/openremote.yml b/.ci_cd/swarm/minikube/openremote.yml
similarity index 100%
rename from swarm/minikube/openremote.yml
rename to .ci_cd/swarm/minikube/openremote.yml
diff --git a/swarm/minikube/postgresql-data-persistentvolumeclaim.yaml b/.ci_cd/swarm/minikube/postgresql-data-persistentvolumeclaim.yaml
similarity index 100%
rename from swarm/minikube/postgresql-data-persistentvolumeclaim.yaml
rename to .ci_cd/swarm/minikube/postgresql-data-persistentvolumeclaim.yaml
diff --git a/swarm/minikube/postgresql-deployment.yaml b/.ci_cd/swarm/minikube/postgresql-deployment.yaml
similarity index 100%
rename from swarm/minikube/postgresql-deployment.yaml
rename to .ci_cd/swarm/minikube/postgresql-deployment.yaml
diff --git a/swarm/minikube/proxy-data-persistentvolumeclaim.yaml b/.ci_cd/swarm/minikube/proxy-data-persistentvolumeclaim.yaml
similarity index 100%
rename from swarm/minikube/proxy-data-persistentvolumeclaim.yaml
rename to .ci_cd/swarm/minikube/proxy-data-persistentvolumeclaim.yaml
diff --git a/swarm/minikube/proxy-deployment.yaml b/.ci_cd/swarm/minikube/proxy-deployment.yaml
similarity index 100%
rename from swarm/minikube/proxy-deployment.yaml
rename to .ci_cd/swarm/minikube/proxy-deployment.yaml
diff --git a/swarm/minikube/proxy-service.yaml b/.ci_cd/swarm/minikube/proxy-service.yaml
similarity index 100%
rename from swarm/minikube/proxy-service.yaml
rename to .ci_cd/swarm/minikube/proxy-service.yaml
diff --git a/swarm/swarm-docker-compose.arm64.yml b/.ci_cd/swarm/swarm-docker-compose.arm64.yml
similarity index 100%
rename from swarm/swarm-docker-compose.arm64.yml
rename to .ci_cd/swarm/swarm-docker-compose.arm64.yml
diff --git a/swarm/swarm-docker-compose.yml b/.ci_cd/swarm/swarm-docker-compose.yml
similarity index 100%
rename from swarm/swarm-docker-compose.yml
rename to .ci_cd/swarm/swarm-docker-compose.yml
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..2c7d17083
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,7 @@
+version: 2
+updates:
+ # Maintain dependencies for GitHub Actions
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 1368fc8f2..524bfb0c1 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -1,50 +1,85 @@
# Build, test and conditionally publish the manager docker image using the included gradle wrapper
name: CI/CD
-concurrency: ci
on:
+ # Push excluding tags and workflow changes
push:
+ branches:
+ - '**'
+ tags-ignore:
+ - '*.*'
paths-ignore:
- '.github/**'
+ - '**/*.md'
+
+ # When a release is published
+ release:
+ types: [published]
workflow_dispatch:
env:
- PLATFORM: linux/amd64,linux/aarch64
+ PLATFORMS: linux/amd64,linux/aarch64
jobs:
+ dockertag:
+ name: Determine docker tag
+ runs-on: ubuntu-latest
+
+ outputs:
+ tag: ${{ steps.dockertag.outputs.tag }}
+
+ steps:
+ - name: Cancel Previous Runs
+ uses: styfle/[email protected]
+ with:
+ access_token: ${{ github.token }}
+
+ - name: Set docker tag based on branch and trigger
+ uses: kanga333/variable-mapper@master
+ with:
+ key: "${{ github.ref_name }}"
+ map: |
+ {
+ "master": {
+ "TAG": "latest"
+ },
+ "develop": {
+ "TAG": "develop"
+ }
+ }
+
+ - name: Determine docker image tag name
+ run: echo "TAG=${{ github.event.release.tag_name || env.TAG }}" >> $GITHUB_ENV
+
+ - id: dockertag
+ run: echo "::set-output name=tag::${{ env.TAG }}"
build:
+ name: Build & Test
+ needs: [dockertag]
+
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
-
- - name: Set up JDK 17
- uses: actions/setup-java@v1
- with:
- java-version: 17
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
-
- - name: Extract docker image IDs
- run: |
- echo ::set-env name=POSTGRES_ID::$(docker-compose -f profile\dev-testing.yml images -q -- postgresql)
- echo ::set-env name=KEYCLOAK_ID::$(docker-compose -f profile\dev-testing.yml images -q -- keycloak)
+ - name: Checkout
+ uses: actions/checkout@v2
- - name: Gradle cache
- id: gradle-cache
- uses: actions/cache@v2
+ - name: Set up JDK 17 and gradle cache
+ id: java
+ uses: actions/setup-java@v2
with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- restore-keys: |
- ${{ runner.os }}-gradle-
+ distribution: 'temurin'
+ java-version: '17'
+ cache: 'gradle'
+
+ - name: Grant execute permission for gradlew and make image-cache
+ run: |
+ chmod +x gradlew
+ mkdir -p ~/image-cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
@@ -55,128 +90,117 @@ jobs:
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+ key: ${{ runner.os }}-yarn---${{ hashFiles('**/yarn.lock') }}
restore-keys: |
- ${{ runner.os }}-yarn-
+ ${{ runner.os }}-yarn---
- - name: Docker postgres image cache
- uses: actions/cache@v2
- id: docker-postgres-cache
- with:
- path: |
- postgres.tar.gz
- key: ${{ runner.os }}-postgres-image--${{ env.POSTGRES_ID }}
- restore-keys: |
- ${{ runner.os }}-postgres-image--${{ env.POSTGRES_ID }}
-
- - name: Docker keycloak image cache
+ - name: Docker image cache
uses: actions/cache@v2
- id: docker-keycloak-cache
+ id: docker-cache
with:
path: |
- keycloak.tar.gz
- key: ${{ runner.os }}-keycloak-image--${{ env.KEYCLOAK_ID }}
+ ~/image-cache
+ key: ${{ runner.os }}-docker---${{ hashFiles('profile/dev-testing.yml') }}
restore-keys: |
- ${{ runner.os }}-keycloak-image--${{ env.KEYCLOAK_ID }}
+ ${{ runner.os }}-docker---
- - name: Output info
+ - name: Output build info
run: |
echo "************************************************************"
echo "************** BUILD INFO *******************"
echo "************************************************************"
- echo "Yarn version: ${yarn -v}"
- echo "dev-testing.yml images: ${docker-compose -f profile/dev-testing.yml images}"
- echo "Gradle cache: ${{ steps.gradle-cache.outputs.cache-hit }}"
- echo "Yarn cache: ${{ steps.yarn-cache.outputs.cache-hit }}"
- echo "Docker postgres from cache: ${{ steps.docker-keycloak-cache.outputs.cache-hit }}"
- echo "Docker keycloak from cache: ${{ steps.docker-keycloak-cache.outputs.cache-hit }}"
+ echo "Java version: $(java --version)"
+ echo "Yarn version: $(yarn -v)"
+ echo "Node version: $(node -v)"
+ echo "Gradle cache: ${{ steps.java.outputs.cache-hit == 'true' }}"
+ echo "Yarn cache: ${{ steps.yarn-cache.outputs.cache-hit == 'true' }}"
+ echo "Docker cache: ${{ steps.docker-cache.outputs.cache-hit == 'true' }}"
echo "************************************************************"
echo "************************************************************"
-
-# - name: Build
-# run: ./gradlew installDist
-
-# - name: Test
-# run: ./gradlew test
-
-# - name: Share build artifacts
-# uses: actions/upload-artifact@v2
-# with:
-# name: build-output
-# path: |
-# manager/build
-# deployment/build
-# retention-days: 1
-
-
- test_ui:
- runs-on: ubuntu-latest
- needs: [image_manager]
- steps:
- - uses: actions/setup-python@v2
+ - name: Check for cached docker images
+ id: check_docker
+ uses: andstor/file-existence-action@v1
with:
- python-version: 3.8
- - name: install openremote-cli
+ files: ", ~/image-cache/postgres.tar.gz"
+
+ - name: Load cached docker images
+ if: steps.docker-cache.outputs.cache-hit == 'true'
run: |
- pip3 install openremote-cli
- openremote-cli -V -t
- - name: deploy openremote stack on localhost and run UI test
+ docker load < ~/image-cache/keycloak.tar.gz
+ docker load < ~/image-cache/postgres.tar.gz
+
+ - name: Pull docker images
+ if: steps.docker-cache.outputs.cache-hit != 'true'
run: |
- wget -nc https://raw.githubusercontent.com/openremote/openremote/master/docker-compose.yml
- docker-compose up -d
- sleep 60
- docker ps
- # Login to manager and add weather agent asset
- or-test-http-rest --dnsname localhost --password secret -vv
- timeout-minutes: 30
+ docker-compose -f profile/dev-testing.yml pull
+ keycloak=$(docker images --filter 'reference=openremote/keycloak' --format "{{.Repository}}:{{.Tag}}")
+ postgres=$(docker images --filter 'reference=openremote/postgresql' --format "{{.Repository}}:{{.Tag}}")
+ docker save $keycloak | gzip > ~/image-cache/keycloak.tar.gz
+ docker save $postgres | gzip > ~/image-cache/postgres.tar.gz
+ ls -R ~/image-cache
+
+ - name: Start docker test services
+ run: docker-compose -f profile/dev-testing.yml up -d --no-build
+
+ - name: Run backend tests
+ run: ./gradlew build
+ timeout-minutes: 20
continue-on-error: true
+
+ - name: Prepare docker image
+ if: ${{ needs.dockertag.outputs.tag != '' }}
+ run: ./gradlew installDist
+ timeout-minutes: 10
+
+ ## TODO: Add UI tests to the pipeline
+ # Start manager
+ # Run UI tests with gradle
+
+ - name: Share build artifacts
+ if: ${{ needs.dockertag.outputs.tag != '' }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: dist-build
+ path: |
+ manager/build/install/manager
+ retention-days: 1
- test_staging_demo:
+
+ docker_image:
+ name: Build & push docker image
runs-on: ubuntu-latest
- needs: [image_manager]
+ needs: [dockertag, build]
+ if: ${{ needs.dockertag.outputs.tag != '' }}
+ env:
+ TAG: ${{ needs.dockertag.outputs.tag }}
+
steps:
- - uses: actions/setup-python@v2
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
with:
- python-version: 3.9
- - name: install openremote-cli
- run: |
- pip3 install openremote-cli
- openremote-cli -V -t
- - name: wait 10m for staging.demo new image update
- run: sleep 600
- - name: login staging.demo.openremote.io and wait for map
- run: openremote-cli manager --open -t --quit --quiet -v --dnsname staging.demo.openremote.io --password "${{ secrets.STAGING_DEMO_PASSWORD }}"
- continue-on-error: false
-
- image_manager:
- runs-on: ubuntu-latest
- needs: [build]
+ username: ${{ secrets.DOCKERHUB_USER }}
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
- steps:
- - uses: actions/checkout@v2
- - uses: n1hility/cancel-previous-runs@v2
+ - name: Download build artifacts
+ uses: actions/download-artifact@v2
with:
- token: ${{ secrets.GITHUB_TOKEN }}
+ name: dist-build
+ path: manager/build/install/manager
+
- name: set up QEMU
uses: docker/setup-qemu-action@v1
with:
- platforms: all
+ platforms: ${{ env.PLATFORMS }}
+
- name: install buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
install: true
- - name: available platforms
- run: echo ${{ steps.buildx.outputs.platforms }}
- - name: login to docker hub
- run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USER }}" --password-stdin
- - name: Download build artifacts
- uses: actions/download-artifact@v2
- with:
- name: dist-build
- - name: build and push images
+
+ - name: Build and push images
run: |
- docker build --push --platform $PLATFORM -t openremote/manager:latest manager/build/install/manager
+ docker build --push --platform $PLATFORMS -t openremote/manager:$TAG manager/build/install/manager
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index a0be10734..884d19432 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -1,5 +1,70 @@
-# Automatic or manual deployment of the stack using specified docker manager image tag from docker hub
-# or alternatively a git commit can be sepcified to build a custom manager image for deployment
+# Automatic or manual deployment of the stack using specified docker manager image tag from docker hub or alternatively
+# if not specified a commit specific image will be built using the git commit.
+#
+# This workflow supports custom projects https://github.com/openremote/custom-project (i.e. has openremote submodule)
+# as well as supporting a deployment directory directly within this repo (deployment/Dockerfile must exist); in this mode
+# a deployment image will also be built and loaded on the host (it is up to the loaded docker compose file to actually
+# use this deployment image via volume mappings).
+#
+# Trigger
+#
+# This workflow can be triggered manually or by a webhook; if triggered by a webhook then the payload must contain an
+# inputs object with the same keys as the workflow_dispatch inputs (note none of the inputs are required):
+#
+# Inputs:
+#
+# - environment - used to load the specified environment from github; this can then contain specific secrets to
+# override default values; these are overlaid on top of the repo and org secrets. It is also used
+# to load an environment specific env and/or host_init files from the repo and/or an environment
+# specific docker compose file
+# - host - FQDN for the host (default: env/secrets.HOST)
+# - ssh_user - SSH username (default: env/secrets.SSH_USER || root)
+# - ssh_password - SSH password (default: secrets.SSH_PASSWORD)
+# - ssh_port - SSH port (default: env/secrets.SSH_PORT || 22)
+# - password - Admin password to be set on deployment; sets the SETUP_ADMIN_PASSWORD env variable
+# (default: secrets.SETUP_ADMIN_PASSWORD || secret)
+# - manager_version - The docker tag to pull for the manager image; if not specified then the manager image
+# will be built using the checked out repo commit
+# - commit - Which commit or branch to checkout and use on this repo (default: branch on which workflow is executed)
+# - platform - The host platform architecture (default: env/secrets.PLATFORM || linux/amd64)
+#
+# Environment variables are loaded into the env context from the following files in the repo if they exist:
+#
+# .ci_cd/env/.env
+# .ci_cd/env/{environment}.env
+#
+# Env/Secrets:
+#
+# Secrets are loaded from the github environment corresponding to the environment input, these secrets are copied into
+# the env context; the combined env/secrets are then made available to the host during execution of docker compose
+# commands; so any env/secret configurable in the compose profile can be set in the env file and/or in the secrets
+# (secrets take priority); NOTE: sensitive values should only be stored as secrets so they are encrypted.
+#
+# The following env/secrets are supported to configure the way this workflow behaves:
+#
+# - HOST - Will be used if input host value is not set
+# - SSH_USER - Will be used if input ssh_user is not set
+# - SSH_PORT - Will be used if input ssh_port is not set
+# - SSH_PASSWORD - Will be used if input ssh_password is not set (should only be set as a secret)
+# - SSH_KEY - SSH private key (should only be set as a secret)
+# - MANAGER_VERSION - Will be used if input manager_version is not set
+# - CLEAN_INSTALL - Can be used to force clean the data before starting the stack
+# - COMPOSE_FILE - Use a specific compose file, must be the full path (e.g. profile/my-compose.yml);
+# if not specified and the file 'profile/{environment}.yml' exists then that will be
+# used otherwise fallback to 'docker-compose.yml' in the repo root.
+# - HOST_INIT_SCRIPT - name of the host initialisation (see below) script to execute on the host (just the
+# name no path or extension e.g. 'test' -> '.ci_cd/host_init/test.sh'; can be set to
+# 'NONE' to force no host initialisation even if files exist.
+#
+# Host initialisation
+#
+# To do host specific configuration (download map files etc.) files can be added to the '.ci_cd/host-init' directory
+# these will be copied to the host and the HOST_INIT_SCRIPT will be executed (if it is present in the repo); if
+# HOST_INIT_SCRIPT is set to 'NONE' no host initialisation will be done, if it is not set then the following files will
+# be checked in priority order:
+#
+# .ci_cd/host_init/{environment}.sh
+# .ci_cd/host_init/init.sh
name: Deploy
@@ -7,35 +72,411 @@ on:
# Manually request a deploy
workflow_dispatch:
inputs:
- managerTag:
- description: 'Manager docker tag to pull'
- managerCommit:
- description: 'Repo commit SHA to build'
- branch:
- description: 'Branch to use (or default)'
environment:
description: 'Environment to use (if any)'
host:
description: 'Host to deploy to'
+ ssh_user:
+ description: 'SSH Username'
+ ssh_port:
+ description: 'SSH port'
+ ssh_password:
+ description: 'SSH password'
password:
- description: 'Admin password to use'
-
-
+ description: 'Admin password override'
+ manager_version:
+ description: 'Manager docker tag to pull'
+ clean_install:
+ description: 'Delete data before starting'
+ type: boolean
+ commit:
+ description: 'Repo branch or commit SHA to use'
+ platform:
+ description: 'Host platform architecture'
+
# Docker push webhook trigger
repository_dispatch:
- types: [docker-push]
-
-env:
- PLATFORM: linux/amd64,linux/arm64
+ types: [ docker-push ]
jobs:
- config:
- name: Determine config
+ deploy:
runs-on: ubuntu-latest
-
+ environment:
+ name: ${{ github.event.inputs.environment }}
+
steps:
- - name: Check manager Tag
- if: github.event.inputs.tag_name != ''
- id: check-tag
- run: docker manifest inspect openremote/manager:${{ github.event.inputs.tag_name }} > /dev/null 2> /dev/null
+
+ - name: Checkout code
+ uses: actions/checkout@v2
+ with:
+ ref: ${{github.event.inputs.commit}}
+ submodules: recursive
+
+ - name: Check if env file exists
+ id: env-exists
+ run: |
+ if [ -f ".ci_cd/env/.env" ]; then
+ echo "::set-output name=value::true"
+ fi
+
+ - name: Check if environment specific env file exists
+ id: env-specific-exists
+ if: ${{ github.event.inputs.environment != '' }}
+ run: |
+ if [ -f ".ci_cd/env/$ENVIRONMENT.env" ]; then
+ echo "::set-output name=value::true"
+ fi
+ env:
+ ENVIRONMENT: ${{ github.event.inputs.environment }}
+
+ - name: Load env file
+ if: ${{ steps.env-exists.outputs.value == 'true' }}
+ uses: cardinalby/export-env-action@v1
+ with:
+ envFile: '.ci_cd/env/.env'
+
+ - name: Load environment specific env file
+ if: ${{ steps.env-specific-exists.outputs.value == 'true' }}
+ uses: cardinalby/export-env-action@v1
+ with:
+ envFile: '.ci_cd/env/${{ github.event.inputs.environment }}.env'
+
+ - name: Output secrets to ENV ready for overwrites from inputs
+ shell: python
+ run: |
+ import json
+ import os
+ import sys
+
+ secrets = json.loads(os.getenv('secret'))
+ for key, value in secrets.items():
+ print(f"Setting {key} ...")
+ lines = len(value.split("\n"))
+ if lines > 1:
+ os.system(f"echo '{key}<<EOF' >> $GITHUB_ENV")
+ os.system(f"echo '{value}' >> $GITHUB_ENV")
+ os.system("echo 'EOF' >> $GITHUB_ENV")
+ else:
+ os.system(f"echo '{key}={value}' >> $GITHUB_ENV")
+ env:
+ secret: ${{ toJSON(secrets) }}
+
+ - name: Determine host name
+ id: host-name
+ run: echo "HOST=${{ github.event.inputs.host || env.HOST }}" >> $GITHUB_ENV
+
+ - name: Host not set
+ if: ${{ env.HOST == '' }}
+ run: exit 1
+
+ - name: Determine SSH username
+ run: echo "SSH_USER=${{ github.event.inputs.ssh_user || env.SSH_USER || 'root' }}" >> $GITHUB_ENV
+
+ - name: Determine SSH port
+ run: echo "SSH_PORT=${{ github.event.inputs.ssh_port || env.SSH_PORT || '22' }}" >> $GITHUB_ENV
+
+ - name: Determine SSH password
+ run: echo "SSH_PASSWORD=${{ github.event.inputs.ssh_password || env.SSH_PASSWORD }}" >> $GITHUB_ENV
+
+ - name: Determine platform
+ run: echo "PLATFORM=${{ github.event.inputs.platform || env.PLATFORM || 'linux/amd64' }}" >> $GITHUB_ENV
+
+ - name: Determine manager tag
+ run: echo "MANAGER_VERSION=${{ github.event.inputs.manager_version || env.MANAGER_VERSION }}" >> $GITHUB_ENV
+
+ - name: Determine clean install
+ run: echo "CLEAN_INSTALL=${{ github.event.inputs.clean_install || env.CLEAN_INSTALL }}" >> $GITHUB_ENV
+
+ - name: Check manager tag input
+ if: env.MANAGER_VERSION != ''
+ run: |
+ docker manifest inspect openremote/manager:${{ env.MANAGER_VERSION }} > /dev/null 2> /dev/null
+
+ - name: Determine password
+ id: password
+ run: echo "SETUP_ADMIN_PASSWORD=${{ github.event.inputs.password || env.SETUP_ADMIN_PASSWORD || 'secret' }}" >> $GITHUB_ENV
+
+ - name: Check deployment existence
+ id: check_deployment_dir
+ uses: andstor/file-existence-action@v1
+ with:
+ files: "deployment/Dockerfile"
+
+ - name: Check custom project
+ id: check_custom_project
+ uses: andstor/file-existence-action@v1
+ with:
+ files: "openremote"
+
+ - name: Determine compose file path
+ id: compose-file
+ run: |
+ if [ ! -z $ENV_COMPOSE_FILE ]; then
+ if [ ! -f $ENV_COMPOSE_FILE ]; then
+ echo "Specified ENV_COMPOSE_FILE does not exist $ENV_COMPOSE_FILE"
+ exit 1
+ fi
+ echo "COMPOSE_FILE=$ENV_COMPOSE_FILE" >> $GITHUB_ENV
+ elif [ -f "profile/$ENVIRONMENT.yml" ]; then
+ echo "COMPOSE_FILE=profile/$ENVIRONMENT.yml" >> $GITHUB_ENV
+ else
+ echo "COMPOSE_FILE=docker-compose.yml" >> $GITHUB_ENV
+ fi
+ env:
+ ENV_COMPOSE_FILE: ${{ env.COMPOSE_FILE }}
+ ENVIRONMENT: ${{ github.event.inputs.environment }}
+
+ - name: Determine manager image info
+ id: manager-image
+ run: |
+ if [ ! -z $MANAGER_VERSION ]; then
+ echo "MANAGER_VERSION=$MANAGER_VERSION" >> $GITHUB_ENV
+ elif [ $CUSTOM_PROJECT == 'true' ]; then
+ echo "MANAGER_BUILD=true" >> $GITHUB_ENV
+ echo "MANAGER_PATH=openremote/manager/build/install/manager" >> $GITHUB_ENV
+ echo "MANAGER_VERSION=$(cd openremote; git rev-parse --short HEAD; cd ..)" >> $GITHUB_ENV
+ else
+ echo "MANAGER_BUILD=true" >> $GITHUB_ENV
+ echo "MANAGER_PATH=manager/build/install/manager" >> $GITHUB_ENV
+ echo "MANAGER_VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
+ fi
+ env:
+ CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.file_exists }}
+
+ - name: Determine deployment image info
+ id: deployment-image
+ if: steps.check_deployment_dir.outputs.files_exists == 'true'
+ run: |
+ echo "DEPLOYMENT_BUILD=true" >> $GITHUB_ENV
+ echo "DEPLOYMENT_PATH=deployment/build" >> $GITHUB_ENV
+ echo "DEPLOYMENT_VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
+
+ - name: Determine host init script
+ id: host-init
+ run: |
+ if [ $HOST_INIT_SCRIPT == 'NONE' ]; then
+ echo "HOST_INIT_SCRIPT=" >> $GITHUB_ENV
+ elif [ ! -z $HOST_INIT_SCRIPT ]; then
+ if [ ! -f ".ci_cd/host_init/${HOST_INIT_SCRIPT}.sh" ]; then
+ echo "HOST_INIT_SCRIPT (.ci_cd/host_init/${HOST_INIT_SCRIPT}.sh) does not exist"
+ exit 1
+ fi
+ echo "HOST_INIT_SCRIPT=${ENV_HOST_INIT_SCRIPT}.sh" >> $GITHUB_ENV
+ elif [ -f ".ci_cd/host_init/$ENVIRONMENT.sh" ]; then
+ echo "HOST_INIT_SCRIPT=$ENVIRONMENT.sh" >> $GITHUB_ENV
+ elif [ -f ".ci_cd/host_init/init.sh" ]; then
+ echo "HOST_INIT_SCRIPT=init.sh" >> $GITHUB_ENV
+ else
+ echo "HOST_INIT_SCRIPT=" >> $GITHUB_ENV
+ fi
+ env:
+ ENVIRONMENT: ${{ github.event.inputs.environment }}
+
+ - name: Output info
+ run: |
+ echo "************************************************************"
+ echo "************** INFO *******************"
+ echo "************************************************************"
+ echo "Host: ${{ env.HOST }}"
+ echo "Environment: ${{ github.event.inputs.environment }}"
+ echo "Platform: ${{ env.PLATFORM }}"
+ echo "Compose file: ${{ env.COMPOSE_FILE }}"
+ echo "Manager build: ${{ env.MANAGER_BUILD == 'true' }}"
+ echo "Manager version: ${{ env.MANAGER_VERSION }}"
+ echo "Manager build path: ${{ env.MANAGER_PATH }}"
+ echo "Deployment build: ${{ env.DEPLOYMENT_BUILD == 'true' }}"
+ echo "Deployment version: ${{ env.DEPLOYMENT_VERSION }}"
+ echo "Deployment build path: ${{ env.DEPLOYMENT_PATH }}"
+ echo "Host init script: ${{ env.HOST_INIT_SCRIPT }}"
+ echo "************************************************************"
+ echo "************************************************************"
+
+ - name: Make temp dir
+ run: mkdir temp
+
+ - name: Output ENV to file
+ shell: python
+ run: |
+ import json
+ import os
+ import sys
+
+ secrets = json.loads(os.getenv('secret'))
+
+ for key, value in secrets.items():
+ print(f"Setting {key} ...")
+ lines = len(value.split("\n"))
+ if lines > 1:
+ os.system(f"echo '{key}=\'' >> temp/env")
+ os.system(f"echo '{value}\'' >> temp/env")
+ else:
+ os.system(f"echo '{key}=\"{value}\"' >> temp/env")
+ env:
+ secret: ${{ toJSON(env) }}
+
+ - name: Copy compose file to temp folder
+ run: cp "$COMPOSE_FILE" temp/docker-compose.yml
+
+ - name: Copy host init files to temp folder
+ if: ${{ env.HOST_INIT_SCRIPT != '' }}
+ run: cp ".ci_cd/host_init" temp/
+
+ - name: grant execute permission for gradlew
+ run: chmod +x gradlew
+
+ - name: Set up JDK 17 and gradle cache
+ if: ${{ env.MANAGER_BUILD == 'true' || env.DEPLOYMENT_BUILD == 'true' }}
+ id: java
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+ cache: 'gradle'
+
+ - name: Grant execute permission for gradlew and make image-cache
+ if: ${{ env.MANAGER_BUILD == 'true' || env.DEPLOYMENT_BUILD == 'true' }}
+ run: |
+ chmod +x gradlew
+ mkdir -p ~/image-cache
+
+ - name: Get yarn cache directory path
+ if: ${{ env.MANAGER_BUILD == 'true' || env.DEPLOYMENT_BUILD == 'true' }}
+ id: yarn-cache-dir-path
+ run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
+
+ - name: Yarn cache
+ if: ${{ env.MANAGER_BUILD == 'true' || env.DEPLOYMENT_BUILD == 'true' }}
+ uses: actions/cache@v2
+ id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
+ with:
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
+ key: ${{ runner.os }}-yarn---${{ hashFiles('**/yarn.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-yarn---
+
+ - name: Do code build
+ if: ${{ env.MANAGER_BUILD == 'true' || env.DEPLOYMENT_BUILD == 'true' }}
+ run: |
+ if [ $MANAGER_BUILD == 'true' ]; then
+ ./gradlew installDist
+ elif [ $DEPLOYMENT_BUILD == 'true' ]; then
+ ./gradlew -p deployment installDist
+ fi
+
+ - name: set up QEMU
+ uses: docker/setup-qemu-action@v1
+ with:
+ platforms: ${{ env.PLATFORM }}
+
+ - name: install buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v1
+ with:
+ version: latest
+ install: true
+
+ - name: Build and save manager image
+ if: ${{ env.MANAGER_BUILD == 'true' }}
+ run: |
+ docker build --platform $PLATFORM -t openremote/manager:$MANAGER_VERSION $MANAGER_PATH
+ docker save openremote/manager:$MANAGER_VERSION | gzip > temp/manager.tar.gz
+
+ - name: Build and save deployment image
+ if: ${{ env.DEPLOYMENT_BUILD == 'true' }}
+ run: |
+ docker build --platform $PLATFORM -t openremote/deployment:$DEPLOYMENT_VERSION $DEPLOYMENT_PATH
+ docker save openremote/deployment:$DEPLOYMENT_VERSION | gzip > temp/deployment.tar.gz
+
+ - name: Copy files to host
+ timeout-minutes: 10
+ uses: appleboy/scp-action@master
+ with:
+ host: ${{ env.HOST }}
+ port: ${{ env.SSH_PORT }}
+ username: ${{ env.SSH_USER }}
+ password: ${{ env.SSH_PASSWORD }}
+ key: ${{ env.SSH_KEY }}
+ source: "temp"
+ target: "temp"
+ strip_components: 1
+ rm: true
+
+ - name: Load image(s)
+ if: ${{ env.MANAGER_BUILD == 'true' || env.DEPLOYMENT_BUILD == 'true' }}
+ uses: appleboy/ssh-action@master
+ with:
+ host: ${{ env.HOST }}
+ port: ${{ env.SSH_PORT }}
+ username: ${{ env.SSH_USER }}
+ password: ${{ env.SSH_PASSWORD }}
+ key: ${{ env.SSH_KEY }}
+ script: |
+ if [ -f "temp/manager.tar.gz" ]; then
+ docker load < temp/manager.tar.gz
+ fi
+ if [ -f "temp/deployment.tar.gz" ]; then
+ docker load < temp/deployment.tar.gz
+ fi
+
+ - name: Execute deployment
+ timeout-minutes: 10
+ uses: appleboy/ssh-action@master
+ with:
+ host: ${{ env.HOST }}
+ port: ${{ env.SSH_PORT }}
+ username: ${{ env.SSH_USER }}
+ password: ${{ env.SSH_PASSWORD }}
+ key: ${{ env.SSH_KEY }}
+ script: |
+ chmod +x -R temp/
+ set -a
+ . ./temp/env
+ set +a
+ if [ -f "temp/host-init/$HOST_INIT_SCRIPT" ]; then
+ ./temp/host-init/$HOST_INIT_SCRIPT
+ fi
+
+ # Pull any required images
+ docker-compose -f temp/docker-compose.yml pull
+
+ # Attempt docker compose down
+ docker-compose -f temp/docker-compose.yml -p or down
+
+ # Delete postgres volume if CLEAN_INSTALL=true
+ if [ $CLEAN_INSTALL == 'true' ]; then
+ docker volume rm or_postgresql-data
+ fi
+
+ docker volume rm or_deployment-data
+
+ # Start the stack
+ docker-compose -f temp/docker-compose.yml -p or up -d
+
+ - name: Wait for up to 5 mins for manager webserver to be running
+ run: |
+ echo "Waiting for manager web server https://$HOST..."
+ count=0
+ response=0
+ while [ $response -ne 200 ] && [ $count -lt 36 ]; do
+ response=$(curl --output /dev/null --silent --head --write-out "%{http_code}" https://$HOST/manager/)
+ echo '.'
+ count=$((count+1))
+ sleep 5
+ done
+ if [ $response -ne 200 ]; then
+ echo "Response code = $response"
+ exit 1
+ fi
+
+ - name: Cleanup any obsolete docker images
+ timeout-minutes: 2
+ uses: appleboy/ssh-action@master
+ with:
+ host: ${{ env.HOST }}
+ port: ${{ env.SSH_PORT }}
+ username: ${{ env.SSH_USER }}
+ password: ${{ env.SSH_PASSWORD }}
+ key: ${{ env.SSH_KEY }}
+ script: |
+ docker image prune -f
diff --git a/docker-compose.yml b/docker-compose.yml
index 965eab720..8e6e8bc4b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,10 @@
# OpenRemote v3
#
-# Profile that runs the vanilla stack on https://localhost using a self-signed SSL certificate,
+# Profile that runs the stack by default on https://localhost using a self-signed SSL certificate,
+# but optionally on https://$HOST with an auto generated SSL certificate from Letsencrypt.
+#
+# It is possible to specify SETUP_TYPE=demo to pre-populate the system with a set of demo assets, rules, etc. (as
+# is shown at https://demo.openremote.io)
# with username 'admin' and password 'secret'. There is no map data available in the vanilla
# system so the map tile server will not function. Persistent data is stored in a docker
# volume called postgresql-data between restarts, simply delete this volume to reset the
@@ -11,6 +15,7 @@
version: '2.4'
volumes:
+ proxy-data:
temp-data:
postgresql-data:
btmesh-data:
@@ -27,7 +32,14 @@ services:
- "80:80"
- "443:443"
- "8883:8883"
-
+ volumes:
+ - proxy-data:/deployment
+ environment:
+ LE_EMAIL: ${SETUP_EMAIL_TO}
+ DOMAINNAME: ${HOST:-localhost}
+ # USE A CUSTOM PROXY CONFIG - COPY FROM https://github.com/openremote/proxy/blob/main/haproxy.cfg
+ #HAPROXY_CONFIG: '/data/proxy/haproxy.cfg'
+
postgresql:
restart: always
image: openremote/postgresql:${POSTGRESQL_VERSION:-14.1.0.1}
@@ -41,24 +53,39 @@ services:
depends_on:
postgresql:
condition: service_healthy
+ volumes:
+ - ./deployment:/deployment
environment:
- KEYCLOAK_FRONTEND_URL: ${EXTERNAL_URL:-https://localhost}/auth
KEYCLOAK_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
+ KEYCLOAK_FRONTEND_URL: https://${HOST:-localhost}/auth
+
manager:
- privileged: true
+# privileged: true
restart: always
image: openremote/manager:${MANAGER_VERSION:-latest}
depends_on:
keycloak:
condition: service_healthy
environment:
- DEV_MODE: ${DEV_MODE:-false}
+ # Set this variable `demo` to auto provision demo assets etc.
+ SETUP_TYPE: ${SETUP_TYPE:-}
SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
+ SETUP_WIPE_CLEAN_INSTALL: ${SETUP_WIPE_CLEAN_INSTALL:-false}
+ SETUP_EMAIL_HOST: ${SETUP_EMAIL_HOST:-}
+ SETUP_EMAIL_USER: ${SETUP_EMAIL_USER:-}
+ SETUP_EMAIL_PASSWORD: ${SETUP_EMAIL_PASSWORD:-}
+ SETUP_EMAIL_FROM: ${SETUP_EMAIL_FROM:-}
+ SETUP_EMAIL_TO: ${SETUP_EMAIL_TO:-}
+ DEV_MODE: ${DEV_MODE:-false}
+ # The following variables will configure the demo
+ FORECAST_SOLAR_API_KEY: ${FORECAST_SOLAR_API_KEY:-}
+ OPEN_WEATHER_API_APP_ID: ${OPEN_WEATHER_API_APP_ID:-}
+ SETUP_IMPORT_DEMO_AGENT_KNX: ${SETUP_IMPORT_DEMO_AGENT_KNX:-false}
+ SETUP_IMPORT_DEMO_AGENT_VELBUS: ${SETUP_IMPORT_DEMO_AGENT_KNX:-false}
volumes:
- temp-data:/tmp
- - /var/run/dbus:/var/run/dbus
- - btmesh-data:/btmesh
+# - /var/run/dbus:/var/run/dbus
+# - btmesh-data:/btmesh
# devices:
# - /dev/ttyACM0:/dev/ttyS0
diff --git a/manager/Dockerfile b/manager/Dockerfile
index 214b0275a..ea173b9fd 100644
--- a/manager/Dockerfile
+++ b/manager/Dockerfile
@@ -10,14 +10,15 @@ ENV JAVA_TOOL_OPTIONS ${JAVA_TOOL_OPTIONS}
ENV TZ ${TZ:-Europe/Amsterdam}
ENV SETUP_ADMIN_PASSWORD ${SETUP_ADMIN_PASSWORD:-secret}
+ENV SETUP_TYPE ${SETUP_TYPE}
ENV EXTERNAL_URL ${EXTERNAL_URL:-https://localhost}
ENV SETUP_EMAIL_HOST ${SETUP_EMAIL_HOST}
ENV SETUP_EMAIL_USER ${SETUP_EMAIL_USER}
ENV SETUP_EMAIL_PASSWORD ${SETUP_EMAIL_PASSWORD}
-ENV SETUP_EMAIL_PORT ${SETUP_EMAIL_PORT:-25}
+ENV SETUP_EMAIL_PORT ${SETUP_EMAIL_PORT:-587}
ENV SETUP_EMAIL_TLS ${SETUP_EMAIL_TLS:-true}
-ENV SETUP_EMAIL_FROM_KEYCLOAK ${SETUP_EMAIL_FROM_KEYCLOAK:-no-reply@localhost}
-ENV SETUP_EMAIL_FROM_DEFAULT ${SETUP_EMAIL_FROM_DEFAULT:-no-reply@localhost}
+ENV SETUP_EMAIL_FROM ${SETUP_EMAIL_FROM}
+ENV SETUP_EMAIL_TO ${SETUP_EMAIL_TO}
ENV NOTIFICATION_FIREBASE_URL ${NOTIFICATION_FIREBASE_URL:-https://fcm.googleapis.com/fcm/send}
ENV NOTIFICATION_FIREBASE_API_KEY ${NOTIFICATION_FIREBASE_API_KEY}
ENV FIREBASE_CONFIG_FILE ${FIREBASE_CONFIG_FILE:-/deployment/manager/fcm.json}
@@ -69,6 +70,7 @@ ADD web /opt/web
ADD map /opt/map
EXPOSE 8080
+EXPOSE 1883
HEALTHCHECK --interval=3s --timeout=3s --start-period=30s --retries=120 CMD curl --fail --silent http://localhost:8080 || exit 1
ENTRYPOINT java $MANAGER_JAVA_OPTS -cp /opt/app/lib/*:/deployment/manager/extensions/* org.openremote.manager.Main
diff --git a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java
index 3b7f085d6..b1a5a804a 100644
--- a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java
+++ b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java
@@ -26,7 +26,6 @@ import org.keycloak.admin.client.resource.*;
import org.keycloak.common.enums.SslRequired;
import org.keycloak.representations.idm.*;
import org.openremote.container.message.MessageBrokerService;
-import org.openremote.model.PersistenceEvent;
import org.openremote.container.persistence.PersistenceService;
import org.openremote.container.security.AuthContext;
import org.openremote.container.security.keycloak.KeycloakIdentityProvider;
@@ -36,6 +35,7 @@ import org.openremote.manager.apps.ConsoleAppService;
import org.openremote.manager.event.ClientEventService;
import org.openremote.model.Constants;
import org.openremote.model.Container;
+import org.openremote.model.PersistenceEvent;
import org.openremote.model.auth.OAuthGrant;
import org.openremote.model.event.shared.TenantFilter;
import org.openremote.model.query.AssetQuery;
@@ -69,8 +69,6 @@ import static org.openremote.container.util.MapAccess.getBoolean;
import static org.openremote.container.util.MapAccess.getString;
import static org.openremote.container.web.WebService.WEBSERVER_ALLOWED_ORIGINS;
import static org.openremote.container.web.WebService.WEBSERVER_ALLOWED_ORIGINS_DEFAULT;
-import static org.openremote.manager.setup.AbstractKeycloakSetup.SETUP_EMAIL_FROM_KEYCLOAK;
-import static org.openremote.manager.setup.AbstractKeycloakSetup.SETUP_EMAIL_FROM_KEYCLOAK_DEFAULT;
import static org.openremote.model.Constants.*;
import static org.openremote.model.util.ValueUtil.convert;
@@ -1126,7 +1124,7 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider im
emailConfig.put("password", container.getConfig().getOrDefault(SETUP_EMAIL_PASSWORD, null));
emailConfig.put("auth", container.getConfig().containsKey(SETUP_EMAIL_USER) ? "true" : "false");
emailConfig.put("tls", Boolean.toString(getBoolean(container.getConfig(), SETUP_EMAIL_TLS, SETUP_EMAIL_TLS_DEFAULT)));
- emailConfig.put("from", getString(container.getConfig(), SETUP_EMAIL_FROM_KEYCLOAK, SETUP_EMAIL_FROM_KEYCLOAK_DEFAULT));
+ emailConfig.put("from", getString(container.getConfig(), SETUP_EMAIL_FROM, SETUP_EMAIL_FROM_DEFAULT));
realmRepresentation.setSmtpServer(emailConfig);
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractKeycloakSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractKeycloakSetup.java
index 6f2bbe3c5..5a063b230 100644
--- a/manager/src/main/java/org/openremote/manager/setup/AbstractKeycloakSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractKeycloakSetup.java
@@ -22,12 +22,14 @@ package org.openremote.manager.setup;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RoleResource;
import org.keycloak.representations.idm.ClientRepresentation;
+import org.openremote.manager.security.ManagerIdentityProvider;
import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.manager.security.ManagerKeycloakIdentityProvider;
import org.openremote.model.Container;
import org.openremote.model.security.ClientRole;
import org.openremote.model.security.Tenant;
import org.openremote.model.security.User;
+import org.openremote.model.setup.Setup;
import java.util.Arrays;
import java.util.Collections;
@@ -38,8 +40,6 @@ import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID;
public abstract class AbstractKeycloakSetup implements Setup {
- public static final String SETUP_EMAIL_FROM_KEYCLOAK = "SETUP_EMAIL_FROM_KEYCLOAK";
- public static final String SETUP_EMAIL_FROM_KEYCLOAK_DEFAULT = "[email protected]";
public static final ClientRole[] PUBLIC_USER_ROLES = new ClientRole[] {
ClientRole.READ_ASSETS,
ClientRole.READ_MAP
diff --git a/manager/src/main/java/org/openremote/manager/setup/EmptySetupTasks.java b/manager/src/main/java/org/openremote/manager/setup/EmptySetupTasks.java
deleted file mode 100644
index a5d4075c1..000000000
--- a/manager/src/main/java/org/openremote/manager/setup/EmptySetupTasks.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017, OpenRemote Inc.
- *
- * See the CONTRIBUTORS.txt file in the distribution for a
- * full listing of individual contributors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.openremote.manager.setup;
-
-import org.openremote.manager.security.ManagerIdentityService;
-import org.openremote.model.Container;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Just prepares keycloak identity provider if it is enabled
- */
-public class EmptySetupTasks implements SetupTasks {
-
- final protected List<Setup> tasks = new ArrayList<>();
-
- protected void addTask(Setup task) {
- tasks.add(task);
- }
-
- public List<Setup> getTasks() {
- return tasks;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <S extends Setup> S getTaskOfType(Class<S> setupType) {
- for (Setup task : tasks) {
- if (setupType.isAssignableFrom(task.getClass()))
- return (S) task;
- }
- throw new IllegalStateException("No setup task found of type: " + setupType);
- }
-
- @Override
- public List<Setup> createTasks(Container container) {
- // Basic vs Keycloak identity provider
- if (container.getService(ManagerIdentityService.class).isKeycloakEnabled()) {
-
- // Keycloak is not managed by persistence service so need separate clean task
- addTask(new KeycloakCleanSetup(container));
- addTask(new KeycloakInitSetup(container));
- }
-
- return getTasks();
- }
-}
diff --git a/manager/src/main/java/org/openremote/manager/setup/ManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/ManagerSetup.java
index 33e51d5eb..e1acbb952 100644
--- a/manager/src/main/java/org/openremote/manager/setup/ManagerSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/ManagerSetup.java
@@ -28,12 +28,12 @@ import org.openremote.manager.rules.RulesetStorageService;
import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.model.Constants;
import org.openremote.model.Container;
-import org.openremote.model.apps.ConsoleAppConfig;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.agent.AgentLink;
import org.openremote.model.asset.impl.*;
import org.openremote.model.attribute.*;
import org.openremote.model.geo.GeoJSONPoint;
+import org.openremote.model.setup.Setup;
import org.openremote.model.util.ValueUtil;
import org.openremote.model.value.ValueFormat;
import org.openremote.model.value.ValueType;
diff --git a/manager/src/main/java/org/openremote/manager/setup/SetupService.java b/manager/src/main/java/org/openremote/manager/setup/SetupService.java
index dae477285..befbaf0a4 100644
--- a/manager/src/main/java/org/openremote/manager/setup/SetupService.java
+++ b/manager/src/main/java/org/openremote/manager/setup/SetupService.java
@@ -19,9 +19,13 @@
*/
package org.openremote.manager.setup;
+import org.openremote.container.persistence.PersistenceService;
+import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.model.Container;
import org.openremote.model.ContainerService;
-import org.openremote.container.persistence.PersistenceService;
+import org.openremote.model.setup.Setup;
+import org.openremote.model.setup.SetupTasks;
+
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
@@ -34,18 +38,14 @@ import java.util.logging.Logger;
* <p>
* First, this service will load an implementation of {@link SetupTasks} from the
* classpath using {@link ServiceLoader}. If multiple providers are found, an error
- * is raised. If a provider is found, only its tasks will be used.
- * <p>
- * If no {@link SetupTasks} provider is found on the classpath, an instance of {@link EmptySetupTasks} is used.
+ * is raised. If a provider is found, its tasks will be used on top of {@link KeycloakCleanSetup}
+ * and {@link KeycloakInitSetup} which are auto-loaded if keycloak is enabled.
*/
public class SetupService implements ContainerService {
private static final Logger LOG = Logger.getLogger(SetupService.class.getName());
- final protected List<Setup> setupList = new ArrayList<>();
-
- // Make demo/test data accessible from Groovy/Java code
- public SetupTasks setupTasks;
+ final protected List<Setup> tasks = new ArrayList<>();
@Override
public int getPriority() {
@@ -62,31 +62,27 @@ public class SetupService implements ContainerService {
return;
}
- ServiceLoader.load(SetupTasks.class).forEach(
- discoveredSetupTasks -> {
- if (setupTasks != null) {
- throw new IllegalStateException(
- "Only one provider of SetupTasks can be configured, already found '"
- + setupTasks.getClass().getName() + ", remove from classpath: "
- + discoveredSetupTasks.getClass().getName()
- );
- }
- LOG.info("Found custom SetupTasks provider on classpath: " + discoveredSetupTasks.getClass().getName());
- setupTasks = discoveredSetupTasks;
- }
- );
+ // If keycloak then we need keycloak clean and init tasks
+ boolean keycloakEnabled = container.getService(ManagerIdentityService.class).isKeycloakEnabled();
+ String setupType = container.getConfig().get(SetupTasks.SETUP_TYPE);
- if (setupTasks == null) {
- LOG.info("No custom SetupTasks provider found on classpath, system will be empty");
- setupTasks = new EmptySetupTasks();
+ if (keycloakEnabled) {
+ // Keycloak is not managed by persistence service so need separate clean task
+ tasks.add(new KeycloakCleanSetup(container));
+ tasks.add(new KeycloakInitSetup(container));
}
- setupList.addAll(setupTasks.createTasks(container));
+ tasks.addAll(ServiceLoader.load(SetupTasks.class).stream().map(ServiceLoader.Provider::get)
+ .flatMap(discoveredSetupTasks -> {
+ LOG.info("Found custom SetupTasks provider on classpath: " + discoveredSetupTasks.getClass().getName());
+ List<Setup> tasks = discoveredSetupTasks.createTasks(container, setupType, keycloakEnabled);
+ return tasks != null ? tasks.stream() : null;
+ }).toList());
try {
- if (setupList.size() > 0) {
+ if (tasks.size() > 0) {
LOG.info("--- EXECUTING INIT TASKS ---");
- for (Setup setup : setupList) {
+ for (Setup setup : tasks) {
setup.onInit();
}
LOG.info("--- INIT TASKS COMPLETED SUCCESSFULLY ---");
@@ -100,9 +96,9 @@ public class SetupService implements ContainerService {
public void start(Container container) {
try {
- if (setupList.size() > 0) {
+ if (tasks.size() > 0) {
LOG.info("--- EXECUTING START TASKS ---");
- for (Setup setup : setupList) {
+ for (Setup setup : tasks) {
setup.onStart();
}
LOG.info("--- START TASKS COMPLETED SUCCESSFULLY ---");
@@ -114,12 +110,16 @@ public class SetupService implements ContainerService {
@Override
public void stop(Container container) {
- setupTasks = null;
- setupList.clear();
+ tasks.clear();
}
+ @SuppressWarnings("unchecked")
public <S extends Setup> S getTaskOfType(Class<S> setupType) {
- return setupTasks.getTaskOfType(setupType);
+ for (Setup task : tasks) {
+ if (setupType.isAssignableFrom(task.getClass()))
+ return (S) task;
+ }
+ throw new IllegalStateException("No setup task found of type: " + setupType);
}
@Override
diff --git a/model/src/main/java/org/openremote/model/Constants.java b/model/src/main/java/org/openremote/model/Constants.java
index e360eb9d9..3a7362bb6 100644
--- a/model/src/main/java/org/openremote/model/Constants.java
+++ b/model/src/main/java/org/openremote/model/Constants.java
@@ -53,11 +53,12 @@ public interface Constants {
String SETUP_EMAIL_HOST = "SETUP_EMAIL_HOST";
String SETUP_EMAIL_PASSWORD = "SETUP_EMAIL_PASSWORD";
String SETUP_EMAIL_PORT = "SETUP_EMAIL_PORT";
- int SETUP_EMAIL_PORT_DEFAULT = 25;
+ int SETUP_EMAIL_PORT_DEFAULT = 587;
String SETUP_EMAIL_TLS = "SETUP_EMAIL_TLS";
boolean SETUP_EMAIL_TLS_DEFAULT = true;
String SETUP_EMAIL_FROM = "SETUP_EMAIL_FROM";
- String SETUP_EMAIL_FROM_DEFAULT = "[email protected]";
+ String SETUP_EMAIL_FROM_DEFAULT = "no-reply@localhost";
+ String SETUP_EMAIL_TO = "SETUP_EMAIL_TO";
String REALM_PARAM_NAME = "Realm";
String ASSET_ID_REGEXP = "^[0-9A-Za-z]{22}$";
String UUID_REGEXP = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
diff --git a/manager/src/main/java/org/openremote/manager/setup/Setup.java b/model/src/main/java/org/openremote/model/setup/Setup.java
similarity index 97%
rename from manager/src/main/java/org/openremote/manager/setup/Setup.java
rename to model/src/main/java/org/openremote/model/setup/Setup.java
index c3bc46f64..05daca109 100644
--- a/manager/src/main/java/org/openremote/manager/setup/Setup.java
+++ b/model/src/main/java/org/openremote/model/setup/Setup.java
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package org.openremote.manager.setup;
+package org.openremote.model.setup;
/**
* A task that runs when the application starts. Typically this means a procedure that
diff --git a/manager/src/main/java/org/openremote/manager/setup/SetupTasks.java b/model/src/main/java/org/openremote/model/setup/SetupTasks.java
similarity index 77%
rename from manager/src/main/java/org/openremote/manager/setup/SetupTasks.java
rename to model/src/main/java/org/openremote/model/setup/SetupTasks.java
index c2790dda9..5634bec04 100644
--- a/manager/src/main/java/org/openremote/manager/setup/SetupTasks.java
+++ b/model/src/main/java/org/openremote/model/setup/SetupTasks.java
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package org.openremote.manager.setup;
+package org.openremote.model.setup;
import org.openremote.model.Container;
@@ -28,7 +28,10 @@ import java.util.List;
*/
public interface SetupTasks {
- List<Setup> createTasks(Container container);
+ /**
+ * Can be used by setup tasks to have different configurable setups (e.g. production/staging/test/etc.)
+ */
+ String SETUP_TYPE = "SETUP_TYPE";
- <S extends Setup> S getTaskOfType(Class<S> setupType);
+ List<Setup> createTasks(Container container, String setupType, boolean keycloakEnabled);
}
diff --git a/mvp/fetch_s3_deploy.sh b/mvp/fetch_s3_deploy.sh
deleted file mode 100755
index 5a11234db..000000000
--- a/mvp/fetch_s3_deploy.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-export DEPLOYMENT_NAME=${1:?usage $0 DEPLOYMENT_NAME}
-AWS_ECR_REPO=$(docker run --rm -v ~/.aws:/root/.aws -v /var/run/docker.sock:/var/run/docker.sock --entrypoint aws openremote/openremote-cli ecr describe-repositories --repository-names $DEPLOYMENT_NAME --query 'repositories[0].repositoryUri' --profile openremote-cli | xargs echo)
-DOCKER_PASSWORD=$(docker run --rm -v ~/.aws:/root/.aws -v /var/run/docker.sock:/var/run/docker.sock --entrypoint aws openremote/openremote-cli ecr get-login-password --profile openremote-cli)
-docker login --username AWS --password $DOCKER_PASSWORD $AWS_ECR_REPO
-docker run --rm -v ~/.aws:/root/.aws -v $(pwd):/$DEPLOYMENT_NAME openremote/openremote-cli map -f $DEPLOYMENT_NAME -v
-echo $AWS_ECR_REPO
-docker-compose -p openremote down
-docker images --filter "reference=$AWS_ECR_REPO" -q | xargs docker rmi
-docker run --rm -v ~/.aws:/root/.aws -v $(pwd):/$DEPLOYMENT_NAME openremote/openremote-cli map -a download -f $DEPLOYMENT_NAME -v -t
-sudo tar -xf deployment.tar.gz
-sudo mv mapdata.mbtiles deployment/map/ || true
-sudo chown -R ubuntu:ubuntu .
-docker system prune -f
-docker-compose -p openremote up -d || exit 69
-docker images --filter "reference=openremote/*" -q | xargs docker rmi || true
diff --git a/profile/deploy.yml b/profile/deploy.yml
index 9670955dc..f6d1fb4c1 100644
--- a/profile/deploy.yml
+++ b/profile/deploy.yml
@@ -11,14 +11,14 @@
# Here's a list of commonly customised environment variables:
#
# SETUP_ADMIN_PASSWORD
-# DOMAINNAME
+# HOST
# EXTERNAL_URL
# ADMIN_EMAIL
# SETUP_EMAIL_HOST
# SETUP_EMAIL_USER
# SETUP_EMAIL_PASSWORD
-# SETUP_EMAIL_FROM_KEYCLOAK
-# SETUP_EMAIL_FROM_DEFAULT
+# SETUP_EMAIL_TO
+# SETUP_EMAIL_FROM
# NOTIFICATION_FIREBASE_API_KEY
# IDENTITY_PROVIDER
#
@@ -55,10 +55,13 @@ services:
# The public host name of this OpenRemote installation. Set this to request/manage an SSL
# certificate with the free https://letsencrypt.org/ provider. The default 'localhost' will
# rely on a baked-in self-signed certificate.
- DOMAINNAME: ${DOMAINNAME:-localhost}
+ DOMAINNAME: ${HOST}
- # Provide your own email address for your SSL certificates with Let's Encrypt.
- LE_EMAIL: ${ADMIN_EMAIL:-}
+ # USE A CUSTOM PROXY CONFIG - COPY FROM https://github.com/openremote/proxy/blob/main/haproxy.cfg
+ HAPROXY_CONFIG: ${HAPROXY_CONFIG}
+
+ # Email address for SSL certificate issuance and expiration notifications.
+ LE_EMAIL: ${SETUP_EMAIL_TO}
# Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt
# when testing (this is important, you are limited to 5 duplicate certificates per week!)
@@ -136,19 +139,24 @@ services:
# the keycloak identity provider).
SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
+ # Can be used by SetupTasks to determine what assets etc. should be setup for this deployment
+ # the available values and general use of this is dependent on the actual SetupTasks available
+ # in the instance being deployed some basic recommendations are 'production', 'staging'
+ SETUP_TYPE: ${SETUP_TYPE}
+
# The public URL of the proxy in front of this manager; must match the proxy#DOMAINNAME (unfortunately
# docker compose doesn't support chaining environment variables at time of writing, hence the need for
# two environment variables)
EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
- # Configure SMTP server, to send password reset emails etc.
+ # Configure Email, SMTP server to send password reset emails etc.
SETUP_EMAIL_HOST:
SETUP_EMAIL_USER:
SETUP_EMAIL_PASSWORD:
- SETUP_EMAIL_PORT: ${SETUP_EMAIL_PORT:-25}
- SETUP_EMAIL_TLS: ${SETUP_EMAIL_TLS:-true}
- SETUP_EMAIL_FROM_KEYCLOAK: ${SETUP_EMAIL_FROM_KEYCLOAK:-no-reply@localhost}
- SETUP_EMAIL_FROM_DEFAULT: ${SETUP_EMAIL_FROM_DEFAULT:-no-reply@localhost}
+ SETUP_EMAIL_PORT: ${SETUP_EMAIL_PORT}
+ SETUP_EMAIL_TLS: ${SETUP_EMAIL_TLS}
+ SETUP_EMAIL_TO: ${SETUP_EMAIL_TO}
+ SETUP_EMAIL_FROM_DEFAULT: ${SETUP_EMAIL_FROM}
# Console applications can register for push notifications through FCM.
NOTIFICATION_FIREBASE_URL: ${NOTIFICATION_FIREBASE_URL:-https://fcm.googleapis.com/fcm/send}
diff --git a/project.gradle b/project.gradle
index 8e3e8c1a3..33bcce8cf 100644
--- a/project.gradle
+++ b/project.gradle
@@ -1,5 +1,4 @@
// Common configuration applied to all projects
-
import java.nio.file.Paths
import static org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS
@@ -46,21 +45,25 @@ if (project == rootProject) {
shortenCommandLine = MANIFEST
workingDirectory = (isCustomProject() ? project(":openremote").projectDir.toString() : projectDir.toString())
}
- "Empty"(Application) {
- moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.manager.main" : ".manager.main")
- }
- "Test Setup"(Application) {
+ "Demo Setup"(Application) {
moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.setup.main" : ".setup.main")
+ envs = [
+ SETUP_TYPE: "demo"
+ ]
}
- "Empty with Proxy"(Application) {
- moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.manager.main" : ".manager.main")
+ "Demo Setup with Proxy"(Application) {
+ moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.setup.main" : ".setup.main")
envs = [
+ SETUP_TYPE: "demo",
WEBSERVER_LISTEN_HOST: "0.0.0.0",
EXTERNAL_URL: "https://localhost:8443"
]
}
- "Test Setup with Proxy"(Application) {
- moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.setup.main" : ".setup.main")
+ "Empty"(Application) {
+ moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.manager.main" : ".manager.main")
+ }
+ "Empty with Proxy"(Application) {
+ moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.manager.main" : ".manager.main")
envs = [
WEBSERVER_LISTEN_HOST: "0.0.0.0",
EXTERNAL_URL: "https://localhost:8443"
diff --git a/setup/build.gradle b/setup/build.gradle
index 9cd29e486..0e2c368d8 100644
--- a/setup/build.gradle
+++ b/setup/build.gradle
@@ -3,3 +3,14 @@ apply plugin: "java-library"
dependencies {
api resolveProject(":manager")
}
+
+jar {
+ archivesBaseName = "openremote-demo-${project.name}"
+}
+
+task installDist(type: Copy) {
+ dependsOn jar
+ dependsOn resolveTask(":manager:installDist")
+ from jar.archiveFile
+ into "${resolveProject(":manager").buildDir}/install/manager/lib"
+}
diff --git a/setup/src/main/java/org/openremote/setup/demo/DemoSetupTasks.java b/setup/src/main/java/org/openremote/setup/demo/DemoSetupTasks.java
new file mode 100644
index 000000000..a6e40cab4
--- /dev/null
+++ b/setup/src/main/java/org/openremote/setup/demo/DemoSetupTasks.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.setup.demo;
+
+import org.openremote.model.Container;
+import org.openremote.model.setup.Setup;
+import org.openremote.model.setup.SetupTasks;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Demo setup tasks.
+ */
+public class DemoSetupTasks implements SetupTasks {
+
+ public static final String DEMO_SETUP_TYPE = "demo";
+
+ @Override
+ public List<Setup> createTasks(Container container, String setupType, boolean keycloakEnabled) {
+
+ if (DEMO_SETUP_TYPE.equals(setupType)) {
+ return Arrays.asList(
+ new KeycloakDemoSetup(container),
+ new ManagerDemoSetup(container),
+ new RulesDemoSetup(container),
+ new ManagerDemoAgentSetup(container)
+ );
+ }
+
+ // Do nothing otherwise
+ return null;
+ }
+}
diff --git a/setup/src/main/java/org/openremote/setup/demo/KeycloakDemoSetup.java b/setup/src/main/java/org/openremote/setup/demo/KeycloakDemoSetup.java
new file mode 100644
index 000000000..724059972
--- /dev/null
+++ b/setup/src/main/java/org/openremote/setup/demo/KeycloakDemoSetup.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2020, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.setup.demo;
+
+import org.openremote.manager.setup.AbstractKeycloakSetup;
+import org.openremote.model.Constants;
+import org.openremote.model.Container;
+import org.openremote.model.security.ClientRole;
+import org.openremote.model.security.Tenant;
+import org.openremote.model.security.User;
+
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+/**
+ * We have the following demo users:
+ * <ul>
+ * <li><code>admin</code> - The superuser in the "master" realm with all access</li>
+ * <li><code>smartcity</code> - (Password: smartcity) A user in the "smartcity" realm with read access</li>
+ *
+ * </ul>
+ */
+public class KeycloakDemoSetup extends AbstractKeycloakSetup {
+
+ private static final Logger LOG = Logger.getLogger(KeycloakDemoSetup.class.getName());
+
+ public String smartCityUserId;
+ public Tenant masterTenant;
+ public Tenant tenantCity;
+
+ public KeycloakDemoSetup(Container container) {
+ super(container);
+ }
+
+ @Override
+ public void onStart() throws Exception {
+ super.onStart();
+
+ // Tenants
+ masterTenant = identityService.getIdentityProvider().getTenant(Constants.MASTER_REALM);
+ tenantCity = createTenant("smartcity", "Smart City", true);
+ removeManageAccount("smartcity");
+
+ // Don't allow demo users to write assets
+ ClientRole[] demoUserRoles = Arrays.stream(AbstractKeycloakSetup.REGULAR_USER_ROLES)
+ .filter(clientRole -> clientRole != ClientRole.WRITE_ASSETS)
+ .toArray(ClientRole[]::new);
+
+ // Users
+ User smartCityUser = createUser(tenantCity.getRealm(), "smartcity", "smartcity", "Smart", "City", null, true, demoUserRoles);
+ this.smartCityUserId = smartCityUser.getId();
+ keycloakProvider.updateUserRoles(tenantCity.getRealm(), smartCityUserId, "account"); // Remove all roles for account client
+ }
+}
diff --git a/setup/src/main/java/org/openremote/setup/demo/ManagerDemoAgentSetup.java b/setup/src/main/java/org/openremote/setup/demo/ManagerDemoAgentSetup.java
new file mode 100644
index 000000000..d810a86df
--- /dev/null
+++ b/setup/src/main/java/org/openremote/setup/demo/ManagerDemoAgentSetup.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2020, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.setup.demo;
+
+import org.openremote.agent.protocol.knx.KNXAgent;
+import org.openremote.agent.protocol.velbus.VelbusTCPAgent;
+import org.openremote.container.util.MapAccess;
+import org.openremote.manager.setup.ManagerSetup;
+import org.openremote.model.Container;
+import org.openremote.model.security.Tenant;
+
+import java.util.logging.Logger;
+
+public class ManagerDemoAgentSetup extends ManagerSetup {
+
+ private static final Logger LOG = Logger.getLogger(ManagerDemoAgentSetup.class.getName());
+
+ public static final String SETUP_IMPORT_DEMO_AGENT_KNX = "SETUP_IMPORT_DEMO_AGENT_KNX";
+ public static final String SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP = "SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP";
+ public static final String SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP = "SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP";
+
+ public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS = "SETUP_IMPORT_DEMO_AGENT_VELBUS";
+ public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS_HOST = "SETUP_IMPORT_DEMO_AGENT_VELBUS_HOST";
+ public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS_PORT = "SETUP_IMPORT_DEMO_AGENT_VELBUS_PORT";
+
+ public String masterRealm;
+
+ final protected boolean knx;
+ final protected String knxGatewayIp;
+ final protected String knxLocalIp;
+
+ final protected boolean velbus;
+ final protected String velbusHost;
+ final protected Integer velbusPort;
+
+ public ManagerDemoAgentSetup(Container container) {
+ super(container);
+
+ this.knx = MapAccess.getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_KNX, false);
+ this.knxGatewayIp = MapAccess.getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP, "localhost");
+ this.knxLocalIp = MapAccess.getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP, "localhost");
+
+ this.velbus = MapAccess.getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS, false);
+ this.velbusHost = MapAccess.getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS_HOST, "localhost");
+ this.velbusPort = MapAccess.getInteger(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS_PORT, 6000);
+ }
+
+ @Override
+ public void onStart() throws Exception {
+ super.onStart();
+
+ KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
+ Tenant masterTenant = keycloakDemoSetup.masterTenant;
+ masterRealm = masterTenant.getRealm();
+
+ if (knx) {
+ LOG.info("Enable KNX demo agent, gateway/local IP: " + knxGatewayIp + "/" + knxLocalIp);
+
+ KNXAgent agent = new KNXAgent("Demo KNX agent")
+ .setRealm(masterRealm)
+ .setHost(knxGatewayIp)
+ .setBindHost(knxLocalIp);
+
+ agent = assetStorageService.merge(agent);
+ }
+
+ if (velbus) {
+ LOG.info("Enable Velbus demo agent, host/port: " + velbusHost + "/" + velbusPort);
+
+ VelbusTCPAgent agent = new VelbusTCPAgent("Demo VELBUS agent")
+ .setRealm(masterRealm)
+ .setHost(velbusHost)
+ .setPort(velbusPort);
+
+ agent = assetStorageService.merge(agent);
+ }
+ }
+}
diff --git a/setup/src/main/java/org/openremote/setup/demo/ManagerDemoSetup.java b/setup/src/main/java/org/openremote/setup/demo/ManagerDemoSetup.java
new file mode 100644
index 000000000..997e5f9ba
--- /dev/null
+++ b/setup/src/main/java/org/openremote/setup/demo/ManagerDemoSetup.java
@@ -0,0 +1,1578 @@
+/*
+ * Copyright 2016, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.setup.demo;
+
+import org.openremote.agent.protocol.http.HTTPAgent;
+import org.openremote.agent.protocol.http.HTTPAgentLink;
+import org.openremote.agent.protocol.simulator.SimulatorAgent;
+import org.openremote.agent.protocol.simulator.SimulatorAgentLink;
+import org.openremote.container.util.UniqueIdentifierGenerator;
+import org.openremote.manager.setup.ManagerSetup;
+import org.openremote.model.Constants;
+import org.openremote.model.Container;
+import org.openremote.model.asset.Asset;
+import org.openremote.model.asset.impl.*;
+import org.openremote.model.attribute.Attribute;
+import org.openremote.model.attribute.AttributeLink;
+import org.openremote.model.attribute.AttributeRef;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.geo.GeoJSONPoint;
+import org.openremote.model.security.Tenant;
+import org.openremote.model.simulator.SimulatorReplayDatapoint;
+import org.openremote.model.value.*;
+
+import java.time.Duration;
+import java.time.LocalTime;
+import java.util.Collections;
+import java.util.Random;
+
+import static java.time.temporal.ChronoField.SECOND_OF_DAY;
+import static org.openremote.model.value.ValueType.MultivaluedStringMap;
+
+public class ManagerDemoSetup extends ManagerSetup {
+
+ public static GeoJSONPoint STATIONSPLEIN_LOCATION = new GeoJSONPoint(4.470175, 51.923464);
+ public String masterRealm;
+ public String realmCityTenant;
+ public String area1Id;
+ public String smartcitySimulatorAgentId;
+ public String energyManagementId;
+ public String weatherHttpApiAgentId;
+
+ private final long halfHourInMillis = Duration.ofMinutes(30).toMillis();
+
+ public ManagerDemoSetup(Container container) {
+ super(container);
+ }
+
+ private static int getRandomNumberInRange(int min, int max) {
+ if (min >= max) {
+ throw new IllegalArgumentException("max must be greater than min");
+ }
+ Random r = new Random();
+ return r.nextInt((max - min) + 1) + min;
+ }
+
+ @Override
+ public void onStart() throws Exception {
+ super.onStart();
+
+ KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
+ Tenant masterTenant = keycloakDemoSetup.masterTenant;
+ Tenant tenantCity = keycloakDemoSetup.tenantCity;
+ masterRealm = masterTenant.getRealm();
+ this.realmCityTenant = tenantCity.getRealm();
+
+ // ################################ Demo assets for 'master' realm ###################################
+
+
+ // ################################ Link demo users and assets ###################################
+
+
+ // ################################ Make users restricted ###################################
+
+
+ // ################################ Realm smartcity ###################################
+
+ SimulatorAgent smartcitySimulatorAgent = new SimulatorAgent("Simulator agent");
+ smartcitySimulatorAgent.setRealm(this.realmCityTenant);
+
+ smartcitySimulatorAgent = assetStorageService.merge(smartcitySimulatorAgent);
+ smartcitySimulatorAgentId = smartcitySimulatorAgent.getId();
+
+ LocalTime midnight = LocalTime.of(0, 0);
+
+ // ################################ Realm smartcity - Energy Management ###################################
+
+ ThingAsset energyManagement = new ThingAsset("Energy management");
+ energyManagement.setRealm(this.realmCityTenant);
+ energyManagement.getAttributes().addOrReplace(
+ new Attribute<>("powerTotalProducers", ValueType.NUMBER)
+ .addOrReplaceMeta(
+ new MetaItem<>(MetaItemType.UNITS, Constants.units(Constants.UNITS_KILO, Constants.UNITS_WATT)),
+ new MetaItem<>(MetaItemType.READ_ONLY, true),
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),
+ new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<>("powerTotalConsumers", ValueType.NUMBER).addOrReplaceMeta(
+ new MetaItem<>(MetaItemType.UNITS, Constants.units(Constants.UNITS_KILO, Constants.UNITS_WATT)),
+ new MetaItem<>(MetaItemType.READ_ONLY, true),
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),
+ new MetaItem<>(MetaItemType.RULE_STATE, true))
+ );
+ energyManagement.setId(UniqueIdentifierGenerator.generateId(energyManagement.getName()));
+ energyManagement = assetStorageService.merge(energyManagement);
+ energyManagementId = energyManagement.getId();
+
+ // ### De Rotterdam ###
+ BuildingAsset building1Asset = new BuildingAsset("De Rotterdam");
+ building1Asset.setParent(energyManagement);
+ building1Asset.getAttributes().addOrReplace(
+ new Attribute<>(BuildingAsset.STREET, "Wilhelminakade 139"),
+ new Attribute<>(BuildingAsset.POSTAL_CODE, "3072 AP"),
+ new Attribute<>(BuildingAsset.CITY, "Rotterdam"),
+ new Attribute<>(BuildingAsset.COUNTRY, "Netherlands"),
+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.488324, 51.906577)),
+ new Attribute<>("powerBalance", ValueType.NUMBER).addMeta(
+ new MetaItem<>(MetaItemType.UNITS, Constants.units(Constants.UNITS_KILO, Constants.UNITS_WATT)),
+ new MetaItem<>(MetaItemType.READ_ONLY),
+ new MetaItem<>(MetaItemType.RULE_STATE),
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS))
+ );
+ building1Asset.setId(UniqueIdentifierGenerator.generateId(building1Asset.getName() + "building"));
+ building1Asset = assetStorageService.merge(building1Asset);
+
+ ElectricityStorageAsset storage1Asset = createDemoElectricityStorageAsset("Battery De Rotterdam", building1Asset, new GeoJSONPoint(4.488324, 51.906577));
+ storage1Asset.setManufacturer("Super-B");
+ storage1Asset.setModel("Nomia");
+ storage1Asset.setId(UniqueIdentifierGenerator.generateId(storage1Asset.getName()));
+ storage1Asset = assetStorageService.merge(storage1Asset);
+
+ ElectricityConsumerAsset consumption1Asset = createDemoElectricityConsumerAsset("Consumption De Rotterdam", building1Asset, new GeoJSONPoint(4.487519, 51.906544));
+ consumption1Asset.getAttribute(ElectricityConsumerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 23),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 21),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 20),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 22),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 21),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 22),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 41),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 54),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 63),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 76),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 80),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 79),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 84),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 76),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 82),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 83),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 77),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 71),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 63),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 41),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 27),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 22),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 24),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 20)
+ })
+ )
+ );
+ });
+
+ consumption1Asset.setId(UniqueIdentifierGenerator.generateId(consumption1Asset.getName()));
+ consumption1Asset = assetStorageService.merge(consumption1Asset);
+
+ ElectricityProducerSolarAsset production1Asset = createDemoElectricitySolarProducerAsset("Solar De Rotterdam", building1Asset, new GeoJSONPoint(4.488592, 51.907047));
+ production1Asset.setManufacturer("AEG");
+ production1Asset.setModel("AS-P60");
+ production1Asset.getAttribute(ElectricityProducerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), -10),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), -15),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), -39),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), -52),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), -50),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), -48),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), -36),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), -23),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), -24),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), -18),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), -10),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), -8),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), -3),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ });
+ production1Asset.setEnergyExportTotal(152689d);
+ production1Asset.setPowerExportMax(89.6);
+ production1Asset.setEfficiencyExport(93);
+ production1Asset.setPanelOrientation(ElectricityProducerSolarAsset.PanelOrientation.EAST_WEST);
+ production1Asset.setPanelAzimuth(30);
+ production1Asset.setPanelPitch(20);
+ production1Asset.setId(UniqueIdentifierGenerator.generateId(production1Asset.getName()));
+ production1Asset = assetStorageService.merge(production1Asset);
+
+ // ### Stadhuis ###
+
+ BuildingAsset building2Asset = new BuildingAsset("Stadhuis");
+ building2Asset.setParent(energyManagement);
+ building2Asset.getAttributes().addOrReplace(
+ new Attribute<>(BuildingAsset.STREET, "Coolsingel 40"),
+ new Attribute<>(BuildingAsset.POSTAL_CODE, "3011 AD"),
+ new Attribute<>(BuildingAsset.CITY, "Rotterdam"),
+ new Attribute<>(BuildingAsset.COUNTRY, "Netherlands"),
+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.47985, 51.92274))
+ );
+ building2Asset.setId(UniqueIdentifierGenerator.generateId(building2Asset.getName() + "building"));
+ building2Asset = assetStorageService.merge(building2Asset);
+
+ ElectricityStorageAsset storage2Asset = createDemoElectricityStorageAsset("Battery Stadhuis", building2Asset, new GeoJSONPoint(4.47985, 51.92274));
+ storage2Asset.setManufacturer("LG Chem");
+ storage2Asset.setModel("ESS Industrial");
+ storage2Asset.setId(UniqueIdentifierGenerator.generateId(storage2Asset.getName()));
+ storage2Asset = assetStorageService.merge(storage2Asset);
+
+ ElectricityConsumerAsset consumption2Asset = createDemoElectricityConsumerAsset("Consumption Stadhuis", building2Asset, new GeoJSONPoint(4.47933, 51.92259));
+ consumption2Asset.getAttribute(ElectricityConsumerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 7),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 8),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 7),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 8),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 12),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 22),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 30),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 36),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 39),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 32),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 36),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 44),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 47),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 44),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 33),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 23),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 13),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 8)
+ }
+ )
+ )
+ );
+ });
+ consumption2Asset.setId(UniqueIdentifierGenerator.generateId(consumption2Asset.getName()));
+ consumption2Asset = assetStorageService.merge(consumption2Asset);
+
+ ElectricityProducerSolarAsset production2Asset = createDemoElectricitySolarProducerAsset("Solar Stadhuis", building2Asset, new GeoJSONPoint(4.47945, 51.92301));
+ production2Asset.getAttribute(ElectricityProducerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), -2),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), -3),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), -8),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), -14),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), -12),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), -10),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), -7),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), -5),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), -7),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), -5),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), -3),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), -2),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ });
+ production2Asset.setEnergyExportTotal(88961d);
+ production2Asset.setPowerExportMax(19.2);
+ production2Asset.setEfficiencyExport(79);
+ production2Asset.setPanelOrientation(ElectricityProducerSolarAsset.PanelOrientation.SOUTH);
+ production2Asset.setPanelAzimuth(10);
+ production2Asset.setPanelPitch(40);
+ production2Asset.setManufacturer("Solarwatt");
+ production2Asset.setModel("EasyIn 60M");
+ production2Asset.setId(UniqueIdentifierGenerator.generateId(production2Asset.getName()));
+ production2Asset = assetStorageService.merge(production2Asset);
+
+ // ### Markthal ###
+
+ BuildingAsset building3Asset = new BuildingAsset("Markthal");
+ building3Asset.setParent(energyManagement);
+ building3Asset.getAttributes().addOrReplace(
+ new Attribute<>(BuildingAsset.STREET, "Dominee Jan Scharpstraat 298"),
+ new Attribute<>(BuildingAsset.POSTAL_CODE, "3011 GZ"),
+ new Attribute<>(BuildingAsset.CITY, "Rotterdam"),
+ new Attribute<>(BuildingAsset.COUNTRY, "Netherlands"),
+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.47945, 51.92301)),
+ new Attribute<>("allChargersInUse", ValueType.BOOLEAN)
+ .addMeta(
+ new MetaItem<>(MetaItemType.READ_ONLY))
+ );
+ building3Asset.setId(UniqueIdentifierGenerator.generateId(building3Asset.getName() + "building"));
+ building3Asset = assetStorageService.merge(building3Asset);
+
+ ElectricityProducerSolarAsset production3Asset = createDemoElectricitySolarProducerAsset("Solar Markthal", building3Asset, new GeoJSONPoint(4.47945, 51.92301));
+ production3Asset.getAttribute(ElectricityProducerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), -2),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), -6),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), -10),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), -13),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), -21),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), -14),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), -17),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), -10),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), -9),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), -7),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), -5),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), -4),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), -2),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ });
+ production3Asset.setEnergyExportTotal(24134d);
+ production3Asset.setPowerExportMax(29.8);
+ production3Asset.setEfficiencyExport(91);
+ production3Asset.setPanelOrientation(ElectricityProducerSolarAsset.PanelOrientation.SOUTH);
+ production3Asset.setManufacturer("Sunpower");
+ production3Asset.setModel("E20-327");
+ production3Asset.setPanelAzimuth(10);
+ production3Asset.setPanelPitch(5);
+ production3Asset.setId(UniqueIdentifierGenerator.generateId(production3Asset.getName()));
+ production3Asset = assetStorageService.merge(production3Asset);
+
+ ElectricityChargerAsset charger1Asset = createDemoElectricityChargerAsset("Charger 1 Markthal", building3Asset, new GeoJSONPoint(4.486143, 51.920058));
+ charger1Asset.setPower(0d);
+ charger1Asset.getAttributes().getOrCreate(ElectricityChargerAsset.POWER).addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 2),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 5),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 10),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 5),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 15),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 32),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 35),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 17),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ charger1Asset.setManufacturer("Allego");
+ charger1Asset.setModel("HPC");
+ charger1Asset.setId(UniqueIdentifierGenerator.generateId(charger1Asset.getName()));
+ charger1Asset = assetStorageService.merge(charger1Asset);
+
+ ElectricityChargerAsset charger2Asset = createDemoElectricityChargerAsset("Charger 2 Markthal", building3Asset, new GeoJSONPoint(4.486188, 51.919957));
+ charger2Asset.setPower(0d);
+ charger2Asset.getAttributes().getOrCreate(ElectricityChargerAsset.POWER)
+ .addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 5),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 11),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 5),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 10),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 17),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 14),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 4),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 28),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 32),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 26),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 13),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ charger2Asset.setManufacturer("Bosch");
+ charger2Asset.setModel("EV800");
+ charger2Asset.setId(UniqueIdentifierGenerator.generateId(charger2Asset.getName()));
+ charger2Asset = assetStorageService.merge(charger2Asset);
+
+ ElectricityChargerAsset charger3Asset = createDemoElectricityChargerAsset("Charger 3 Markthal", building3Asset, new GeoJSONPoint(4.486232, 51.919856));
+ charger3Asset.setPower(0d);
+ charger3Asset.getAttributes().getOrCreate(ElectricityChargerAsset.POWER)
+ .addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 4),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 4),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 7),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 2),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 18),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 4),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 29),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 22),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 14),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ charger3Asset.setManufacturer("Siemens");
+ charger3Asset.setModel("CPC 50");
+ charger3Asset.setId(UniqueIdentifierGenerator.generateId(charger3Asset.getName()));
+ charger3Asset = assetStorageService.merge(charger3Asset);
+
+ ElectricityChargerAsset charger4Asset = createDemoElectricityChargerAsset("Charger 4 Markthal", building3Asset, new GeoJSONPoint(4.486286, 51.919733));
+ charger4Asset.setPower(0d);
+ charger4Asset.getAttributes().getOrCreate(ElectricityChargerAsset.POWER)
+ .addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 3),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 4),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 17),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 15),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 8),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 16),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 4),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 15),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 30),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 11),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 16),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 7),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 4)
+ }
+ )
+ )
+ );
+
+ charger4Asset.setManufacturer("SemaConnect");
+ charger4Asset.setModel("The Series 6");
+ charger4Asset.setId(UniqueIdentifierGenerator.generateId(charger4Asset.getName()));
+ charger4Asset = assetStorageService.merge(charger4Asset);
+
+ // ### Erasmianum ###
+
+ BuildingAsset building4Asset = new BuildingAsset("Erasmianum");
+ building4Asset.setParent(energyManagement);
+ building4Asset.getAttributes().addOrReplace(
+ new Attribute<>(BuildingAsset.STREET, "Wytemaweg 25"),
+ new Attribute<>(BuildingAsset.POSTAL_CODE, "3015 CN"),
+ new Attribute<>(BuildingAsset.CITY, "Rotterdam"),
+ new Attribute<>(BuildingAsset.COUNTRY, "Netherlands"),
+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.468324, 51.912062))
+ );
+ building4Asset.setId(UniqueIdentifierGenerator.generateId(building4Asset.getName() + "building"));
+ building4Asset = assetStorageService.merge(building4Asset);
+
+ ElectricityConsumerAsset consumption4Asset = createDemoElectricityConsumerAsset("Consumption Erasmianum", building4Asset, new GeoJSONPoint(4.468324, 51.912062));
+ consumption4Asset.getAttribute(ElectricityConsumerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 5),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 7),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 5),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 6),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 9),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 23),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 37),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 41),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 47),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 49),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 51),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 43),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 48),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 45),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 46),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 41),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 30),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 19),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 15),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 7),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 6)
+ }
+ )
+ )
+ );
+ });
+ consumption4Asset.setId(UniqueIdentifierGenerator.generateId(consumption4Asset.getName()));
+ consumption4Asset = assetStorageService.merge(consumption4Asset);
+
+ // ### Oostelijk zwembad ###
+
+ BuildingAsset building5Asset = new BuildingAsset("Oostelijk zwembad");
+ building5Asset.setParent(energyManagement);
+ building5Asset.getAttributes().addOrReplace(
+ new Attribute<>(BuildingAsset.STREET, "Gerdesiaweg 480"),
+ new Attribute<>(BuildingAsset.POSTAL_CODE, "3061 RA"),
+ new Attribute<>(BuildingAsset.CITY, "Rotterdam"),
+ new Attribute<>(BuildingAsset.COUNTRY, "Netherlands"),
+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.498048, 51.925770))
+ );
+ building5Asset.setId(UniqueIdentifierGenerator.generateId(building5Asset.getName() + "building"));
+ building5Asset = assetStorageService.merge(building5Asset);
+
+ ElectricityConsumerAsset consumption5Asset = createDemoElectricityConsumerAsset("Consumption Zwembad", building5Asset, new GeoJSONPoint(4.498048, 51.925770));
+ consumption5Asset.getAttribute(ElectricityConsumerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 16),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 16),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 15),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 16),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 17),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 16),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 24),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 35),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 32),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 33),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 33),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 31),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 36),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 32),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 37),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 37),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 35),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 24),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 19)
+ }
+ )
+ )
+ );
+ });
+ consumption5Asset.setId(UniqueIdentifierGenerator.generateId(consumption5Asset.getName()));
+ consumption5Asset = assetStorageService.merge(consumption5Asset);
+
+ ElectricityProducerSolarAsset production5Asset = createDemoElectricitySolarProducerAsset("Solar Zwembad", building5Asset, new GeoJSONPoint(4.498281, 51.925507));
+ production5Asset.getAttribute(ElectricityProducerAsset.POWER).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), -1),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), -3),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), -8),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), -30),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), -44),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), -42),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), -41),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), -29),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), -19),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), -16),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), -11),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), -4),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), -3),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), -2),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 0),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0)
+ }
+ )
+ )
+ );
+ });
+ production5Asset.setEnergyExportTotal(23461d);
+ production5Asset.setPowerExportMax(76.2);
+ production5Asset.setEfficiencyExport(86);
+ production5Asset.setPanelOrientation(ElectricityProducerSolarAsset.PanelOrientation.SOUTH);
+ production5Asset.setManufacturer("S-Energy");
+ production5Asset.setModel("SN260P-10");
+ production5Asset.setPanelAzimuth(50);
+ production5Asset.setPanelPitch(15);
+ production5Asset.setId(UniqueIdentifierGenerator.generateId(production5Asset.getName()));
+ production5Asset = assetStorageService.merge(production5Asset);
+
+ // ### Weather ###
+ HTTPAgent weatherHttpApiAgent = new HTTPAgent("Weather Agent");
+ weatherHttpApiAgent.setParent(energyManagement);
+ weatherHttpApiAgent.setBaseURI("https://api.openweathermap.org/data/2.5/");
+
+ MultivaluedStringMap queryParams = new MultivaluedStringMap();
+ queryParams.put("appid", Collections.singletonList("c3ecbf09be5267cd280676a01acd3360"));
+ queryParams.put("lat", Collections.singletonList("51.918849"));
+ queryParams.put("lon", Collections.singletonList("4.463250"));
+ queryParams.put("units", Collections.singletonList("metric"));
+ weatherHttpApiAgent.setRequestQueryParameters(queryParams);
+
+ MultivaluedStringMap headers = new MultivaluedStringMap();
+ headers.put("Accept", Collections.singletonList("application/json"));
+ weatherHttpApiAgent.setRequestHeaders(headers);
+
+ weatherHttpApiAgent = assetStorageService.merge(weatherHttpApiAgent);
+ weatherHttpApiAgentId = weatherHttpApiAgent.getId();
+
+ WeatherAsset weather = new WeatherAsset("Weather");
+ weather.setParent(energyManagement);
+ weather.setId(UniqueIdentifierGenerator.generateId(weather.getName()));
+
+ HTTPAgentLink agentLink = new HTTPAgentLink(weatherHttpApiAgentId);
+ agentLink.setPath("weather");
+ agentLink.setPollingMillis((int)halfHourInMillis);
+
+ weather.getAttributes().addOrReplace(
+ new Attribute<>("currentWeather", ValueType.JSON_OBJECT)
+ .addMeta(
+ new MetaItem<>(MetaItemType.AGENT_LINK, agentLink),
+ new MetaItem<>(MetaItemType.LABEL, "Open Weather Map API weather end point"),
+ new MetaItem<>(MetaItemType.READ_ONLY, true),
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS, false),
+ new MetaItem<>(MetaItemType.RULE_STATE, false),
+ new MetaItem<>(MetaItemType.ATTRIBUTE_LINKS, new AttributeLink[] {
+ createWeatherApiAttributeLink(weather.getId(), "main", "temp", "temperature"),
+ createWeatherApiAttributeLink(weather.getId(), "main", "humidity", "humidity"),
+ createWeatherApiAttributeLink(weather.getId(), "wind", "speed", "windSpeed"),
+ createWeatherApiAttributeLink(weather.getId(), "wind", "deg", "windDirection")
+ })
+ ));
+ weather.getAttribute("windSpeed").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS),
+ new MetaItem<>(MetaItemType.RULE_STATE)
+ );
+ });
+ weather.getAttribute("temperature").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS),
+ new MetaItem<>(MetaItemType.RULE_STATE)
+ );
+ });
+ weather.getAttribute("windDirection").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS),
+ new MetaItem<>(MetaItemType.RULE_STATE)
+ );
+ });
+ weather.getAttribute("humidity").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS),
+ new MetaItem<>(MetaItemType.RULE_STATE)
+ );
+ });
+ new Attribute<>(Asset.LOCATION, new GeoJSONPoint(4.463250, 51.918849));
+ weather = assetStorageService.merge(weather);
+
+ // ################################ Realm smartcity - Environment monitor ###################################
+
+ Asset<?> environmentMonitor = new ThingAsset("Environment monitor");
+ environmentMonitor.setRealm(this.realmCityTenant);
+ environmentMonitor.setId(UniqueIdentifierGenerator.generateId(environmentMonitor.getName()));
+ environmentMonitor = assetStorageService.merge(environmentMonitor);
+
+ EnvironmentSensorAsset environment1Asset = createDemoEnvironmentAsset("Oudehaven", environmentMonitor, new GeoJSONPoint(4.49313, 51.91885), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId));
+ EnvironmentSensorAsset environment2Asset = createDemoEnvironmentAsset("Kaappark", environmentMonitor, new GeoJSONPoint(4.480434, 51.899287), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId));
+ EnvironmentSensorAsset environment3Asset = createDemoEnvironmentAsset("Museumpark", environmentMonitor, new GeoJSONPoint(4.472457, 51.912047), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId));
+ EnvironmentSensorAsset environment4Asset = createDemoEnvironmentAsset("Eendrachtsplein", environmentMonitor, new GeoJSONPoint(4.473599, 51.916292), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId));
+
+ EnvironmentSensorAsset[] environmentArray = {environment1Asset, environment2Asset, environment3Asset, environment4Asset};
+ for (EnvironmentSensorAsset asset : environmentArray) {
+ asset.setManufacturer("Intemo");
+ asset.setModel("Josene outdoor");
+ asset.getAttribute(EnvironmentSensorAsset.OZONE).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), getRandomNumberInRange(90,110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), getRandomNumberInRange(90,110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), getRandomNumberInRange(90,110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), getRandomNumberInRange(90,110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), getRandomNumberInRange(110,120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), getRandomNumberInRange(115,125)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), getRandomNumberInRange(115,125)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), getRandomNumberInRange(110,120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), getRandomNumberInRange(90,110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), getRandomNumberInRange(90,110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), getRandomNumberInRange(80,90)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), getRandomNumberInRange(80,90))
+ }
+ )
+ )
+ );
+ });
+ asset.setId(UniqueIdentifierGenerator.generateId(asset.getName()));
+ asset = assetStorageService.merge(asset);
+ }
+
+ GroundwaterSensorAsset groundwater1Asset = createDemoGroundwaterAsset("Leuvehaven", environmentMonitor, new GeoJSONPoint(4.48413, 51.91431));
+ GroundwaterSensorAsset groundwater2Asset = createDemoGroundwaterAsset("Steiger", environmentMonitor, new GeoJSONPoint(4.482887, 51.920082));
+ GroundwaterSensorAsset groundwater3Asset = createDemoGroundwaterAsset("Stadhuis", environmentMonitor, new GeoJSONPoint(4.480876, 51.923212));
+
+ GroundwaterSensorAsset[] groundwaterArray = {groundwater1Asset, groundwater2Asset, groundwater3Asset};
+ for (GroundwaterSensorAsset asset : groundwaterArray) {
+ asset.setManufacturer("Eijkelkamp");
+ asset.setModel("TeleControlNet");
+ asset.getAttribute(GroundwaterSensorAsset.SOIL_TEMPERATURE).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 12.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 12.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 12.0),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 11.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 11.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 11.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 11.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 12.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 12.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 13.5),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 13.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 15.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 15.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 15.5),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 15.5),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 15.4),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 15.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 15.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 14.6),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 14.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 13.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 13.4),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 12.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 12.3)
+ }
+ )
+ )
+ );
+ });
+ asset.getAttribute(GroundwaterSensorAsset.WATER_LEVEL).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), getRandomNumberInRange(100, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), getRandomNumberInRange(100, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), getRandomNumberInRange(90, 110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), getRandomNumberInRange(100, 110)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), getRandomNumberInRange(100, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), getRandomNumberInRange(110, 120))
+ }
+ )
+ )
+ );
+ });
+ asset.setId(UniqueIdentifierGenerator.generateId(asset.getName()));
+ asset = assetStorageService.merge(asset);
+ }
+
+ // ################################ Realm smartcity - Mobility and Safety ###################################
+
+ Asset<?> mobilityAndSafety = new ThingAsset("Mobility and safety");
+ mobilityAndSafety.setRealm(this.realmCityTenant);
+ mobilityAndSafety.setId(UniqueIdentifierGenerator.generateId(mobilityAndSafety.getName()));
+ mobilityAndSafety = assetStorageService.merge(mobilityAndSafety);
+
+ // ### Parking ###
+
+ GroupAsset parkingGroupAsset = new GroupAsset("Parking group", ParkingAsset.class);
+ parkingGroupAsset.setParent(mobilityAndSafety);
+ parkingGroupAsset.getAttributes().addOrReplace(
+ new Attribute<>("totalOccupancy", ValueType.POSITIVE_INTEGER)
+ .addMeta(
+ new MetaItem<>(MetaItemType.UNITS, Constants.units(Constants.UNITS_PERCENTAGE)),
+ new MetaItem<>(MetaItemType.CONSTRAINTS, ValueConstraint.constraints(new ValueConstraint.Min(0), new ValueConstraint.Max(100))),
+ new MetaItem<>(MetaItemType.READ_ONLY),
+ new MetaItem<>(MetaItemType.RULE_STATE),
+ new MetaItem<>(MetaItemType.STORE_DATA_POINTS)
+ ));
+ parkingGroupAsset.setId(UniqueIdentifierGenerator.generateId(parkingGroupAsset.getName()));
+ parkingGroupAsset = assetStorageService.merge(parkingGroupAsset);
+
+ ParkingAsset parking1Asset = createDemoParkingAsset("Markthal", parkingGroupAsset, new GeoJSONPoint(4.48527, 51.91984))
+ .setManufacturer("SKIDATA")
+ .setModel("Barrier.Gate");
+ parking1Asset.getAttribute(ParkingAsset.SPACES_OCCUPIED).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 34),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 37),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 31),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 36),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 32),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 39),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 47),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 53),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 165),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 301),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 417),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 442),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 489),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 467),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 490),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 438),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 457),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 402),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 379),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 336),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 257),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 204),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 112),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 75)
+ }
+ )
+ )
+ );
+ });
+ parking1Asset.setPriceHourly(3.75);
+ parking1Asset.setPriceDaily(25.00);
+ parking1Asset.setSpacesTotal(512);
+ parking1Asset.getAttribute(ParkingAsset.SPACES_TOTAL).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.RULE_STATE));
+ });
+ parking1Asset.setId(UniqueIdentifierGenerator.generateId(parking1Asset.getName()));
+ parking1Asset = assetStorageService.merge(parking1Asset);
+
+ ParkingAsset parking2Asset = createDemoParkingAsset("Lijnbaan", parkingGroupAsset, new GeoJSONPoint(4.47681, 51.91849));
+ parking2Asset.setManufacturer("SKIDATA");
+ parking2Asset.setModel("Barrier.Gate");
+ parking2Asset.getAttribute(ParkingAsset.SPACES_OCCUPIED).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 31),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 24),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 36),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 38),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 46),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 48),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 52),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 89),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 142),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 187),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 246),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 231),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 367),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 345),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 386),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 312),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 363),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 276),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 249),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 256),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 123),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 153),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 83),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 25)
+ }
+ )
+ )
+ );
+ });
+ parking2Asset.setPriceHourly(3.50);
+ parking2Asset.setPriceDaily(23.00);
+ parking2Asset.setSpacesTotal(390);
+ parking2Asset.getAttribute(ParkingAsset.SPACES_TOTAL).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.RULE_STATE));
+ });
+ parking2Asset.setId(UniqueIdentifierGenerator.generateId(parking2Asset.getName()));
+ parking2Asset = assetStorageService.merge(parking2Asset);
+
+ ParkingAsset parking3Asset = createDemoParkingAsset("Erasmusbrug", parkingGroupAsset, new GeoJSONPoint(4.48207, 51.91127));
+ parking3Asset.setManufacturer("Kiestra");
+ parking3Asset.setModel("Genius Rainbow");
+ parking3Asset.getAttribute(ParkingAsset.SPACES_OCCUPIED).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 25),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 23),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 23),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 21),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 18),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 13),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 29),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 36),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 119),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 257),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 357),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 368),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 362),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 349),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 370),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 367),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 355),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 314),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 254),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 215),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 165),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 149),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 108),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 47)
+ }
+ )
+ )
+ );
+ });
+ parking3Asset.setPriceHourly(3.40);
+ parking3Asset.setPriceDaily(20.00);
+ parking3Asset.setSpacesTotal(373);
+ parking3Asset.getAttribute(ParkingAsset.SPACES_TOTAL).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(MetaItemType.RULE_STATE));
+ });
+ parking3Asset.setId(UniqueIdentifierGenerator.generateId(parking3Asset.getName()));
+ parking3Asset = assetStorageService.merge(parking3Asset);
+
+ // ### Crowd control ###
+
+ ThingAsset assetAreaStation = new ThingAsset("Stationsplein");
+ assetAreaStation.setParent(mobilityAndSafety)
+ .getAttributes().addOrReplace(
+ new Attribute<>(Asset.LOCATION, STATIONSPLEIN_LOCATION),
+ new Attribute<>(BuildingAsset.POSTAL_CODE, "3013 AK"),
+ new Attribute<>(BuildingAsset.CITY, "Rotterdam"),
+ new Attribute<>(BuildingAsset.COUNTRY, "Netherlands")
+ );
+ assetAreaStation.setId(UniqueIdentifierGenerator.generateId(assetAreaStation.getName()));
+ assetAreaStation = assetStorageService.merge(assetAreaStation);
+ area1Id = assetAreaStation.getId();
+
+ PeopleCounterAsset peopleCounter1Asset = createDemoPeopleCounterAsset("People Counter South", assetAreaStation, new GeoJSONPoint(4.470147, 51.923171), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId));
+ peopleCounter1Asset.setManufacturer("ViNotion");
+ peopleCounter1Asset.setModel("ViSense");
+ peopleCounter1Asset.getAttribute(PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0.0),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0.4),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0.5),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 0.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 1.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 2.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 2.4),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 1.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 1.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 2.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 1.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 1.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 2.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 3.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 2.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 2.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 1.6),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 1.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 1.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0.8)
+ }
+ )
+ )
+ );
+ });
+ peopleCounter1Asset.setId(UniqueIdentifierGenerator.generateId(peopleCounter1Asset.getName()));
+ peopleCounter1Asset = assetStorageService.merge(peopleCounter1Asset);
+
+ Asset<?> peopleCounter2Asset = createDemoPeopleCounterAsset("People Counter North", assetAreaStation, new GeoJSONPoint(4.469329, 51.923700), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId));
+ peopleCounter2Asset.setManufacturer("Axis");
+ peopleCounter2Asset.setModel("P1375-E");
+ peopleCounter2Asset.getAttribute(PeopleCounterAsset.COUNT_GROWTH_PER_MINUTE).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), 0.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), 0.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), 0.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), 0.1),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), 0.0),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), 0.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), 0.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), 0.6),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), 1.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), 2.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), 2.8),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), 1.6),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), 1.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), 2.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), 1.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), 1.6),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), 2.4),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), 3.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), 2.9),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), 2.3),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), 1.7),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), 1.4),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), 1.2),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), 0.7)
+ }
+ )
+ )
+ );
+ });
+ peopleCounter2Asset.setId(UniqueIdentifierGenerator.generateId(peopleCounter2Asset.getName()));
+ peopleCounter2Asset = assetStorageService.merge(peopleCounter2Asset);
+
+ MicrophoneAsset microphone1Asset = createDemoMicrophoneAsset("Microphone South", assetAreaStation, new GeoJSONPoint(4.470362, 51.923201), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), getRandomNumberInRange(50,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), getRandomNumberInRange(50,55)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), getRandomNumberInRange(50,55)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), getRandomNumberInRange(50,55)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), getRandomNumberInRange(60,70)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), getRandomNumberInRange(60,70)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), getRandomNumberInRange(50,60))
+ }
+ ));
+ microphone1Asset.setManufacturer("Sorama");
+ microphone1Asset.setModel("CAM1K");
+ microphone1Asset.setId(UniqueIdentifierGenerator.generateId(microphone1Asset.getName()));
+ microphone1Asset = assetStorageService.merge(microphone1Asset);
+
+ MicrophoneAsset microphone2Asset = createDemoMicrophoneAsset("Microphone North", assetAreaStation, new GeoJSONPoint(4.469190, 51.923786), () ->
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[] {
+ new SimulatorReplayDatapoint(midnight.get(SECOND_OF_DAY), getRandomNumberInRange(50,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(1).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(2).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(3).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(4).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(5).get(SECOND_OF_DAY), getRandomNumberInRange(45,50)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), getRandomNumberInRange(50,55)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), getRandomNumberInRange(50,55)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), getRandomNumberInRange(50,55)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), getRandomNumberInRange(60,70)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), getRandomNumberInRange(55,60)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), getRandomNumberInRange(60,70)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), getRandomNumberInRange(60,65)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), getRandomNumberInRange(50,60))
+ }
+ ));
+ microphone2Asset.setManufacturer("Sorama");
+ microphone2Asset.setModel("CAM1K");
+ microphone2Asset.setId(UniqueIdentifierGenerator.generateId(microphone2Asset.getName()));
+ microphone2Asset = assetStorageService.merge(microphone2Asset);
+
+ LightAsset lightStation1Asset = createDemoLightAsset("Station Light NW", assetAreaStation, new GeoJSONPoint(4.468874, 51.923881));
+ lightStation1Asset.setManufacturer("Philips");
+ lightStation1Asset.setModel("CityTouch");
+ lightStation1Asset.setId(UniqueIdentifierGenerator.generateId(lightStation1Asset.getName()));
+ lightStation1Asset = assetStorageService.merge(lightStation1Asset);
+
+ LightAsset lightStation2Asset = createDemoLightAsset("Station Light NE", assetAreaStation, new GeoJSONPoint(4.470539, 51.923991));
+ lightStation2Asset.setManufacturer("Philips");
+ lightStation2Asset.setModel("CityTouch");
+ lightStation2Asset.setId(UniqueIdentifierGenerator.generateId(lightStation2Asset.getName()));
+ lightStation2Asset = assetStorageService.merge(lightStation2Asset);
+
+ LightAsset lightStation3Asset = createDemoLightAsset("Station Light S", assetAreaStation, new GeoJSONPoint(4.470558, 51.923186));
+ lightStation3Asset.setManufacturer("Philips");
+ lightStation3Asset.setModel("CityTouch");
+ lightStation3Asset.setId(UniqueIdentifierGenerator.generateId(lightStation3Asset.getName()));
+ lightStation3Asset = assetStorageService.merge(lightStation3Asset);
+
+ // ### Lighting controller ###
+
+ LightAsset lightingControllerOPAsset = createDemoLightControllerAsset("Lighting Noordereiland", mobilityAndSafety, new GeoJSONPoint(4.496177, 51.915060));
+ lightingControllerOPAsset.setManufacturer("Pharos");
+ lightingControllerOPAsset.setModel("LPC X");
+ lightingControllerOPAsset.setId(UniqueIdentifierGenerator.generateId(lightingControllerOPAsset.getName()));
+ lightingControllerOPAsset = assetStorageService.merge(lightingControllerOPAsset);
+
+ LightAsset lightOP1Asset = createDemoLightAsset("Ons Park 1", lightingControllerOPAsset, new GeoJSONPoint(4.49626, 51.91516));
+ lightOP1Asset.setManufacturer("Schréder");
+ lightOP1Asset.setModel("Axia 2");
+ lightOP1Asset.setId(UniqueIdentifierGenerator.generateId(lightOP1Asset.getName()));
+ lightOP1Asset = assetStorageService.merge(lightOP1Asset);
+
+ LightAsset lightOP2Asset = createDemoLightAsset("Ons Park 2", lightingControllerOPAsset, new GeoJSONPoint(4.49705, 51.91549));
+ lightOP2Asset.setManufacturer("Schréder");
+ lightOP2Asset.setModel("Axia 2");
+ lightOP2Asset.setId(UniqueIdentifierGenerator.generateId(lightOP2Asset.getName()));
+ lightOP2Asset = assetStorageService.merge(lightOP2Asset);
+
+ LightAsset lightOP3Asset = createDemoLightAsset("Ons Park 3", lightingControllerOPAsset, new GeoJSONPoint(4.49661, 51.91495));
+ lightOP3Asset.setManufacturer("Schréder");
+ lightOP3Asset.setModel("Axia 2");
+ lightOP3Asset.setId(UniqueIdentifierGenerator.generateId(lightOP3Asset.getName()));
+ lightOP3Asset = assetStorageService.merge(lightOP3Asset);
+
+ LightAsset lightOP4Asset = createDemoLightAsset("Ons Park 4", lightingControllerOPAsset, new GeoJSONPoint(4.49704, 51.91520));
+ lightOP4Asset.setManufacturer("Schréder");
+ lightOP4Asset.setModel("Axia 2");
+ lightOP4Asset.setId(UniqueIdentifierGenerator.generateId(lightOP4Asset.getName()));
+ lightOP4Asset = assetStorageService.merge(lightOP4Asset);
+
+ LightAsset lightOP5Asset = createDemoLightAsset("Ons Park 5", lightingControllerOPAsset, new GeoJSONPoint(4.49758, 51.91440));
+ lightOP5Asset.setManufacturer("Schréder");
+ lightOP5Asset.setModel("Axia 2");
+ lightOP5Asset.setId(UniqueIdentifierGenerator.generateId(lightOP5Asset.getName()));
+ lightOP5Asset = assetStorageService.merge(lightOP5Asset);
+
+ LightAsset lightOP6Asset = createDemoLightAsset("Ons Park 6", lightingControllerOPAsset, new GeoJSONPoint(4.49786, 51.91452));
+ lightOP6Asset.setManufacturer("Schréder");
+ lightOP6Asset.setModel("Axia 2");
+ lightOP6Asset.setId(UniqueIdentifierGenerator.generateId(lightOP6Asset.getName()));
+ lightOP6Asset = assetStorageService.merge(lightOP6Asset);
+
+ // ### Ships ###
+
+ GroupAsset shipGroupAsset = new GroupAsset("Ship group", ShipAsset.class);
+ shipGroupAsset.setParent(mobilityAndSafety);
+ shipGroupAsset.setId(UniqueIdentifierGenerator.generateId(shipGroupAsset.getName()));
+ shipGroupAsset = assetStorageService.merge(shipGroupAsset);
+
+ ShipAsset ship1Asset = createDemoShipAsset("Hotel New York", shipGroupAsset, new GeoJSONPoint(4.48527, 51.91984));
+ ship1Asset.setLength(12);
+ ship1Asset.setShipType("Passenger");
+ ship1Asset.setIMONumber(9183527);
+ ship1Asset.setMSSINumber(244650537);
+ ship1Asset.getAttribute(Asset.LOCATION).ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem<>(
+ MetaItemType.AGENT_LINK,
+ new SimulatorAgentLink(smartcitySimulatorAgentId).setReplayData(
+ new SimulatorReplayDatapoint[]{
+ new SimulatorReplayDatapoint(midnight.plusHours(6).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(6).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(7).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(8).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(9).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(10).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(11).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(12).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(13).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(14).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(15).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(16).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(17).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(18).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(19).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(20).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(21).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(22).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(5).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(10).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(15).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(20).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(25).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(30).get(SECOND_OF_DAY), new GeoJSONPoint(4.484374, 51.903518)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(35).get(SECOND_OF_DAY), new GeoJSONPoint(4.479779, 51.904404)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(40).get(SECOND_OF_DAY), new GeoJSONPoint(4.482914, 51.906769)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(45).get(SECOND_OF_DAY), new GeoJSONPoint(4.486156, 51.908570)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(50).get(SECOND_OF_DAY), new GeoJSONPoint(4.483362, 51.911897)),
+ new SimulatorReplayDatapoint(midnight.plusHours(23).plusMinutes(55).get(SECOND_OF_DAY), new GeoJSONPoint(4.482669, 51.916436))
+ }
+ )
+ )
+ );
+ });
+ ship1Asset.setId(UniqueIdentifierGenerator.generateId(ship1Asset.getName()));
+ ship1Asset = assetStorageService.merge(ship1Asset);
+ }
+
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ protected static AttributeLink createWeatherApiAttributeLink(String assetId, String jsonParentName, String jsonName, String parameter) {
+ return new AttributeLink(
+ new AttributeRef(assetId, parameter),
+ null,
+ new ValueFilter[]{
+ new JsonPathFilter("$." + jsonParentName + "." + jsonName, true, false),
+ }
+ );
+ }
+}
diff --git a/setup/src/main/java/org/openremote/setup/demo/RulesDemoSetup.java b/setup/src/main/java/org/openremote/setup/demo/RulesDemoSetup.java
new file mode 100644
index 000000000..267b04d4c
--- /dev/null
+++ b/setup/src/main/java/org/openremote/setup/demo/RulesDemoSetup.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2020, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.setup.demo;
+
+import org.apache.commons.io.IOUtils;
+import org.openremote.manager.setup.ManagerSetup;
+import org.openremote.model.Container;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.rules.Ruleset;
+import org.openremote.model.rules.TenantRuleset;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.logging.Logger;
+
+import static org.openremote.model.rules.Ruleset.SHOW_ON_LIST;
+
+public class RulesDemoSetup extends ManagerSetup {
+
+ private static final Logger LOG = Logger.getLogger(RulesDemoSetup.class.getName());
+
+ public RulesDemoSetup(Container container) {
+ super(container);
+ }
+
+ public Long tenantSmartCityRulesetId;
+
+ @Override
+ public void onStart() throws Exception {
+
+ KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
+ ManagerDemoSetup managerDemoSetup = setupService.getTaskOfType(ManagerDemoSetup.class);
+
+ LOG.info("Importing demo rulesets");
+
+ // ################################ Rules demo data ###################################
+
+ // SmartCity geofences
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/DeKuip.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "De Kuip", Ruleset.Lang.JSON, rules
+ ).setAccessPublicRead(true);
+ ruleset.getMeta().addOrReplace(
+ new MetaItem<>(SHOW_ON_LIST));
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/Euromast.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Euromast", Ruleset.Lang.JSON, rules
+ ).setAccessPublicRead(true);
+ ruleset.getMeta().addOrReplace(
+ new MetaItem<>(SHOW_ON_LIST));
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/Markthal.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Markthal", Ruleset.Lang.JSON, rules
+ ).setAccessPublicRead(true);
+ ruleset.getMeta().addOrReplace(
+ new MetaItem<>(SHOW_ON_LIST));
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/MarkthalChargersInUse.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Markthal: All chargers in use", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/OnsParkBrightStrongWinds.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Ons Park: Brighten lights", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/OnsParkDimLightWinds.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Ons Park: Dim lights", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/StationCrowded.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Station: Crowded square", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/EnvironmentAlerts.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Environment monitoring: Alerts", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/TotalPowerConsumption.flow")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Total power consumption", Ruleset.Lang.FLOW, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/TotalSolarProduction.flow")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Total power production", Ruleset.Lang.FLOW, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/RotterdamPowerBalance.flow")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "De Rotterdam: Power balance", Ruleset.Lang.FLOW, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/ParkingOccupiedPercentage.flow")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Parking: Occupied spaces", Ruleset.Lang.FLOW, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/ParkingFull.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Parking: Almost full", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/RotterdamBatteryUse.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "De Rotterdam: Battery use", Ruleset.Lang.JSON, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/smartcity/LightGroupOnOff.flow")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakDemoSetup.tenantCity.getRealm(), "Light group: On/Off", Ruleset.Lang.FLOW, rules
+ );
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+ }
+}
diff --git a/setup/src/main/java/org/openremote/test/setup/RulesTestSetup.java b/setup/src/main/java/org/openremote/test/setup/RulesTestSetup.java
deleted file mode 100644
index 35042657a..000000000
--- a/setup/src/main/java/org/openremote/test/setup/RulesTestSetup.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2020, OpenRemote Inc.
- *
- * See the CONTRIBUTORS.txt file in the distribution for a
- * full listing of individual contributors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.openremote.test.setup;
-
-import org.apache.commons.io.IOUtils;
-import org.openremote.manager.setup.ManagerSetup;
-import org.openremote.model.Container;
-import org.openremote.model.attribute.MetaItem;
-import org.openremote.model.rules.AssetRuleset;
-import org.openremote.model.rules.Ruleset;
-import org.openremote.model.rules.TenantRuleset;
-
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.logging.Logger;
-
-import static org.openremote.model.rules.Ruleset.Lang.GROOVY;
-import static org.openremote.model.rules.Ruleset.SHOW_ON_LIST;
-
-public class RulesTestSetup extends ManagerSetup {
-
- private static final Logger LOG = Logger.getLogger(RulesTestSetup.class.getName());
-
- public RulesTestSetup(Container container) {
- super(container);
- }
-
- public Long apartmentActionsRulesetId;
- public Long tenantBuildingRulesetId;
- public Long tenantSmartCityRulesetId;
-
- @Override
- public void onStart() throws Exception {
-
- KeycloakTestSetup keycloakTestSetup = setupService.getTaskOfType(KeycloakTestSetup.class);
- ManagerTestSetup managerTestSetup = setupService.getTaskOfType(ManagerTestSetup.class);
-
- LOG.info("Importing demo rulesets");
-
- // ################################ Rules demo data ###################################
-
- // Apartment 1
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ResidencePresenceDetection.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerTestSetup.apartment1Id, "Demo Residence - Presence Detection with motion and CO2 sensors", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ResidenceVacationMode.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerTestSetup.apartment1Id, "Demo Residence - Vacation Mode", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ResidenceAutoVentilation.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerTestSetup.apartment1Id, "Demo Residence - Auto Ventilation", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ResidenceNotifyAlarmTrigger.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerTestSetup.apartment1Id, "Demo Residence - Notify Alarm Trigger", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ResidenceSmartSwitch.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerTestSetup.apartment1Id, "Demo Residence - Smart Start Switch", Ruleset.Lang.GROOVY, rules
- );
- ruleset.setEnabled(false);
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
-
- // Apartment 2
-// try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ResidenceAllLightsOff.js")) {
-// String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
-// Ruleset ruleset = new AssetRuleset(
-// managerTestSetup.apartment2Id, "Demo Residence - All Lights Off", Ruleset.Lang.JAVASCRIPT, rules
-// );
-// apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
-// }
-
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/ConsoleLocation.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new TenantRuleset(
- keycloakTestSetup.tenantBuilding.getRealm(), "Demo Console Location", Ruleset.Lang.GROOVY, rules
- ).setAccessPublicRead(true);
- tenantBuildingRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
-
- // People counter
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/SmartCityCamera.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerTestSetup.peopleCounter3AssetId, "PeopleCounter 3 Rules", GROOVY, rules
- );
- rulesetStorageService.merge(ruleset);
- }
-
- // SmartCity geofences
- try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/org/openremote/test/rules/Geofence.json")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new TenantRuleset(
- keycloakTestSetup.tenantCity.getRealm(), "Demo Geofences", Ruleset.Lang.JSON, rules
- ).setAccessPublicRead(true);
- ruleset.getMeta().addOrReplace(
- new MetaItem<>(SHOW_ON_LIST));
- tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- }
-}
diff --git a/setup/src/main/resources/META-INF/services/org.openremote.model.setup.SetupTasks b/setup/src/main/resources/META-INF/services/org.openremote.model.setup.SetupTasks
new file mode 100644
index 000000000..628b9706b
--- /dev/null
+++ b/setup/src/main/resources/META-INF/services/org.openremote.model.setup.SetupTasks
@@ -0,0 +1 @@
+org.openremote.setup.demo.DemoSetupTasks
diff --git a/setup/src/main/resources/demo/rules/smartcity/DeKuip.json b/setup/src/main/resources/demo/rules/smartcity/DeKuip.json
new file mode 100644
index 000000000..242ddae75
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/DeKuip.json
@@ -0,0 +1,76 @@
+{
+ "rules": [
+ {
+ "name": "De Kuip",
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "ConsoleAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "location"
+ },
+ "value": {
+ "predicateType": "radial",
+ "negated": false,
+ "radius": 100,
+ "lat": 51.8938569,
+ "lng": 4.5219983
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "notification",
+ "notification": {
+ "name": "De Kuip",
+ "message": {
+ "type": "push",
+ "title": "De Kuip",
+ "body": "De thuis van Feyenoord",
+ "action": {
+ "url": "https://www.feyenoord.nl"
+ },
+ "buttons": [
+ {
+ "title": "Open in app",
+ "action": {
+ "url": "https://www.feyenoord.nl"
+ }
+ },
+ {
+ "title": "Open in browser",
+ "action": {
+ "url": "https://www.feyenoord.nl",
+ "openInBrowser": true
+ }
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "reset": {
+ "timer": "1m"
+ }
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/EnvironmentAlerts.json b/setup/src/main/resources/demo/rules/smartcity/EnvironmentAlerts.json
new file mode 100644
index 000000000..78aa615c4
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/EnvironmentAlerts.json
@@ -0,0 +1,86 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 10080
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "GroundwaterSensorAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "waterLevel"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "LESS_THAN",
+ "value": 100
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "EnvironmentSensorAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "ozoneLevel"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_THAN",
+ "value": 120
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "notification",
+ "target": {
+ "custom": "[email protected]"
+ },
+ "notification": {
+ "message": {
+ "type": "email",
+ "subject": "%RULESET_NAME%",
+ "html": "%TRIGGER_ASSETS%"
+ }
+ }
+ }
+ ],
+ "name": "Environment monitoring: Alerts"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/Euromast.json b/setup/src/main/resources/demo/rules/smartcity/Euromast.json
new file mode 100644
index 000000000..0b0b86a02
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/Euromast.json
@@ -0,0 +1,76 @@
+{
+ "rules": [
+ {
+ "name": "Euromast",
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "ConsoleAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "location"
+ },
+ "value": {
+ "predicateType": "radial",
+ "negated": false,
+ "radius": 100,
+ "lat": 51.9069373,
+ "lng": 4.4633775
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "notification",
+ "notification": {
+ "name": "Euromast",
+ "message": {
+ "type": "push",
+ "title": "Euromast",
+ "body": "Euromast, sinds 1960",
+ "action": {
+ "url": "https://euromast.nl"
+ },
+ "buttons": [
+ {
+ "title": "Open in app",
+ "action": {
+ "url": "https://euromast.nl"
+ }
+ },
+ {
+ "title": "Open in browser",
+ "action": {
+ "url": "https://euromast.nl",
+ "openInBrowser": true
+ }
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "reset": {
+ "timer": "1m"
+ }
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/LightGroupOnOff.flow b/setup/src/main/resources/demo/rules/smartcity/LightGroupOnOff.flow
new file mode 100644
index 000000000..3cc9f75fc
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/LightGroupOnOff.flow
@@ -0,0 +1,270 @@
+{
+ "name": "Light group: On/Off",
+ "description": null,
+ "connections": [
+ {
+ "from": "ukpONuy_1l",
+ "to": "B3dY_taYNK"
+ },
+ {
+ "from": "ukpONuy_1l",
+ "to": "68LWcne-67"
+ },
+ {
+ "from": "ukpONuy_1l",
+ "to": "ktRR2NfCIz"
+ },
+ {
+ "from": "ukpONuy_1l",
+ "to": "yeg_2mKTYs"
+ },
+ {
+ "from": "ukpONuy_1l",
+ "to": "IZLWvgKE53"
+ },
+ {
+ "from": "ukpONuy_1l",
+ "to": "jhuPjbsPKE"
+ }
+ ],
+ "nodes": [
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "52kOB7c1Rs7WUxgfoCKf5B",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "06QKgajTZ",
+ "id": "ukpONuy_1l"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -543.9625396728516,
+ "y": -112.80001831054688
+ },
+ "size": {
+ "x": 227.5,
+ "y": 65
+ },
+ "id": "06QKgajTZ"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "B5WJbAESc",
+ "id": "B3dY_taYNK"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "3QlH8nQWvnevcyxat6tQKJ",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -17.587539672851562,
+ "y": -464.4250183105469
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "B5WJbAESc"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "-RIbDrogC",
+ "id": "68LWcne-67"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "4Y8sldGAezGSxqSSW3bly5",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -17.212539672851562,
+ "y": -323.1750183105469
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "-RIbDrogC"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "pfENJ9_NZ",
+ "id": "ktRR2NfCIz"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "4RYkKKuM1wOw21PNOgHShZ",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -16.962539672851562,
+ "y": -183.30001831054688
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "pfENJ9_NZ"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "w11vs1M8S",
+ "id": "yeg_2mKTYs"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "43F9MlyRcnGhY2m2hHlOdz",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -17.712539672851562,
+ "y": -41.675018310546875
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "w11vs1M8S"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "80FuLcHW-",
+ "id": "IZLWvgKE53"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "5aID6iE9exaVNirT2flago",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -16.587539672851562,
+ "y": 94.57498168945312
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "80FuLcHW-"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "BOOLEAN",
+ "nodeId": "aJz5lyWMD",
+ "id": "jhuPjbsPKE"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "3wauEi0ol2th6hXULHV2N4",
+ "attributeName": "onOff"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -17.462539672851562,
+ "y": 233.94998168945312
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "aJz5lyWMD"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/Markthal.json b/setup/src/main/resources/demo/rules/smartcity/Markthal.json
new file mode 100644
index 000000000..d430586ee
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/Markthal.json
@@ -0,0 +1,76 @@
+{
+ "rules": [
+ {
+ "name": "Markthal",
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "ConsoleAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "location"
+ },
+ "value": {
+ "predicateType": "radial",
+ "negated": false,
+ "radius": 100,
+ "lat": 51.9202494,
+ "lng": 4.4851372
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "notification",
+ "notification": {
+ "name": "Markthal",
+ "message": {
+ "type": "push",
+ "title": "Markthal",
+ "body": "Happy Food Shopping",
+ "action": {
+ "url": "https://www.markthal.nl"
+ },
+ "buttons": [
+ {
+ "title": "Open in app",
+ "action": {
+ "url": "https://www.markthal.nl"
+ }
+ },
+ {
+ "title": "Open in browser",
+ "action": {
+ "url": "https://www.markthal.nl",
+ "openInBrowser": true
+ }
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "reset": {
+ "timer": "1m"
+ }
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/MarkthalChargersInUse.json b/setup/src/main/resources/demo/rules/smartcity/MarkthalChargersInUse.json
new file mode 100644
index 000000000..833a2c533
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/MarkthalChargersInUse.json
@@ -0,0 +1,139 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 10080
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "ElectricityChargerAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "power"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_EQUALS",
+ "value": 0
+ }
+ }
+ ]
+ },
+ "ids": [
+ "2QEKoczoTiOfLKh5UHqEf5"
+ ]
+ }
+ },
+ {
+ "assets": {
+ "types": [
+ "ElectricityChargerAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "power"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_EQUALS",
+ "value": 0
+ }
+ }
+ ]
+ },
+ "ids": [
+ "6Pgv4HQGmC0EjXg7GmNM6l"
+ ]
+ }
+ },
+ {
+ "assets": {
+ "types": [
+ "ElectricityChargerAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "power"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_EQUALS",
+ "value": 0
+ }
+ }
+ ]
+ },
+ "ids": [
+ "3KUCNnuNcS2zFAURMpAq0u"
+ ]
+ }
+ },
+ {
+ "assets": {
+ "types": [
+ "ElectricityChargerAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "power"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_EQUALS",
+ "value": 0
+ }
+ }
+ ]
+ },
+ "ids": [
+ "6EaYX7DEAFwxOJr3de4GFf"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "notification",
+ "target": {
+ "custom": "[email protected]"
+ },
+ "notification": {
+ "message": {
+ "type": "email",
+ "subject": "%RULESET_NAME%",
+ "html": "%TRIGGER_ASSETS%"
+ }
+ }
+ }
+ ],
+ "name": "Markthal: All chargers in use"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/OnsParkBrightStrongWinds.json b/setup/src/main/resources/demo/rules/smartcity/OnsParkBrightStrongWinds.json
new file mode 100644
index 000000000..ee06d235f
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/OnsParkBrightStrongWinds.json
@@ -0,0 +1,138 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 0
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "WeatherAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "windSpeed"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_THAN",
+ "value": 2
+ }
+ }
+ ]
+ },
+ "ids": [
+ "2bMjSx0iy1usC9KKhT24h9"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "3QlH8nQWvnevcyxat6tQKJ"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 90,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "4Y8sldGAezGSxqSSW3bly5"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 90,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "4RYkKKuM1wOw21PNOgHShZ"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 90,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "43F9MlyRcnGhY2m2hHlOdz"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 90,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "5aID6iE9exaVNirT2flago"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 90,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "3wauEi0ol2th6hXULHV2N4"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 90,
+ "attributeName": "brightness"
+ }
+ ],
+ "name": "Ons Park: Brighten lights"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/OnsParkDimLightWinds.json b/setup/src/main/resources/demo/rules/smartcity/OnsParkDimLightWinds.json
new file mode 100644
index 000000000..dd59a4c85
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/OnsParkDimLightWinds.json
@@ -0,0 +1,138 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 0
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "WeatherAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "windSpeed"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "LESS_EQUALS",
+ "value": 2
+ }
+ }
+ ]
+ },
+ "ids": [
+ "2bMjSx0iy1usC9KKhT24h9"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "3QlH8nQWvnevcyxat6tQKJ"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "4Y8sldGAezGSxqSSW3bly5"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "4RYkKKuM1wOw21PNOgHShZ"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "43F9MlyRcnGhY2m2hHlOdz"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "5aID6iE9exaVNirT2flago"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "3wauEi0ol2th6hXULHV2N4"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ }
+ ],
+ "name": "Ons Park: Dim lights"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/ParkingFull.json b/setup/src/main/resources/demo/rules/smartcity/ParkingFull.json
new file mode 100644
index 000000000..1593d387b
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/ParkingFull.json
@@ -0,0 +1,61 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 10080
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "GroupAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "totalOccupancy"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_EQUALS",
+ "value": 90
+ }
+ }
+ ]
+ },
+ "ids": [
+ "7UUzmvnTuLdjVpTb8MnjSX"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "notification",
+ "target": {
+ "custom": "[email protected]"
+ },
+ "notification": {
+ "message": {
+ "type": "email",
+ "subject": "%RULESET_NAME%",
+ "html": "%TRIGGER_ASSETS%"
+ }
+ }
+ }
+ ],
+ "name": "Parking: Almost full"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/ParkingOccupiedPercentage.flow b/setup/src/main/resources/demo/rules/smartcity/ParkingOccupiedPercentage.flow
new file mode 100644
index 000000000..38c595895
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/ParkingOccupiedPercentage.flow
@@ -0,0 +1,551 @@
+{
+ "name": "Parking: Occupied spaces",
+ "description": null,
+ "connections": [
+ {
+ "from": "5D-B3ktG0G",
+ "to": "vw097tfr81"
+ },
+ {
+ "from": "hsSgzfNE-E",
+ "to": "bQs4E9qCN2"
+ },
+ {
+ "from": "vCKMzAmLNx",
+ "to": "hz9f6Q4ESn"
+ },
+ {
+ "from": "lasR8uUoUR",
+ "to": "KqxwaOcGIP"
+ },
+ {
+ "from": "cOmTxKOpO0",
+ "to": "mJMXOPeGZd"
+ },
+ {
+ "from": "SOy3l0IR80",
+ "to": "vVdwGz2y8k"
+ },
+ {
+ "from": "-GPWnMsaGi",
+ "to": "OwI5iFzFMS"
+ },
+ {
+ "from": "z3-Iw-kaOH",
+ "to": "IEc8KwEhvK"
+ },
+ {
+ "from": "AKbiPAtB8t",
+ "to": "UVDHhIKihX"
+ },
+ {
+ "from": "C1DIYbdOhv",
+ "to": "6S19cFPyNd"
+ },
+ {
+ "from": "LI2D3VNWB6",
+ "to": "TPkxQ4HKOE"
+ },
+ {
+ "from": "Rw4MA6Afzc",
+ "to": "iTcEE2Mgzd"
+ },
+ {
+ "from": "yxflB92whn",
+ "to": "mfesEa2D7N"
+ }
+ ],
+ "nodes": [
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "2tLAEBGjmRCu1KrdJn9T2Z",
+ "attributeName": "spacesOccupied"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "EXZ-b6ute",
+ "id": "5D-B3ktG0G"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -749.5,
+ "y": -501.5
+ },
+ "size": {
+ "x": 136.234,
+ "y": 65
+ },
+ "id": "EXZ-b6ute"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "1yuaW634x1LqumPTwGxvyg",
+ "attributeName": "spacesOccupied"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "4K3EqIsY6",
+ "id": "hsSgzfNE-E"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -748.5,
+ "y": -348.5
+ },
+ "size": {
+ "x": 121,
+ "y": 65
+ },
+ "id": "4K3EqIsY6"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "3D49AxXerrIycM8gNd0zlK",
+ "attributeName": "spacesOccupied"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "fsaLpxzdx",
+ "id": "lasR8uUoUR"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -744.5,
+ "y": -197.5
+ },
+ "size": {
+ "x": 121,
+ "y": 65
+ },
+ "id": "fsaLpxzdx"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "1yuaW634x1LqumPTwGxvyg",
+ "attributeName": "spacesTotal"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "cUasODe-H",
+ "id": "SOy3l0IR80"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -745.5,
+ "y": 133.5
+ },
+ "size": {
+ "x": 121,
+ "y": 65
+ },
+ "id": "cUasODe-H"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "2tLAEBGjmRCu1KrdJn9T2Z",
+ "attributeName": "spacesTotal"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "SNDES5qeX",
+ "id": "cOmTxKOpO0"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -744.5,
+ "y": -12.5
+ },
+ "size": {
+ "x": 136.234,
+ "y": 65
+ },
+ "id": "SNDES5qeX"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "3D49AxXerrIycM8gNd0zlK",
+ "attributeName": "spacesTotal"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "qZnj0EbDZ",
+ "id": "-GPWnMsaGi"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -749.5,
+ "y": 278.5
+ },
+ "size": {
+ "x": 121,
+ "y": 65
+ },
+ "id": "qZnj0EbDZ"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "EN5SNd71j",
+ "id": "vw097tfr81"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "EN5SNd71j",
+ "id": "bQs4E9qCN2"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "EN5SNd71j",
+ "id": "vCKMzAmLNx"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -446.5,
+ "y": -387.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "EN5SNd71j"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "4PR4GPJ-N",
+ "id": "hz9f6Q4ESn"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "4PR4GPJ-N",
+ "id": "KqxwaOcGIP"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "4PR4GPJ-N",
+ "id": "AKbiPAtB8t"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -328.5,
+ "y": -251.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "4PR4GPJ-N"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "XoUjUmfs9",
+ "id": "mJMXOPeGZd"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "XoUjUmfs9",
+ "id": "vVdwGz2y8k"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "XoUjUmfs9",
+ "id": "z3-Iw-kaOH"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -434.5,
+ "y": 104.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "XoUjUmfs9"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "dlsfNuzaj",
+ "id": "IEc8KwEhvK"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "dlsfNuzaj",
+ "id": "OwI5iFzFMS"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "dlsfNuzaj",
+ "id": "C1DIYbdOhv"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -301.5,
+ "y": 194.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "dlsfNuzaj"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "INNVamTqd",
+ "id": "UVDHhIKihX"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "INNVamTqd",
+ "id": "6S19cFPyNd"
+ }
+ ],
+ "internals": [],
+ "name": "DIVIDE_OPERATOR",
+ "displayCharacter": "÷",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "INNVamTqd",
+ "id": "LI2D3VNWB6"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -141.5,
+ "y": -113.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "INNVamTqd"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "WsFkoOv-R",
+ "id": "TPkxQ4HKOE"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "WsFkoOv-R",
+ "id": "iTcEE2Mgzd"
+ }
+ ],
+ "internals": [],
+ "name": "MULTIPLY_OPERATOR",
+ "displayCharacter": "×",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "WsFkoOv-R",
+ "id": "yxflB92whn"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": 136.5,
+ "y": -51.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "WsFkoOv-R"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "value",
+ "picker": {
+ "type": "NUMBER"
+ },
+ "value": 100
+ }
+ ],
+ "name": "NUMBER_INPUT",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "_H7TZoQqw",
+ "id": "Rw4MA6Afzc"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -149.734375,
+ "y": 50.5
+ },
+ "size": {
+ "x": 148,
+ "y": 17
+ },
+ "id": "_H7TZoQqw"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "jeli6TQY1",
+ "id": "mfesEa2D7N"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "7UUzmvnTuLdjVpTb8MnjSX",
+ "attributeName": "totalOccupancy"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 281.9921875,
+ "y": -98.5
+ },
+ "size": {
+ "x": 263,
+ "y": 65
+ },
+ "id": "jeli6TQY1"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/RotterdamBatteryUse.json b/setup/src/main/resources/demo/rules/smartcity/RotterdamBatteryUse.json
new file mode 100644
index 000000000..878497ca8
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/RotterdamBatteryUse.json
@@ -0,0 +1,63 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 0
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "BuildingAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "powerBalance"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "LESS_THAN",
+ "value": -25
+ }
+ }
+ ]
+ },
+ "ids": [
+ "2wzKB2j39144oTzAJnHpfs"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "6bzhox7vxOKpKQ5yX5Ysoh"
+ ],
+ "types": [
+ "ElectricityBatteryAsset"
+ ]
+ }
+ },
+ "value": 25,
+ "attributeName": "powerSetpoint"
+ }
+ ],
+ "name": "De Rotterdam: Battery use"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/RotterdamPowerBalance.flow b/setup/src/main/resources/demo/rules/smartcity/RotterdamPowerBalance.flow
new file mode 100644
index 000000000..367a11964
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/RotterdamPowerBalance.flow
@@ -0,0 +1,167 @@
+{
+"name": "De Rotterdam: Power balance",
+"description": "",
+ "connections": [
+ {
+ "from": "mtdBqMHEXV",
+ "to": "HdQFYHsvcv"
+ },
+ {
+ "from": "LvwzHkg9-A",
+ "to": "q-nDnOD6dF"
+ },
+ {
+ "from": "NsjVJrTtFW",
+ "to": "Ni1QTWS6Cr"
+ }
+ ],
+ "nodes": [
+ {
+ "inputs": [
+
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "6DW7WWYVtOybr7W1BWREc3",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "sroPWsTkE",
+ "id": "LvwzHkg9-A"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -689.5,
+ "y": -341.5
+ },
+ "size": {
+ "x": 193.766,
+ "y": 65
+ },
+ "id": "sroPWsTkE"
+ },
+ {
+ "inputs": [
+
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "3Mj9yiC6bcH4MoIYDY2T35",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "f4jr9m-j7",
+ "id": "mtdBqMHEXV"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -687.5,
+ "y": -165.5
+ },
+ "size": {
+ "x": 256.844,
+ "y": 65
+ },
+ "id": "f4jr9m-j7"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "pR1MxgR1S",
+ "id": "Ni1QTWS6Cr"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "2wzKB2j39144oTzAJnHpfs",
+ "attributeName": "powerBalance"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [
+
+ ],
+ "type": "OUTPUT",
+ "position": {
+ "x": 25.9921875,
+ "y": -245.5
+ },
+ "size": {
+ "x": 139.453,
+ "y": 65
+ },
+ "id": "pR1MxgR1S"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "WdW_DByTa",
+ "id": "q-nDnOD6dF"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "WdW_DByTa",
+ "id": "HdQFYHsvcv"
+ }
+ ],
+ "internals": [
+
+ ],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "WdW_DByTa",
+ "id": "NsjVJrTtFW"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -187.5,
+ "y": -197.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "WdW_DByTa"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/StationCrowded.json b/setup/src/main/resources/demo/rules/smartcity/StationCrowded.json
new file mode 100644
index 000000000..0f0293576
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/StationCrowded.json
@@ -0,0 +1,150 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 0
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "MicrophoneAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "soundLevel"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_THAN",
+ "value": 60
+ }
+ }
+ ]
+ },
+ "ids": [
+ "2bdD9xZlveIOabucPi9Iur"
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ "MicrophoneAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "soundLevel"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_THAN",
+ "value": 60
+ }
+ }
+ ]
+ },
+ "ids": [
+ "5WKcxVxZqFq1GYd9b2YVGD"
+ ]
+ }
+ },
+ {
+ "assets": {
+ "types": [
+ "PeopleCounterAsset"
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "countGrowthMinute"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_THAN",
+ "value": 2
+ }
+ }
+ ]
+ },
+ "ids": [
+ "4vD8XpKSR6iieaSLJ35nKl"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "2JA9oLQDHY0pjVHnGJMS35"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 60,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "3BSvaTREZX2MLjuE8bkM16"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 75,
+ "attributeName": "brightness"
+ },
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "2motXSzult66RsYrImPTdf"
+ ],
+ "types": [
+ "LightAsset"
+ ]
+ }
+ },
+ "value": 70,
+ "attributeName": "brightness"
+ }
+ ],
+ "name": "Station: Crowded square"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/TotalPowerConsumption.flow b/setup/src/main/resources/demo/rules/smartcity/TotalPowerConsumption.flow
new file mode 100644
index 000000000..332a9bfd5
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/TotalPowerConsumption.flow
@@ -0,0 +1,317 @@
+{
+ "name": "Total power consumption",
+ "description": null,
+ "connections": [
+ {
+ "from": "k7xzWpPmOU",
+ "to": "mOv6cwMsN6"
+ },
+ {
+ "from": "0GKNcY239I",
+ "to": "TlmXpsOXUQ"
+ },
+ {
+ "from": "h9ZwYflt4Z",
+ "to": "rDjJ1NRPSV"
+ },
+ {
+ "from": "lzZfpdD4S0",
+ "to": "N2_UIZs3xI"
+ },
+ {
+ "from": "quH3sV5fSp",
+ "to": "Rsco32_whA"
+ },
+ {
+ "from": "cTWyTa7iqz",
+ "to": "DZdxsbYtlW"
+ },
+ {
+ "from": "74xUsnTGZY",
+ "to": "kW3nIIzmKM"
+ }
+ ],
+ "nodes": [
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "3Mj9yiC6bcH4MoIYDY2T35",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "b_5QIrcpn",
+ "id": "k7xzWpPmOU"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -855.0078125,
+ "y": -453.5
+ },
+ "size": {
+ "x": 257.781,
+ "y": 65
+ },
+ "id": "b_5QIrcpn"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "4jBtdIZOtA7pLxPNSwWCVa",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "5zCZbiVkM",
+ "id": "0GKNcY239I"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -858.0078125,
+ "y": -301.5
+ },
+ "size": {
+ "x": 243.969,
+ "y": 65
+ },
+ "id": "5zCZbiVkM"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "6L8hVlM1fQ4dDHFM6HYA6O",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "TQ9PC2hLm",
+ "id": "h9ZwYflt4Z"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -861.0078125,
+ "y": -151.5
+ },
+ "size": {
+ "x": 217.031,
+ "y": 65
+ },
+ "id": "TQ9PC2hLm"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "4oio0T4DX9lxeBsZVNIpEN",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "EA8rltWHy",
+ "id": "lzZfpdD4S0"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -865.0078125,
+ "y": 2.5
+ },
+ "size": {
+ "x": 216.141,
+ "y": 65
+ },
+ "id": "EA8rltWHy"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "VTzqeMTRY",
+ "id": "mOv6cwMsN6"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "VTzqeMTRY",
+ "id": "TlmXpsOXUQ"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "VTzqeMTRY",
+ "id": "quH3sV5fSp"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -336.5,
+ "y": -327.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "VTzqeMTRY"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "zy-tW7hST",
+ "id": "rDjJ1NRPSV"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "zy-tW7hST",
+ "id": "N2_UIZs3xI"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "zy-tW7hST",
+ "id": "cTWyTa7iqz"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -362.5,
+ "y": -31.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "zy-tW7hST"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "4_h4BFrUr",
+ "id": "Rsco32_whA"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "4_h4BFrUr",
+ "id": "DZdxsbYtlW"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "4_h4BFrUr",
+ "id": "74xUsnTGZY"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -167.5,
+ "y": -186.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "4_h4BFrUr"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "3CV-fcqbr",
+ "id": "kW3nIIzmKM"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "44ORIhkDVAlT97dYGUD9n5",
+ "attributeName": "powerTotalConsumers"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 25.9921875,
+ "y": -232.5
+ },
+ "size": {
+ "x": 247,
+ "y": 65
+ },
+ "id": "3CV-fcqbr"
+ }
+ ]
+}
diff --git a/setup/src/main/resources/demo/rules/smartcity/TotalSolarProduction.flow b/setup/src/main/resources/demo/rules/smartcity/TotalSolarProduction.flow
new file mode 100644
index 000000000..8d1effe71
--- /dev/null
+++ b/setup/src/main/resources/demo/rules/smartcity/TotalSolarProduction.flow
@@ -0,0 +1,317 @@
+{
+ "name": "Total power production",
+ "description": null,
+ "connections": [
+ {
+ "from": "C-QaWZEeBs",
+ "to": "dxvU9Xz2IM"
+ },
+ {
+ "from": "mNS9-GZPMK",
+ "to": "VIEnlWRV_a"
+ },
+ {
+ "from": "nYeDEdHMK3",
+ "to": "r0o8xVQT3N"
+ },
+ {
+ "from": "oCML5aGaOI",
+ "to": "bONtkmO85l"
+ },
+ {
+ "from": "IV-unZRsFH",
+ "to": "PJIlVVDNQw"
+ },
+ {
+ "from": "UCNOY-HrzI",
+ "to": "zW2K73tjyv"
+ },
+ {
+ "from": "lEI0uY0L1o",
+ "to": "2zo6HaMm88"
+ }
+ ],
+ "nodes": [
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "6DW7WWYVtOybr7W1BWREc3",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "CynzKmqQe",
+ "id": "C-QaWZEeBs"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -753.0078125,
+ "y": -514.5
+ },
+ "size": {
+ "x": 194.563,
+ "y": 65
+ },
+ "id": "CynzKmqQe"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "4Fnz8pxxdtDobuDGWYwRNp",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "NEAaAZEMD",
+ "id": "mNS9-GZPMK"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -751.0078125,
+ "y": -353.5
+ },
+ "size": {
+ "x": 161.578,
+ "y": 65
+ },
+ "id": "NEAaAZEMD"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "2RIt5xuSj1BSyaRhwU3z3I",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "DlwsVTeKD",
+ "id": "nYeDEdHMK3"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -754.5,
+ "y": -188.5
+ },
+ "size": {
+ "x": 153.828,
+ "y": 65
+ },
+ "id": "DlwsVTeKD"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "5xgMdcrVWORYWpUKuP2Mo0",
+ "attributeName": "power"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "0_2NG2WHi",
+ "id": "oCML5aGaOI"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -749.5,
+ "y": -32.5
+ },
+ "size": {
+ "x": 152.922,
+ "y": 65
+ },
+ "id": "0_2NG2WHi"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "-Citw31Em",
+ "id": "dxvU9Xz2IM"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "-Citw31Em",
+ "id": "VIEnlWRV_a"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "-Citw31Em",
+ "id": "UCNOY-HrzI"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -339.5,
+ "y": -348.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "-Citw31Em"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "2O2rRgaWI",
+ "id": "r0o8xVQT3N"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "2O2rRgaWI",
+ "id": "bONtkmO85l"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "2O2rRgaWI",
+ "id": "IV-unZRsFH"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -344.5,
+ "y": -94.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "2O2rRgaWI"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER",
+ "nodeId": "Gvoh2qclw",
+ "id": "zW2K73tjyv"
+ },
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "Gvoh2qclw",
+ "id": "PJIlVVDNQw"
+ }
+ ],
+ "internals": [],
+ "name": "ADD_OPERATOR",
+ "displayCharacter": "+",
+ "outputs": [
+ {
+ "name": "c",
+ "type": "NUMBER",
+ "nodeId": "Gvoh2qclw",
+ "id": "lEI0uY0L1o"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -179.5,
+ "y": -215.5
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "Gvoh2qclw"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "XVFP1kzlH",
+ "id": "2zo6HaMm88"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "value": {
+ "assetId": "44ORIhkDVAlT97dYGUD9n5",
+ "attributeName": "powerTotalProducers"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -14.5,
+ "y": -262.5
+ },
+ "size": {
+ "x": 247,
+ "y": 65
+ },
+ "id": "XVFP1kzlH"
+ }
+ ]
+}
diff --git a/test/build.gradle b/test/build.gradle
index 98ffa53df..38856d7f0 100644
--- a/test/build.gradle
+++ b/test/build.gradle
@@ -10,7 +10,7 @@ apply plugin: "groovy"
dependencies {
- api resolveProject(":setup")
+ api resolveProject(":manager")
api "org.codehaus.groovy:groovy-all:$groovyVersion"
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
index 613b65905..4bece9e55 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -9,7 +9,6 @@ import org.openremote.manager.setup.SetupService
import org.openremote.model.Constants
import org.openremote.test.setup.KeycloakTestSetup
import org.openremote.test.setup.ManagerTestSetup
-import org.openremote.model.asset.Asset
import org.openremote.model.asset.agent.Agent
import org.openremote.model.asset.impl.BuildingAsset
import org.openremote.model.asset.impl.RoomAsset
@@ -26,11 +25,9 @@ import spock.lang.Shared
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
-import javax.persistence.EntityManager
import java.time.Instant
import java.time.ZoneOffset
import java.time.ZonedDateTime
-import java.util.function.Function
import static java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME
import static org.openremote.model.query.AssetQuery.*
diff --git a/setup/src/main/java/org/openremote/test/model/TestAssetModelProvider.java b/test/src/test/java/org/openremote/test/model/TestAssetModelProvider.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/model/TestAssetModelProvider.java
rename to test/src/test/java/org/openremote/test/model/TestAssetModelProvider.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/KNXTestingNetworkLink.java b/test/src/test/java/org/openremote/test/protocol/KNXTestingNetworkLink.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/KNXTestingNetworkLink.java
rename to test/src/test/java/org/openremote/test/protocol/KNXTestingNetworkLink.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/MockAgent.java b/test/src/test/java/org/openremote/test/protocol/MockAgent.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/MockAgent.java
rename to test/src/test/java/org/openremote/test/protocol/MockAgent.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/MockAgentLink.java b/test/src/test/java/org/openremote/test/protocol/MockAgentLink.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/MockAgentLink.java
rename to test/src/test/java/org/openremote/test/protocol/MockAgentLink.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/MockProtocol.java b/test/src/test/java/org/openremote/test/protocol/MockProtocol.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/MockProtocol.java
rename to test/src/test/java/org/openremote/test/protocol/MockProtocol.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/http/HTTPServerTestAgent.java b/test/src/test/java/org/openremote/test/protocol/http/HTTPServerTestAgent.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/http/HTTPServerTestAgent.java
rename to test/src/test/java/org/openremote/test/protocol/http/HTTPServerTestAgent.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/http/TestHTTPServerProtocol.java b/test/src/test/java/org/openremote/test/protocol/http/TestHTTPServerProtocol.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/http/TestHTTPServerProtocol.java
rename to test/src/test/java/org/openremote/test/protocol/http/TestHTTPServerProtocol.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/http/TestResource.java b/test/src/test/java/org/openremote/test/protocol/http/TestResource.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/http/TestResource.java
rename to test/src/test/java/org/openremote/test/protocol/http/TestResource.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/http/TestResourceImpl.java b/test/src/test/java/org/openremote/test/protocol/http/TestResourceImpl.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/http/TestResourceImpl.java
rename to test/src/test/java/org/openremote/test/protocol/http/TestResourceImpl.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/velbus/MockVelbusAgent.java b/test/src/test/java/org/openremote/test/protocol/velbus/MockVelbusAgent.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/velbus/MockVelbusAgent.java
rename to test/src/test/java/org/openremote/test/protocol/velbus/MockVelbusAgent.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/velbus/MockVelbusClient.java b/test/src/test/java/org/openremote/test/protocol/velbus/MockVelbusClient.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/velbus/MockVelbusClient.java
rename to test/src/test/java/org/openremote/test/protocol/velbus/MockVelbusClient.java
diff --git a/setup/src/main/java/org/openremote/test/protocol/velbus/MockVelbusProtocol.java b/test/src/test/java/org/openremote/test/protocol/velbus/MockVelbusProtocol.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/protocol/velbus/MockVelbusProtocol.java
rename to test/src/test/java/org/openremote/test/protocol/velbus/MockVelbusProtocol.java
diff --git a/setup/src/main/java/org/openremote/test/setup/KeycloakTestSetup.java b/test/src/test/java/org/openremote/test/setup/KeycloakTestSetup.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/setup/KeycloakTestSetup.java
rename to test/src/test/java/org/openremote/test/setup/KeycloakTestSetup.java
diff --git a/setup/src/main/java/org/openremote/test/setup/ManagerTestAgentSetup.java b/test/src/test/java/org/openremote/test/setup/ManagerTestAgentSetup.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/setup/ManagerTestAgentSetup.java
rename to test/src/test/java/org/openremote/test/setup/ManagerTestAgentSetup.java
diff --git a/setup/src/main/java/org/openremote/test/setup/ManagerTestSetup.java b/test/src/test/java/org/openremote/test/setup/ManagerTestSetup.java
similarity index 100%
rename from setup/src/main/java/org/openremote/test/setup/ManagerTestSetup.java
rename to test/src/test/java/org/openremote/test/setup/ManagerTestSetup.java
diff --git a/setup/src/main/java/org/openremote/test/setup/TestSetupTasks.java b/test/src/test/java/org/openremote/test/setup/TestSetupTasks.java
similarity index 57%
rename from setup/src/main/java/org/openremote/test/setup/TestSetupTasks.java
rename to test/src/test/java/org/openremote/test/setup/TestSetupTasks.java
index aa218728e..0c87d366f 100644
--- a/setup/src/main/java/org/openremote/test/setup/TestSetupTasks.java
+++ b/test/src/test/java/org/openremote/test/setup/TestSetupTasks.java
@@ -19,32 +19,24 @@
*/
package org.openremote.test.setup;
-import org.openremote.manager.security.ManagerIdentityService;
-import org.openremote.manager.setup.EmptySetupTasks;
-import org.openremote.manager.setup.Setup;
import org.openremote.model.Container;
+import org.openremote.model.setup.Setup;
+import org.openremote.model.setup.SetupTasks;
+import java.util.Arrays;
import java.util.List;
/**
* Test setup tasks.
*/
-public class TestSetupTasks extends EmptySetupTasks {
+public class TestSetupTasks implements SetupTasks {
@Override
- public List<Setup> createTasks(Container container) {
- super.createTasks(container);
-
- // Basic vs Keycloak identity provider
- if (container.getService(ManagerIdentityService.class).isKeycloakEnabled()) {
-
- addTask(new KeycloakTestSetup(container));
- addTask(new ManagerTestSetup(container));
- //addTask(new RulesTestSetup(container));
-
- addTask(new ManagerTestAgentSetup(container));
- }
-
- return getTasks();
+ public List<Setup> createTasks(Container container, String setupType, boolean keycloakEnabled) {
+ return Arrays.asList(
+ new KeycloakTestSetup(container),
+ new ManagerTestSetup(container),
+ new ManagerTestAgentSetup(container)
+ );
}
}
diff --git a/setup/src/main/resources/META-INF/services/org.openremote.model.AssetModelProvider b/test/src/test/resources/META-INF/services/org.openremote.model.AssetModelProvider
similarity index 100%
rename from setup/src/main/resources/META-INF/services/org.openremote.model.AssetModelProvider
rename to test/src/test/resources/META-INF/services/org.openremote.model.AssetModelProvider
diff --git a/setup/src/main/resources/META-INF/services/org.openremote.manager.setup.SetupTasks b/test/src/test/resources/META-INF/services/org.openremote.model.setup.SetupTasks
similarity index 100%
rename from setup/src/main/resources/META-INF/services/org.openremote.manager.setup.SetupTasks
rename to test/src/test/resources/META-INF/services/org.openremote.model.setup.SetupTasks