{
 "id": "realweatheralert",
 "name": "AutomateRecipes \u2013 weather-alert-tomorrow",
 "nodes": [
  {
   "parameters": {
    "rule": {
     "interval": [
      {
       "field": "days",
       "triggerAtHour": 18
      }
     ]
    }
   },
   "name": "Schedule Trigger",
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1.2,
   "position": [
    0,
    0
   ],
   "id": "1232a011-6e0e-455e-be7a-ec89ffe16651"
  },
  {
   "parameters": {
    "jsCode": "// EDIT THESE SETTINGS\nreturn [{json:{\n \"ntfyTopic\": \"CHANGE-ME-to-a-long-random-topic\",\n \"place\": \"Riyadh\",\n \"latitude\": 24.71,\n \"longitude\": 46.68,\n \"rainChancePct\": 40,\n \"hotC\": 45,\n \"windKmh\": 40\n}}];"
   },
   "name": "Config",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    240,
    0
   ],
   "id": "fd9d3615-9974-431d-bb56-54a009e55a65"
  },
  {
   "parameters": {
    "url": "=https://api.open-meteo.com/v1/forecast?latitude={{ $json.latitude }}&longitude={{ $json.longitude }}&daily=precipitation_probability_max,temperature_2m_max,wind_speed_10m_max&timezone=auto&forecast_days=2",
    "options": {
     "timeout": 15000
    }
   },
   "name": "Get forecast (Open-Meteo)",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    480,
    0
   ],
   "id": "51259879-c801-4247-8095-366880b3d8bc"
  },
  {
   "parameters": {
    "jsCode": "const c=$('Config').first().json,d=$input.first().json.daily;const t={date:d.time[1],rain:d.precipitation_probability_max[1],tmax:d.temperature_2m_max[1],wind:d.wind_speed_10m_max[1]};const w=[];if(t.rain>=c.rainChancePct)w.push(`rain chance ${t.rain}%`);if(t.tmax>=c.hotC)w.push(`max ${t.tmax}\u00b0C`);if(t.wind>=c.windKmh)w.push(`wind ${t.wind} km/h`);if(!w.length)return [];return [{json:{title:`Weather alert for ${c.place} ${t.date}`,tags:'cloud',message:w.join(', ')+'. Plan outdoor work/seating/deliveries accordingly.',forecast:t}}];"
   },
   "name": "Check tomorrow",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    720,
    0
   ],
   "id": "6e435f3b-a339-44ca-97a9-2226cd0a553d"
  },
  {
   "parameters": {
    "method": "POST",
    "url": "=https://ntfy.sh/{{ $('Config').first().json.ntfyTopic }}",
    "sendHeaders": true,
    "headerParameters": {
     "parameters": [
      {
       "name": "Title",
       "value": "={{ $json.title }}"
      },
      {
       "name": "Tags",
       "value": "={{ $json.tags || 'bell' }}"
      }
     ]
    },
    "sendBody": true,
    "contentType": "raw",
    "rawContentType": "text/plain",
    "body": "={{ $json.message }}",
    "options": {}
   },
   "name": "Send ntfy alert",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    960,
    0
   ],
   "id": "037a6596-dc27-4216-ba88-891c7ca7f300"
  },
  {
   "parameters": {},
   "name": "Run manually (test)",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    200
   ],
   "id": "70665dcd-4d42-4c5d-949b-33836c6a382a"
  }
 ],
 "connections": {
  "Schedule Trigger": {
   "main": [
    [
     {
      "node": "Config",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Config": {
   "main": [
    [
     {
      "node": "Get forecast (Open-Meteo)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Get forecast (Open-Meteo)": {
   "main": [
    [
     {
      "node": "Check tomorrow",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Check tomorrow": {
   "main": [
    [
     {
      "node": "Send ntfy alert",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Run manually (test)": {
   "main": [
    [
     {
      "node": "Config",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "active": false,
 "pinData": {}
}