{
  "version": 1,
  "ruleChain": {
    "name": "Root Rule Chain",
    "type": "CORE",
    "firstRuleNodeId": null,
    "root": false,
    "debugMode": false,
    "configuration": null,
    "additionalInfo": null
  },
  "metadata": {
    "firstNodeIndex": 9,
    "nodes": [
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
        "name": "Save Timeseries",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1735310701003
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "defaultTTL": 0,
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          }
        },
        "additionalInfo": {
          "description": null,
          "layoutX": 1202,
          "layoutY": 221
        }
      },
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode",
        "name": "Save Attributes",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 3,
        "configuration": {
          "scope": "CLIENT_SCOPE",
          "notifyDevice": false,
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          },
          "sendAttributesUpdatedNotification": false,
          "updateAttributesOnlyOnValueChange": false
        },
        "additionalInfo": {
          "layoutX": 1000,
          "layoutY": 167
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode",
        "name": "Message Type Switch",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "version": 0
        },
        "additionalInfo": {
          "layoutX": 566,
          "layoutY": 302
        }
      },
      {
        "type": "org.thingsboard.rule.engine.action.TbLogNode",
        "name": "Log RPC from Device",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);",
          "tbelScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
        },
        "additionalInfo": {
          "layoutX": 1000,
          "layoutY": 381
        }
      },
      {
        "type": "org.thingsboard.rule.engine.action.TbLogNode",
        "name": "Log Other",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);",
          "tbelScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
        },
        "additionalInfo": {
          "layoutX": 1000,
          "layoutY": 494
        }
      },
      {
        "type": "org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode",
        "name": "RPC Call Request",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "timeoutInSeconds": 60
        },
        "additionalInfo": {
          "layoutX": 1000,
          "layoutY": 583
        }
      },
      {
        "type": "org.thingsboard.rule.engine.profile.TbDeviceProfileNode",
        "name": "Device Profile Node",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1735310701003
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "persistAlarmRulesState": false,
          "fetchAlarmRulesStateOnStart": false
        },
        "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": 45,
          "layoutY": 359
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbJsFilterNode",
        "name": "Test JS script",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "JS",
          "jsScript": "var test = {\n    a: 'a',\n    b: 'b'\n};\n\nreturn test.a === 'a' && test.b === 'b';",
          "tbelScript": "return msg.temperature > 20;"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 251,
          "layoutY": 499
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbJsFilterNode",
        "name": "Test TBEL script",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "return msg.temperature > 20;",
          "tbelScript": "var a = \"a\";\nvar b = \"b\";\nreturn a.equals(\"a\") && b.equals(\"b\");"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 317,
          "layoutY": 355
        }
      },
      {
        "type": "org.thingsboard.rule.engine.transform.TbTransformMsgNode",
        "name": "Add arrival timestamp",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1744642101587
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "return {msg: msg, metadata: metadata, msgType: msgType};",
          "tbelScript": "metadata.arrivalTs = Date.now();\nreturn {msg: msg, metadata: metadata, msgType: msgType};"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 40,
          "layoutY": 252
        }
      },
      {
        "type": "org.thingsboard.rule.engine.transform.TbTransformMsgNode",
        "name": "Calculate additional latencies",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1735310701003
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "return {msg: msg, metadata: metadata, msgType: msgType};",
          "tbelScript": "var arrivalLatency = metadata.arrivalTs - metadata.ts;\nvar processingTime = Date.now() - metadata.arrivalTs;\nmsg = {\n    arrivalLatency: arrivalLatency,\n    processingTime: processingTime\n};\nreturn {msg: msg, metadata: metadata, msgType: msgType};"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 1467,
          "layoutY": 267
        }
      },
      {
        "type": "org.thingsboard.rule.engine.transform.TbChangeOriginatorNode",
        "name": "To latencies asset",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "originatorSource": "ENTITY",
          "entityType": "ASSET",
          "entityNamePattern": "[Monitoring] Latencies",
          "relationsQuery": {
            "direction": "FROM",
            "maxLevel": 1,
            "filters": [
              {
                "relationType": "Contains",
                "entityTypes": []
              }
            ],
            "fetchLastLevelOnly": false
          }
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 1438,
          "layoutY": 403
        }
      },
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
        "name": "Save Timeseries",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1735310701003
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "defaultTTL": 0,
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          }
        },
        "additionalInfo": {
          "description": null,
          "layoutX": 1458,
          "layoutY": 505
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbCheckMessageNode",
        "name": "Has testData",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "messageNames": [
            "testData",
            "testDataCf"
          ],
          "metadataNames": [],
          "checkAllKeys": false
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 928,
          "layoutY": 266
        }
      },
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
        "name": "Save Timeseries with TTL",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1742305233839
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          },
          "defaultTTL": 60,
          "useServerTs": null
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 1203,
          "layoutY": 327
        }
      }
    ],
    "connections": [
      {
        "fromIndex": 2,
        "toIndex": 1,
        "type": "Post attributes"
      },
      {
        "fromIndex": 2,
        "toIndex": 3,
        "type": "RPC Request from Device"
      },
      {
        "fromIndex": 2,
        "toIndex": 4,
        "type": "Other"
      },
      {
        "fromIndex": 2,
        "toIndex": 5,
        "type": "RPC Request to Device"
      },
      {
        "fromIndex": 2,
        "toIndex": 13,
        "type": "Post telemetry"
      },
      {
        "fromIndex": 6,
        "toIndex": 7,
        "type": "Success"
      },
      {
        "fromIndex": 7,
        "toIndex": 8,
        "type": "True"
      },
      {
        "fromIndex": 8,
        "toIndex": 2,
        "type": "True"
      },
      {
        "fromIndex": 9,
        "toIndex": 6,
        "type": "Success"
      },
      {
        "fromIndex": 10,
        "toIndex": 11,
        "type": "Success"
      },
      {
        "fromIndex": 11,
        "toIndex": 12,
        "type": "Success"
      },
      {
        "fromIndex": 13,
        "toIndex": 0,
        "type": "False"
      },
      {
        "fromIndex": 13,
        "toIndex": 14,
        "type": "True"
      },
      {
        "fromIndex": 14,
        "toIndex": 10,
        "type": "Success"
      }
    ],
    "ruleChainConnections": null
  }
}