{
  "version": 2,
  "ruleChain": {
    "name": "Root Rule Chain",
    "type": "CORE",
    "firstRuleNodeId": null,
    "root": false,
    "debugMode": false,
    "configuration": null,
    "additionalInfo": {
      "description": ""
    }
  },
  "metadata": {
    "firstNodeIndex": 12,
    "nodes": [
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
        "name": "Save Timeseries",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1742298157855
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "defaultTTL": 1209600,
          "useServerTs": null,
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          }
        },
        "additionalInfo": {
          "description": null,
          "layoutX": 1202,
          "layoutY": 221
        }
      },
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode",
        "name": "Save Attributes",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1742298157855
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 3,
        "configuration": {
          "scope": "CLIENT_SCOPE",
          "notifyDevice": false,
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          },
          "sendAttributesUpdatedNotification": false,
          "updateAttributesOnlyOnValueChange": false
        },
        "additionalInfo": {
          "description": null,
          "layoutX": 1000,
          "layoutY": 167
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode",
        "name": "Message Type Switch",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1742304208838
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "version": 0
        },
        "additionalInfo": {
          "description": null,
          "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.filter.TbOriginatorTypeFilterNode",
        "name": "Is Entity Group",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "originatorTypes": [
            "ENTITY_GROUP"
          ]
        },
        "additionalInfo": {
          "layoutX": 268,
          "layoutY": 300
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbMsgTypeFilterNode",
        "name": "Post attributes or RPC request",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "messageTypes": [
            "POST_ATTRIBUTES_REQUEST",
            "RPC_CALL_FROM_SERVER_TO_DEVICE"
          ]
        },
        "additionalInfo": {
          "layoutX": 319,
          "layoutY": 109
        }
      },
      {
        "type": "org.thingsboard.rule.engine.transform.TbDuplicateMsgToGroupNode",
        "name": "Duplicate To Group Entities",
        "debugSettings": null,
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "entityGroupId": null,
          "entityGroupIsMessageOriginator": true
        },
        "additionalInfo": {
          "layoutX": 627,
          "layoutY": 108
        }
      },
      {
        "type": "org.thingsboard.rule.engine.profile.TbDeviceProfileNode",
        "name": "Device Profile Node",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1742304208838
        },
        "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};\nreturn test.a === 'a' && test.b === 'b';",
          "tbelScript": "return msg.temperature > 20;"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 154,
          "layoutY": 548
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbJsFilterNode",
        "name": "Test TBEL script",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 0
        },
        "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": 357,
          "layoutY": 457
        }
      },
      {
        "type": "org.thingsboard.rule.engine.transform.TbTransformMsgNode",
        "name": "Add arrival timestamp",
        "debugSettings": null,
        "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": 1733331880270
        },
        "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": 1,
        "configuration": {
          "originatorSource": "ENTITY",
          "entityType": "ASSET",
          "entityNamePattern": "[Monitoring] Latencies",
          "relationsQuery": {
            "direction": "FROM",
            "maxLevel": 1,
            "filters": [
              {
                "relationType": "Contains",
                "entityTypes": []
              }
            ],
            "fetchLastLevelOnly": false
          },
          "preserveOriginatorIfCustomer": true
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 1438,
          "layoutY": 403
        }
      },
      {
        "type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
        "name": "Save Timeseries",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1733331880270
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "defaultTTL": 1209600,
          "useServerTs": null,
          "processingSettings": {
            "type": "ON_EVERY_MESSAGE"
          }
        },
        "additionalInfo": {
          "description": null,
          "layoutX": 1458,
          "layoutY": 505
        }
      },
      {
        "type": "org.thingsboard.rule.engine.filter.TbCheckMessageNode",
        "name": "Has testData",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1744655225418
        },
        "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": 1742304208838
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "processingSettings": {
            "timeseries": {
              "type": "ON_EVERY_MESSAGE"
            },
            "latest": {
              "type": "ON_EVERY_MESSAGE"
            },
            "webSockets": {
              "type": "ON_EVERY_MESSAGE"
            },
            "calculatedFields": {
              "type": "ON_EVERY_MESSAGE"
            },
            "type": "ADVANCED"
          },
          "defaultTTL": 60,
          "useServerTs": null
        },
        "additionalInfo": {
          "description": null,
          "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": 16,
        "type": "Post telemetry"
      },
      {
        "fromIndex": 6,
        "toIndex": 2,
        "type": "False"
      },
      {
        "fromIndex": 6,
        "toIndex": 7,
        "type": "True"
      },
      {
        "fromIndex": 7,
        "toIndex": 2,
        "type": "False"
      },
      {
        "fromIndex": 7,
        "toIndex": 8,
        "type": "True"
      },
      {
        "fromIndex": 8,
        "toIndex": 2,
        "type": "Success"
      },
      {
        "fromIndex": 9,
        "toIndex": 10,
        "type": "Success"
      },
      {
        "fromIndex": 10,
        "toIndex": 11,
        "type": "True"
      },
      {
        "fromIndex": 11,
        "toIndex": 6,
        "type": "True"
      },
      {
        "fromIndex": 12,
        "toIndex": 9,
        "type": "Success"
      },
      {
        "fromIndex": 13,
        "toIndex": 14,
        "type": "Success"
      },
      {
        "fromIndex": 14,
        "toIndex": 15,
        "type": "Success"
      },
      {
        "fromIndex": 16,
        "toIndex": 0,
        "type": "False"
      },
      {
        "fromIndex": 16,
        "toIndex": 17,
        "type": "True"
      },
      {
        "fromIndex": 17,
        "toIndex": 13,
        "type": "Success"
      }
    ],
    "ruleChainConnections": null
  }
}