{
  "_exportDate": "2022-08-03T14:37:55.254Z",
  "_type": "flow",
  "applicationId": "62694a79b7db3002831c845e",
  "customNodeVersions": [
  ],
  "customNodes": [
  ],
  "description": "",
  "enabled": true,
  "flowClass": "cloud",
  "globals": [
    {
      "key": "tts-wegnology-schedule-downlink-api-key",
      "type": "string"
    },
    {
      "key": "tts-webhook-id",
      "type": "string"
    },
    {
      "key": "tts-application-id",
      "type": "string"
    },
    {
      "key": "tts-api-url",
      "type": "string"
    },
    {
      "key": "tts-device-id",
      "type": "string"
    }
  ],
  "id": "62a0f9db788eeb581b8f9d44",
  "name": "Send Downlink: Uplink Interval",
  "nodes": [
    {
      "config": {
        "authCredentials": {
        },
        "authType": "none",
        "bodyTemplate": "{\n  \"downlinks\":[{\n    \"frm_payload\":\"{{{ intervalInBase64 }}}\",\n    \"f_port\":2,\n    \"priority\":\"NORMAL\",\n    \"confirmed\": true\n  }]\n}",
        "bodyType": "string",
        "caCertTemplate": "",
        "disableSSLVerification": false,
        "encodingTemplate": "utf8",
        "errorBehavior": "throw",
        "errorPath": "",
        "headerInfo": [
          {
            "key": "Authorization",
            "valueTemplate": "Bearer {{ globals.tts-wegnology-schedule-downlink-api-key }}"
          },
          {
            "key": "Content-Type",
            "valueTemplate": "application/json"
          },
          {
            "key": "User-Agent",
            "valueTemplate": "integrationToTTS/v0_1"
          }
        ],
        "method": "POST",
        "requestEncodingTemplate": "utf8",
        "responsePath": "working.httpResult",
        "timeoutTemplate": "",
        "uriTemplate": "{{globals.tts-api-url}}/{{globals.tts-application-id}}/webhooks/{{globals.tts-webhook-id}}/devices/{{globals.tts-device-id}}/down/push"
      },
      "id": "StjsMaz2_O",
      "meta": {
        "category": "data",
        "description": "",
        "label": "TTS Downlink API",
        "name": "http",
        "x": 380,
        "y": 800
      },
      "outputIds": [
        [
          "Kw4dXkvlMf"
        ]
      ],
      "type": "HttpNode"
    },
    {
      "config": {
        "message": "",
        "property": ""
      },
      "id": "Kw4dXkvlMf",
      "meta": {
        "category": "output",
        "description": "",
        "label": "Debug",
        "name": "debug",
        "x": 380,
        "y": 1020
      },
      "outputIds": [
      ],
      "type": "DebugNode"
    },
    {
      "config": {
        "script": "payload.intervalInBase64 = Buffer.from(payload.data.intervalInHex , 'hex').toString('base64')"
      },
      "id": "cbPd6dtzLq",
      "meta": {
        "category": "logic",
        "description": "",
        "label": "Hex to Base64",
        "name": "function",
        "x": 380,
        "y": 620
      },
      "outputIds": [
        [
          "StjsMaz2_O"
        ]
      ],
      "type": "RawFunctionNode"
    },
    {
      "config": {
      },
      "id": "0esSDhvEJm",
      "meta": {
        "annotationText": "### Overview\n\nThis workflow will update the end device's transmit interval by sending a downlink message to TTS that will be forwarded to the end device.\n\nMake sure to set the following workflow global values:\n\n- tts-wegnology-schedule-downlink-api-key\n- tts-webhook-id\n- tts-application-id\n- tts-api-url\n- tts-device-id",
        "category": "annotation",
        "height": 300,
        "label": "Note",
        "name": "note",
        "width": 600,
        "x": 180,
        "y": 80
      },
      "outputIds": [
      ],
      "type": "AnnotationNode"
    },
    {
      "config": {
      },
      "id": "CaswD3_MBA",
      "meta": {
        "annotationText": "Each Virtual Button contains the hex-encoded value to update the end device's transmit interval. Each Virtual Button has a different value to change the interval (1 min, 5 mins, 10 mins, and 20 mins).",
        "category": "annotation",
        "height": 120,
        "label": "Note",
        "name": "note",
        "width": 520,
        "x": 880,
        "y": 400
      },
      "outputIds": [
      ],
      "type": "AnnotationNode"
    },
    {
      "config": {
      },
      "id": "mbeyRNiAxk",
      "meta": {
        "annotationText": "Convert the hex string from the Virtual Button to Base64.",
        "category": "annotation",
        "height": 100,
        "label": "Note",
        "name": "note",
        "width": 320,
        "x": 40,
        "y": 600
      },
      "outputIds": [
      ],
      "type": "AnnotationNode"
    },
    {
      "config": {
      },
      "id": "JHTlyQEr4B",
      "meta": {
        "annotationText": "Call the TTS downlink webhook to schedule the downlink message to the end device. The URL and authorization header all come from workflow globals.",
        "category": "annotation",
        "height": 140,
        "label": "Note",
        "name": "note",
        "width": 320,
        "x": 580,
        "y": 760
      },
      "outputIds": [
      ],
      "type": "AnnotationNode"
    }
  ],
  "triggers": [
    {
      "config": {
      },
      "key": "62a0f9db788eeb581b8f9d44-OtxMHpHIEHVfQGeF2R6lP",
      "meta": {
        "category": "trigger",
        "description": "",
        "label": "1 min / 60 sec",
        "name": "virtualButton",
        "payload": "{\n    \"intervalInHex\": \"0100003C\"\n}",
        "uiId": "u8uIQ5x0uO",
        "x": 80,
        "y": 420
      },
      "outputIds": [
        [
          "cbPd6dtzLq"
        ]
      ],
      "type": "virtualButton"
    },
    {
      "config": {
      },
      "key": "62a0f9db788eeb581b8f9d44-Qzw6YTWaTjYjsnw53UfwP",
      "meta": {
        "category": "trigger",
        "description": "",
        "label": "5 min / 300 sec",
        "name": "virtualButton",
        "payload": "{\n    \"intervalInHex\": \"0100012C\"\n}",
        "uiId": "QeqmnJBXVU",
        "x": 280,
        "y": 420
      },
      "outputIds": [
        [
          "cbPd6dtzLq"
        ]
      ],
      "type": "virtualButton"
    },
    {
      "config": {
      },
      "key": "62a0f9db788eeb581b8f9d44-Vk8YdmWtHObX_UOG8zL28",
      "meta": {
        "category": "trigger",
        "description": "",
        "label": "10 min / 600 sec",
        "name": "virtualButton",
        "payload": "{\n    \"intervalInHex\": \"01000258\"\n}",
        "uiId": "DLYOMaALLV",
        "x": 480,
        "y": 420
      },
      "outputIds": [
        [
          "cbPd6dtzLq"
        ]
      ],
      "type": "virtualButton"
    },
    {
      "config": {
      },
      "key": "62a0f9db788eeb581b8f9d44-wQiyBTDtz4aFcrloPoisC",
      "meta": {
        "category": "trigger",
        "description": "",
        "label": "20 min / 1200 sec",
        "name": "virtualButton",
        "payload": "{\n    \"intervalInHex\": \"010004B0\"\n}",
        "uiId": "7pnO8z9wyd",
        "x": 680,
        "y": 420
      },
      "outputIds": [
        [
          "cbPd6dtzLq"
        ]
      ],
      "type": "virtualButton"
    }
  ]
}