Skip to content

armgit / core

Public Imported from GitHub
0

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

Add rules to demo setup

Don3267df304f20
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
index 2122635a0..980728f2c 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
@@ -163,5 +163,21 @@ public class RulesDemoSetup extends AbstractManagerSetup {
);
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/manager/src/main/resources/demo/rules/smartcity/LightGroupOnOff.flow b/manager/src/main/resources/demo/rules/smartcity/LightGroupOnOff.flow
new file mode 100644
index 000000000..b9284689e
--- /dev/null
+++ b/manager/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": "lightAllStatus"
+ }
+ }
+ ],
+ "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": "54LS0LDCxIqVHnOCAVTK58",
+ "attributeName": "lightStatus"
+ }
+ }
+ ],
+ "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": "4vHXXX1zQEB6J27Kee8Nwf",
+ "attributeName": "lightStatus"
+ }
+ }
+ ],
+ "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": "57wYnE3LEpPLDfsBwnOHzk",
+ "attributeName": "lightStatus"
+ }
+ }
+ ],
+ "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": "61BNFNS5vTR2SCOLDXUBvX",
+ "attributeName": "lightStatus"
+ }
+ }
+ ],
+ "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": "6uE2d0t2SqZcXUtv9qnjq5",
+ "attributeName": "lightStatus"
+ }
+ }
+ ],
+ "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": "3uCPRjC6XTrx38xFG10FSb",
+ "attributeName": "lightStatus"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": -17.462539672851562,
+ "y": 233.94998168945312
+ },
+ "size": {
+ "x": 113,
+ "y": 65
+ },
+ "id": "aJz5lyWMD"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/manager/src/main/resources/demo/rules/smartcity/RotterdamBatteryUse.json b/manager/src/main/resources/demo/rules/smartcity/RotterdamBatteryUse.json
new file mode 100644
index 000000000..3de167921
--- /dev/null
+++ b/manager/src/main/resources/demo/rules/smartcity/RotterdamBatteryUse.json
@@ -0,0 +1,70 @@
+{
+ "rules": [
+ {
+ "recurrence": {
+ "mins": 0
+ },
+ "when": {
+ "operator": "OR",
+ "groups": [
+ {
+ "operator": "AND",
+ "items": [
+ {
+ "assets": {
+ "types": [
+ {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "urn:openremote:asset:building"
+ }
+ ],
+ "attributes": {
+ "items": [
+ {
+ "name": {
+ "predicateType": "string",
+ "match": "EXACT",
+ "value": "powerBalance"
+ },
+ "value": {
+ "predicateType": "number",
+ "operator": "GREATER_THAN",
+ "value": 1
+ }
+ }
+ ]
+ },
+ "ids": [
+ "2wzKB2j39144oTzAJnHpfs"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "then": [
+ {
+ "action": "write-attribute",
+ "target": {
+ "assets": {
+ "ids": [
+ "6bzhox7vxOKpKQ5yX5Ysoh"
+ ],
+ "types": [
+ {
+ "predicateType": "string",
+ "value": "urn:openremote:asset:electricityStorage"
+ }
+ ]
+ }
+ },
+ "value": 18,
+ "attributeName": "setPointPower"
+ }
+ ],
+ "name": "De Rotterdam: Battery use"
+ }
+ ]
+}
\ No newline at end of file