Browse Source

added thermostat rule chain, removed "Temperature & Humidity Demo Dashboard" & "Raspberry PI GPIO Demo Dashboard"

pull/3776/head
YevhenBondarenko 6 years ago
committed by Andrew Shvayka
parent
commit
80b1ffa736
  1. 700
      application/src/main/data/json/demo/dashboards/raspberry_pi_gpio_demo_dashboard.json
  2. 264
      application/src/main/data/json/demo/dashboards/temperature___humidity_demo_dashboard.json
  3. 135
      application/src/main/data/json/demo/rule_chains/thermostat_rule_chain.json
  4. 7
      application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java
  5. 9
      application/src/main/java/org/thingsboard/server/service/install/InstallScripts.java

700
application/src/main/data/json/demo/dashboards/raspberry_pi_gpio_demo_dashboard.json

@ -1,700 +0,0 @@
{
"title": "Raspberry PI GPIO Demo Dashboard",
"configuration": {
"description": "Demo dashboard for Raspberry PI GPIO Demo",
"widgets": {
"602177f6-267b-cb87-4e8f-e23d7fb2f61c": {
"isSystemType": true,
"bundleAlias": "gpio_widgets",
"typeAlias": "raspberry_pi_gpio_control",
"type": "rpc",
"title": "New widget",
"sizeX": 6,
"sizeY": 10,
"config": {
"targetDeviceAliases": [],
"showTitle": true,
"backgroundColor": "#fff",
"color": "rgba(0, 0, 0, 0.87)",
"padding": "0px",
"settings": {
"parseGpioStatusFunction": "return body[pin] === true;",
"gpioStatusChangeRequest": {
"method": "setGpioStatus",
"paramsBody": "{\n \"pin\": \"{$pin}\",\n \"enabled\": \"{$enabled}\"\n}"
},
"requestTimeout": 500,
"switchPanelBackgroundColor": "#008a00",
"gpioStatusRequest": {
"method": "getGpioStatus",
"paramsBody": "{}"
},
"gpioList": [
{
"pin": 7,
"label": "GPIO 4 (GPCLK0)",
"row": 3,
"col": 0,
"_uniqueKey": 0
},
{
"pin": 11,
"label": "GPIO 17",
"row": 5,
"col": 0,
"_uniqueKey": 1
},
{
"pin": 12,
"label": "GPIO 18",
"row": 5,
"col": 1,
"_uniqueKey": 2
},
{
"_uniqueKey": 3,
"pin": 13,
"label": "GPIO 27",
"row": 6,
"col": 0
},
{
"_uniqueKey": 4,
"pin": 15,
"label": "GPIO 22",
"row": 7,
"col": 0
},
{
"_uniqueKey": 5,
"pin": 16,
"label": "GPIO 23",
"row": 7,
"col": 1
},
{
"_uniqueKey": 6,
"pin": 18,
"label": "GPIO 24",
"row": 8,
"col": 1
},
{
"_uniqueKey": 7,
"pin": 22,
"label": "GPIO 25",
"row": 10,
"col": 1
},
{
"_uniqueKey": 8,
"pin": 29,
"label": "GPIO 5",
"row": 14,
"col": 0
},
{
"_uniqueKey": 9,
"pin": 31,
"label": "GPIO 6",
"row": 15,
"col": 0
},
{
"_uniqueKey": 10,
"pin": 32,
"label": "GPIO 12",
"row": 15,
"col": 1
},
{
"_uniqueKey": 11,
"pin": 33,
"label": "GPIO 13",
"row": 16,
"col": 0
},
{
"_uniqueKey": 12,
"pin": 35,
"label": "GPIO 19",
"row": 17,
"col": 0
},
{
"_uniqueKey": 13,
"pin": 36,
"label": "GPIO 16",
"row": 17,
"col": 1
},
{
"_uniqueKey": 14,
"pin": 37,
"label": "GPIO 26",
"row": 18,
"col": 0
},
{
"_uniqueKey": 15,
"pin": 38,
"label": "GPIO 20",
"row": 18,
"col": 1
},
{
"_uniqueKey": 16,
"pin": 40,
"label": "GPIO 21",
"row": 19,
"col": 1
}
]
},
"title": "Raspberry Pi GPIO Control Panel",
"datasources": [],
"targetDeviceAliasIds": [
"f26b12b6-6938-e1a0-85ec-d88a1f23e382"
]
},
"row": 0,
"col": 0,
"id": "602177f6-267b-cb87-4e8f-e23d7fb2f61c"
},
"3cca52a5-e874-eb43-b444-8efa01e663c8": {
"isSystemType": true,
"bundleAlias": "gpio_widgets",
"typeAlias": "raspberry_pi_gpio_panel",
"type": "latest",
"title": "New widget",
"sizeX": 7,
"sizeY": 10,
"config": {
"showTitle": true,
"backgroundColor": "#fff",
"color": "rgba(0, 0, 0, 0.87)",
"padding": "0px",
"settings": {
"gpioList": [
{
"pin": 1,
"label": "3.3V",
"row": 0,
"col": 0,
"color": "#fc9700",
"_uniqueKey": 0
},
{
"pin": 2,
"label": "5V",
"row": 0,
"col": 1,
"color": "#fb0000",
"_uniqueKey": 1
},
{
"pin": 3,
"label": "GPIO 2 (I2C1_SDA)",
"row": 1,
"col": 0,
"color": "#02fefb",
"_uniqueKey": 2
},
{
"color": "#fb0000",
"pin": 4,
"label": "5V",
"row": 1,
"col": 1
},
{
"color": "#02fefb",
"pin": 5,
"label": "GPIO 3 (I2C1_SCL)",
"row": 2,
"col": 0
},
{
"color": "#000000",
"pin": 6,
"label": "GND",
"row": 2,
"col": 1
},
{
"color": "#00fd00",
"pin": 7,
"label": "GPIO 4 (GPCLK0)",
"row": 3,
"col": 0
},
{
"color": "#fdfb00",
"pin": 8,
"label": "GPIO 14 (UART_TXD)",
"row": 3,
"col": 1
},
{
"color": "#000000",
"pin": 9,
"label": "GND",
"row": 4,
"col": 0
},
{
"color": "#fdfb00",
"pin": 10,
"label": "GPIO 15 (UART_RXD)",
"row": 4,
"col": 1
},
{
"color": "#00fd00",
"pin": 11,
"label": "GPIO 17",
"row": 5,
"col": 0
},
{
"color": "#00fd00",
"pin": 12,
"label": "GPIO 18",
"row": 5,
"col": 1
},
{
"color": "#00fd00",
"pin": 13,
"label": "GPIO 27",
"row": 6,
"col": 0
},
{
"color": "#000000",
"pin": 14,
"label": "GND",
"row": 6,
"col": 1
},
{
"color": "#00fd00",
"pin": 15,
"label": "GPIO 22",
"row": 7,
"col": 0
},
{
"color": "#00fd00",
"pin": 16,
"label": "GPIO 23",
"row": 7,
"col": 1
},
{
"color": "#fc9700",
"pin": 17,
"label": "3.3V",
"row": 8,
"col": 0
},
{
"color": "#00fd00",
"pin": 18,
"label": "GPIO 24",
"row": 8,
"col": 1
},
{
"color": "#fd01fd",
"pin": 19,
"label": "GPIO 10 (SPI_MOSI)",
"row": 9,
"col": 0
},
{
"color": "#000000",
"pin": 20,
"label": "GND",
"row": 9,
"col": 1
},
{
"color": "#fd01fd",
"pin": 21,
"label": "GPIO 9 (SPI_MISO)",
"row": 10,
"col": 0
},
{
"color": "#00fd00",
"pin": 22,
"label": "GPIO 25",
"row": 10,
"col": 1
},
{
"color": "#fd01fd",
"pin": 23,
"label": "GPIO 11 (SPI_SCLK)",
"row": 11,
"col": 0
},
{
"color": "#fd01fd",
"pin": 24,
"label": "GPIO 8 (SPI_CE0)",
"row": 11,
"col": 1
},
{
"color": "#000000",
"pin": 25,
"label": "GND",
"row": 12,
"col": 0
},
{
"color": "#fd01fd",
"pin": 26,
"label": "GPIO 7 (SPI_CE1)",
"row": 12,
"col": 1
},
{
"color": "#ffffff",
"pin": 27,
"label": "ID_SD",
"row": 13,
"col": 0
},
{
"color": "#ffffff",
"pin": 28,
"label": "ID_SC",
"row": 13,
"col": 1
},
{
"color": "#00fd00",
"pin": 29,
"label": "GPIO 5",
"row": 14,
"col": 0
},
{
"color": "#000000",
"pin": 30,
"label": "GND",
"row": 14,
"col": 1
},
{
"color": "#00fd00",
"pin": 31,
"label": "GPIO 6",
"row": 15,
"col": 0
},
{
"color": "#00fd00",
"pin": 32,
"label": "GPIO 12",
"row": 15,
"col": 1
},
{
"color": "#00fd00",
"pin": 33,
"label": "GPIO 13",
"row": 16,
"col": 0
},
{
"color": "#000000",
"pin": 34,
"label": "GND",
"row": 16,
"col": 1
},
{
"color": "#00fd00",
"pin": 35,
"label": "GPIO 19",
"row": 17,
"col": 0
},
{
"color": "#00fd00",
"pin": 36,
"label": "GPIO 16",
"row": 17,
"col": 1
},
{
"color": "#00fd00",
"pin": 37,
"label": "GPIO 26",
"row": 18,
"col": 0
},
{
"color": "#00fd00",
"pin": 38,
"label": "GPIO 20",
"row": 18,
"col": 1
},
{
"color": "#000000",
"pin": 39,
"label": "GND",
"row": 19,
"col": 0
},
{
"color": "#00fd00",
"pin": 40,
"label": "GPIO 21",
"row": 19,
"col": 1
}
],
"ledPanelBackgroundColor": "#008a00"
},
"title": "Raspberry Pi GPIO Status Panel",
"datasources": [
{
"type": "entity",
"dataKeys": [
{
"name": "7",
"type": "attribute",
"label": "7",
"color": "#2196f3",
"settings": {},
"_hash": 0.20925966435886978
},
{
"name": "11",
"type": "attribute",
"label": "11",
"color": "#4caf50",
"settings": {},
"_hash": 0.330267349594344
},
{
"name": "12",
"type": "attribute",
"label": "12",
"color": "#f44336",
"settings": {},
"_hash": 0.5040578704481748
},
{
"name": "13",
"type": "attribute",
"label": "13",
"color": "#ffc107",
"settings": {},
"_hash": 0.588956328191639
},
{
"name": "15",
"type": "attribute",
"label": "15",
"color": "#607d8b",
"settings": {},
"_hash": 0.9229040530336119
},
{
"name": "16",
"type": "attribute",
"label": "16",
"color": "#9c27b0",
"settings": {},
"_hash": 0.8692315253041654
},
{
"name": "18",
"type": "attribute",
"label": "18",
"color": "#8bc34a",
"settings": {},
"_hash": 0.41465562857521543
},
{
"name": "22",
"type": "attribute",
"label": "22",
"color": "#3f51b5",
"settings": {},
"_hash": 0.36135260043112827
},
{
"name": "29",
"type": "attribute",
"label": "29",
"color": "#e91e63",
"settings": {},
"_hash": 0.9904592276182183
},
{
"name": "31",
"type": "attribute",
"label": "31",
"color": "#ffeb3b",
"settings": {},
"_hash": 0.038330985429919195
},
{
"name": "32",
"type": "attribute",
"label": "32",
"color": "#03a9f4",
"settings": {},
"_hash": 0.4334683890135089
},
{
"name": "33",
"type": "attribute",
"label": "33",
"color": "#ff9800",
"settings": {},
"_hash": 0.6487255992492305
},
{
"name": "35",
"type": "attribute",
"label": "35",
"color": "#673ab7",
"settings": {},
"_hash": 0.971555321150732
},
{
"name": "36",
"type": "attribute",
"label": "36",
"color": "#cddc39",
"settings": {},
"_hash": 0.7826129728424382
},
{
"name": "37",
"type": "attribute",
"label": "37",
"color": "#009688",
"settings": {},
"_hash": 0.44925676517537627
},
{
"name": "38",
"type": "attribute",
"label": "38",
"color": "#795548",
"settings": {},
"_hash": 0.051518155759787465
},
{
"name": "40",
"type": "attribute",
"label": "40",
"color": "#00bcd4",
"settings": {},
"_hash": 0.8733296686871144
}
],
"name": "RPi",
"entityAliasId": "f26b12b6-6938-e1a0-85ec-d88a1f23e382"
}
],
"timewindow": {
"realtime": {
"timewindowMs": 60000
}
}
},
"row": 0,
"col": 6,
"id": "3cca52a5-e874-eb43-b444-8efa01e663c8"
}
},
"states": {
"default": {
"name": "Default",
"root": true,
"layouts": {
"main": {
"widgets": {
"602177f6-267b-cb87-4e8f-e23d7fb2f61c": {
"sizeX": 6,
"sizeY": 10,
"row": 0,
"col": 0
},
"3cca52a5-e874-eb43-b444-8efa01e663c8": {
"sizeX": 7,
"sizeY": 10,
"row": 0,
"col": 6
}
},
"gridSettings": {
"backgroundColor": "#eeeeee",
"color": "rgba(0,0,0,0.870588)",
"columns": 24,
"margins": [
10,
10
],
"backgroundSizeMode": "100%"
}
}
}
}
},
"entityAliases": {
"f26b12b6-6938-e1a0-85ec-d88a1f23e382": {
"id": "f26b12b6-6938-e1a0-85ec-d88a1f23e382",
"alias": "RPi",
"filter": {
"type": "entityName",
"resolveMultiple": false,
"entityType": "DEVICE",
"entityNameFilter": "Raspberry Pi Demo Device"
}
}
},
"timewindow": {
"displayValue": "",
"selectedTab": 0,
"realtime": {
"interval": 1000,
"timewindowMs": 60000
},
"history": {
"historyType": 0,
"interval": 1000,
"timewindowMs": 60000,
"fixedTimewindow": {
"startTimeMs": 1498653734150,
"endTimeMs": 1498740134150
}
},
"aggregation": {
"type": "AVG",
"limit": 200
}
},
"settings": {
"stateControllerId": "default",
"showTitle": true,
"showDashboardsSelect": true,
"showEntitiesSelect": true,
"showDashboardTimewindow": true,
"showDashboardExport": true,
"toolbarAlwaysOpen": false
}
},
"name": "Raspberry PI GPIO Demo Dashboard"
}

