{
  "id": "btmWeeklyRoutine",
  "name": "Basketball team manager - weekly",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                4
              ],
              "triggerAtHour": 15,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "tue-train",
      "name": "Thu 15:00 training",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "http://192.168.20.13:8420/post/training?if=changed",
        "sendBody": false,
        "options": {
          "timeout": 45000,
          "response": {
            "response": {
              "responseFormat": "text",
              "neverError": true
            }
          }
        }
      },
      "id": "train-http",
      "name": "Post training reminder",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        0
      ],
      "notes": ""
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "sent",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            },
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "unchanged",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            },
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "skipped",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            }
          ],
          "combinator": "or"
        }
      },
      "id": "train-if",
      "name": "Training sent?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://192.168.20.35:8210/notify/btm",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Basketball routine failed', body: $json.data }) }}",
        "options": {
          "timeout": 20000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "train-alert",
      "name": "Alert: training failed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        120
      ],
      "notes": "Sends to Apprise key btm, which posts to the ntfy topic btm-alerts."
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                5
              ],
              "triggerAtHour": 9,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "fri-refresh",
      "name": "Fri 09:00 refresh",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        240
      ]
    },
    {
      "parameters": {
        "url": "http://192.168.20.13:8420/refresh",
        "sendBody": false,
        "options": {
          "timeout": 45000,
          "response": {
            "response": {
              "responseFormat": "text",
              "neverError": true
            }
          }
        }
      },
      "id": "refresh-http",
      "name": "Refresh fixtures",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        240
      ],
      "notes": ""
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "Written",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "refresh-if",
      "name": "Refresh ok?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        480,
        240
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://192.168.20.35:8210/notify/btm",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Basketball routine failed', body: $json.data }) }}",
        "options": {
          "timeout": 20000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "refresh-alert",
      "name": "Alert: refresh failed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        360
      ],
      "notes": "Sends to Apprise key btm, which posts to the ntfy topic btm-alerts."
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                5
              ],
              "triggerAtHour": 9,
              "triggerAtMinute": 5
            }
          ]
        }
      },
      "id": "fri-game",
      "name": "Fri 09:05 game",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        480
      ]
    },
    {
      "parameters": {
        "url": "http://192.168.20.13:8420/post/game",
        "sendBody": false,
        "options": {
          "timeout": 45000,
          "response": {
            "response": {
              "responseFormat": "text",
              "neverError": true
            }
          }
        }
      },
      "id": "game-http",
      "name": "Post game details",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        480
      ],
      "notes": ""
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "sent",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            },
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "unchanged",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            }
          ],
          "combinator": "or"
        }
      },
      "id": "game-if",
      "name": "Game sent?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        480,
        480
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://192.168.20.35:8210/notify/btm",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Basketball routine failed', body: $json.data }) }}",
        "options": {
          "timeout": 20000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "game-alert",
      "name": "Alert: game post failed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        600
      ],
      "notes": "Sends to Apprise key btm, which posts to the ntfy topic btm-alerts."
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                5
              ],
              "triggerAtHour": 16,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "fri-recheck",
      "name": "Fri 16:00 re-check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        720
      ]
    },
    {
      "parameters": {
        "url": "http://192.168.20.13:8420/post/game?if=changed",
        "sendBody": false,
        "options": {
          "timeout": 45000,
          "response": {
            "response": {
              "responseFormat": "text",
              "neverError": true
            }
          }
        }
      },
      "id": "recheck-http",
      "name": "Re-post if changed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        720
      ],
      "notes": ""
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "sent",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            },
            {
              "leftValue": "={{ $json.data }}",
              "rightValue": "unchanged",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              }
            }
          ],
          "combinator": "or"
        }
      },
      "id": "recheck-if",
      "name": "Re-check ok?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        480,
        720
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://192.168.20.35:8210/notify/btm",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Basketball routine failed', body: $json.data }) }}",
        "options": {
          "timeout": 20000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "recheck-alert",
      "name": "Alert: re-check failed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        840
      ],
      "notes": "Sends to Apprise key btm, which posts to the ntfy topic btm-alerts."
    }
  ],
  "connections": {
    "Post training reminder": {
      "main": [
        [
          {
            "node": "Training sent?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Training sent?": {
      "main": [
        [],
        [
          {
            "node": "Alert: training failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fri 09:00 refresh": {
      "main": [
        [
          {
            "node": "Refresh fixtures",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refresh fixtures": {
      "main": [
        [
          {
            "node": "Refresh ok?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refresh ok?": {
      "main": [
        [],
        [
          {
            "node": "Alert: refresh failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fri 09:05 game": {
      "main": [
        [
          {
            "node": "Post game details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post game details": {
      "main": [
        [
          {
            "node": "Game sent?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Game sent?": {
      "main": [
        [],
        [
          {
            "node": "Alert: game post failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fri 16:00 re-check": {
      "main": [
        [
          {
            "node": "Re-post if changed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Re-post if changed": {
      "main": [
        [
          {
            "node": "Re-check ok?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Re-check ok?": {
      "main": [
        [],
        [
          {
            "node": "Alert: re-check failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Thu 15:00 training": {
      "main": [
        [
          {
            "node": "Post training reminder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  },
  "pinData": {},
  "meta": {
    "description": "Thursday 3pm training reminder (or a no-training note in school holidays). Friday 9am refresh fixtures, 9:05am game details (or a no-game note), 4pm re-post only if the message changed. Any failure sends an Apprise alert: email and phone."
  },
  "versionId": "7c6fa9a7-fa5f-4b54-931c-8d04b7b40abe"
}