264
application/src/main/data/json/demo/dashboards/temperature___humidity_demo_dashboard.json

@ -1,264 +0,0 @@
{
"title": "Temperature & Humidity Demo Dashboard",
"configuration": {
"description": "Demo dashboard for sample applications that upload temperature and humidity received from DHT11 or DHT22 sensors",
"widgets": {
"03e06986-1c50-e9e4-267c-2bae930ad9a2": {
"isSystemType": true,
"bundleAlias": "digital_gauges",
"typeAlias": "digital_thermometer",
"type": "latest",
"title": "New widget",
"sizeX": 5,
"sizeY": 5,
"config": {
"datasources": [
{
"type": "entity",
"dataKeys": [
{
"name": "temperature",
"type": "timeseries",
"label": "temperature",
"color": "#2196f3",
"settings": {},
"_hash": 0.3720839051412099
}
],
"name": "DHT11",
"entityAliasId": "63a93238-c13f-4403-4bcc-9ccc86bd6a62"
}
],
"timewindow": {
"realtime": {
"timewindowMs": 60000
}
},
"showTitle": false,
"backgroundColor": "#000000",
"color": "rgba(0, 0, 0, 0.87)",
"padding": "0px",
"settings": {
"maxValue": 50,
"donutStartAngle": 90,
"showValue": true,
"showMinMax": true,
"gaugeWidthScale": 1,
"levelColors": [
"#304ffe",
"#7e57c2",
"#ff4081",
"#d32f2f"
],
"refreshAnimationType": "<>",
"refreshAnimationTime": 700,
"startAnimationType": "<>",
"startAnimationTime": 700,
"titleFont": {
"family": "RobotoDraft",
"size": 12,
"style": "normal",
"weight": "500"
},
"labelFont": {
"family": "RobotoDraft",
"size": 8,
"style": "normal",
"weight": "500"
},
"valueFont": {
"family": "Segment7Standard",
"style": "normal",
"weight": "500",
"size": 18
},
"minMaxFont": {
"family": "Segment7Standard",
"size": 12,
"style": "normal",
"weight": "500"
},
"dashThickness": 1.5,
"decimals": 0,
"minValue": 0,
"units": "°C",
"gaugeColor": "#333333",
"neonGlowBrightness": 35,
"gaugeType": "donut",
"showTitle": false
},
"title": "Temperature"
},
"row": 0,
"col": 0,
"id": "03e06986-1c50-e9e4-267c-2bae930ad9a2"
},
"88808eb1-d381-9970-c852-e3499df68bd8": {
"isSystemType": true,
"bundleAlias": "digital_gauges",
"typeAlias": "digital_vertical_bar",
"type": "latest",
"title": "New widget",
"sizeX": 3,
"sizeY": 5,
"config": {
"datasources": [
{
"type": "entity",
"dataKeys": [
{
"name": "humidity",
"type": "timeseries",
"label": "humidity",
"color": "#2196f3",
"settings": {},
"_hash": 0.9492802776509441
}
],
"name": "DHT11",
"entityAliasId": "63a93238-c13f-4403-4bcc-9ccc86bd6a62"
}
],
"timewindow": {
"realtime": {
"timewindowMs": 60000
}
},
"showTitle": false,
"backgroundColor": "#000000",
"color": "rgba(0, 0, 0, 0.87)",
"padding": "0px",
"settings": {
"maxValue": 100,
"donutStartAngle": 90,
"showValue": true,
"showMinMax": true,
"gaugeWidthScale": 0.75,
"levelColors": [
"#3d5afe",
"#f44336"
],
"refreshAnimationType": "<>",
"refreshAnimationTime": 700,
"startAnimationType": "<>",
"startAnimationTime": 700,
"titleFont": {
"family": "RobotoDraft",
"size": 12,
"style": "normal",
"weight": "500"
},
"labelFont": {
"family": "RobotoDraft",
"size": 8,
"style": "normal",
"weight": "500"
},
"valueFont": {
"family": "Segment7Standard",
"style": "normal",
"weight": "500",
"size": 14
},
"minMaxFont": {
"family": "Segment7Standard",
"size": 8,
"style": "normal",
"weight": "normal",
"color": "#cccccc"
},
"neonGlowBrightness": 20,
"decimals": 0,
"showUnitTitle": true,
"gaugeColor": "#171a1c",
"gaugeType": "verticalBar",
"showTitle": false,
"minValue": 0,
"dashThickness": 1.2
},
"title": "Humidity"
},
"row": 0,
"col": 5,
"id": "88808eb1-d381-9970-c852-e3499df68bd8"
}
},
"states": {
"default": {
"name": "Default",
"root": true,
"layouts": {
"main": {
"widgets": {
"03e06986-1c50-e9e4-267c-2bae930ad9a2": {
"sizeX": 5,
"sizeY": 5,
"row": 0,
"col": 0
},
"88808eb1-d381-9970-c852-e3499df68bd8": {
"sizeX": 3,
"sizeY": 5,
"row": 0,
"col": 5
}
},
"gridSettings": {
"backgroundColor": "#eeeeee",
"color": "rgba(0,0,0,0.870588)",
"columns": 24,
"margins": [
10,
10
],
"backgroundSizeMode": "100%"
}
}
}
}
},
"entityAliases": {
"63a93238-c13f-4403-4bcc-9ccc86bd6a62": {
"id": "63a93238-c13f-4403-4bcc-9ccc86bd6a62",
"alias": "DHT11",
"filter": {
"type": "entityName",
"resolveMultiple": false,
"entityType": "DEVICE",
"entityNameFilter": "DHT11 Demo Device"
}
}
},
"timewindow": {
"displayValue": "",
"selectedTab": 0,
"realtime": {
"interval": 1000,
"timewindowMs": 60000
},
"history": {
"historyType": 0,
"interval": 1000,
"timewindowMs": 60000,
"fixedTimewindow": {
"startTimeMs": 1498653790019,
"endTimeMs": 1498740190019
}
},
"aggregation": {
"type": "AVG",
"limit": 200
}
},
"settings": {
"stateControllerId": "default",
"showTitle": true,
"showDashboardsSelect": true,
"showEntitiesSelect": true,
"showDashboardTimewindow": true,
"showDashboardExport": true,
"toolbarAlwaysOpen": false
}
},
"name": "Temperature & Humidity Demo Dashboard"
}

135
application/src/main/data/json/demo/rule_chains/thermostat_rule_chain.json

@ -0,0 +1,135 @@
{
"ruleChain": {
"additionalInfo": null,
"name": "Thermostat",
"firstRuleNodeId": null,
"root": false,
"debugMode": false,
"configuration": null
},
"metadata": {
"firstNodeIndex": 6,
"nodes": [
{
"additionalInfo": {
"layoutX": 824,
"layoutY": 156
},
"type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
"name": "Save Timeseries",
"debugMode": false,
"configuration": {
"defaultTTL": 0
}
},
{
"additionalInfo": {
"layoutX": 825,
"layoutY": 52
},
"type": "org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode",
"name": "Save Client Attributes",
"debugMode": false,
"configuration": {
"scope": "CLIENT_SCOPE",
"notifyDevice": "false"
}
},
{
"additionalInfo": {
"layoutX": 347,
"layoutY": 149
},
"type": "org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode",
"name": "Message Type Switch",
"debugMode": false,
"configuration": {
"version": 0
}
},
{
"additionalInfo": {
"layoutX": 825,
"layoutY": 266
},
"type": "org.thingsboard.rule.engine.action.TbLogNode",
"name": "Log RPC from Device",
"debugMode": false,
"configuration": {
"jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
}
},
{
"additionalInfo": {
"layoutX": 825,
"layoutY": 379
},
"type": "org.thingsboard.rule.engine.action.TbLogNode",
"name": "Log Other",
"debugMode": false,
"configuration": {
"jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
}
},
{
"additionalInfo": {
"layoutX": 825,
"layoutY": 468
},
"type": "org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode",
"name": "RPC Call Request",
"debugMode": false,
"configuration": {
"timeoutInSeconds": 60
}
},
{
"additionalInfo": {
"description": "Process incoming messages from devices with the alarm rules defined in the device profile. Dispatch all incoming messages with \"Success\" relation type.",
"layoutX": 204,
"layoutY": 240
},
"type": "org.thingsboard.rule.engine.profile.TbDeviceProfileNode",
"name": "Device Profile Node",
"debugMode": false,
"configuration": {
"persistAlarmRulesState": false,
"fetchAlarmRulesStateOnStart": false
}
}
],
"connections": [
{
"fromIndex": 6,
"toIndex": 2,
"type": "Success"
},
{
"fromIndex": 2,
"toIndex": 4,
"type": "Other"
},
{
"fromIndex": 2,
"toIndex": 1,
"type": "Post attributes"
},
{
"fromIndex": 2,
"toIndex": 0,
"type": "Post telemetry"
},
{
"fromIndex": 2,
"toIndex": 3,
"type": "RPC Request from Device"
},
{
"fromIndex": 2,
"toIndex": 5,
"type": "RPC Request to Device"
}
],
"ruleChainConnections": null
}
}

7
application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java

@ -51,6 +51,7 @@ import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
import org.thingsboard.server.common.data.kv.BooleanDataEntry;
import org.thingsboard.server.common.data.kv.DoubleDataEntry;
import org.thingsboard.server.common.data.kv.LongDataEntry;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.query.BooleanFilterPredicate;
import org.thingsboard.server.common.data.query.DynamicValue;
import org.thingsboard.server.common.data.query.DynamicValueSourceType;
@ -72,6 +73,7 @@ import org.thingsboard.server.dao.device.DeviceCredentialsService;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.rule.RuleChainService;
import org.thingsboard.server.dao.settings.AdminSettingsService;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import org.thingsboard.server.dao.tenant.TenantService;
@ -127,6 +129,9 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
@Autowired
private DeviceCredentialsService deviceCredentialsService;
@Autowired
private RuleChainService ruleChainService;
@Bean
protected BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
@ -266,6 +271,8 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
thermostatDeviceProfile.setTransportType(DeviceTransportType.DEFAULT);
thermostatDeviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED);
thermostatDeviceProfile.setDescription("Thermostat device profile");
thermostatDeviceProfile.setDefaultRuleChainId(ruleChainService.findTenantRuleChains(
demoTenant.getId(), new PageLink(1, 0, "Thermostat")).getData().get(0).getId());
DeviceProfileData deviceProfileData = new DeviceProfileData();
DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration();

9
application/src/main/java/org/thingsboard/server/service/install/InstallScripts.java

@ -212,10 +212,17 @@ public class InstallScripts {
public void loadDemoRuleChains(TenantId tenantId) throws Exception {
Path ruleChainsDir = Paths.get(getDataDir(), JSON_DIR, DEMO_DIR, RULE_CHAINS_DIR);
try {
JsonNode thermostatRuleChainJson = objectMapper.readTree(ruleChainsDir.resolve("thermostat_rule_chain.json").toFile());
RuleChain thermostatRuleChain = objectMapper.treeToValue(thermostatRuleChainJson.get("ruleChain"), RuleChain.class);
RuleChainMetaData ruleChainMetaData = objectMapper.treeToValue(thermostatRuleChainJson.get("metadata"), RuleChainMetaData.class);
thermostatRuleChain.setTenantId(tenantId);
thermostatRuleChain = ruleChainService.saveRuleChain(thermostatRuleChain);
ruleChainMetaData.setRuleChainId(thermostatRuleChain.getId());
ruleChainService.saveRuleChainMetaData(new TenantId(EntityId.NULL_UUID), ruleChainMetaData);
JsonNode rootChainJson = objectMapper.readTree(ruleChainsDir.resolve("root_rule_chain.json").toFile());
RuleChain rootChain = objectMapper.treeToValue(rootChainJson.get("ruleChain"), RuleChain.class);
RuleChainMetaData rootChainMetaData = objectMapper.treeToValue(rootChainJson.get("metadata"), RuleChainMetaData.class);
rootChain.setTenantId(tenantId);
rootChain = ruleChainService.saveRuleChain(rootChain);
rootChainMetaData.setRuleChainId(rootChain.getId());

Loading…
Cancel
Save