{
  "name": "Voltcast Home — negative-price alert",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      },
      "name": "Every hour",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "url": "https://voltcast.com/api/v1/prices/DE-LU",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "name": "Get published prices",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [240, 0],
      "notes": "Header Auth: Authorization = Bearer YOUR_VOLTCAST_KEY. Keep DE-LU equal to the zone selected on Home."
    },
    {
      "parameters": {
        "jsCode": "const rows = $json.data || [];\nconst negative = rows.filter((row) => Number(row.price_eur_mwh) < 0);\nreturn [{ json: {\n  zone: $json.meta?.zone || 'DE-LU',\n  has_negative_prices: negative.length > 0,\n  count: negative.length,\n  intervals: negative.map((row) => ({ start: row.delivery_start, end: row.delivery_end, eur_mwh: Number(row.price_eur_mwh) })),\n  source: 'Voltcast published day-ahead prices'\n} }];"
      },
      "name": "Find negative intervals",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [500, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.has_negative_prices }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        }
      },
      "name": "Any negative prices?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [760, 0],
      "notes": "Attach email, Slack, Home Assistant, or another notification node to the true branch."
    }
  ],
  "connections": {
    "Every hour": {
      "main": [[{ "node": "Get published prices", "type": "main", "index": 0 }]]
    },
    "Get published prices": {
      "main": [[{ "node": "Find negative intervals", "type": "main", "index": 0 }]]
    },
    "Find negative intervals": {
      "main": [[{ "node": "Any negative prices?", "type": "main", "index": 0 }]]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "voltcastCampaign": "home-negative-price-alert",
    "signupUrl": "https://voltcast.com/register?plan=home&utm_source=n8n&utm_medium=workflow-template&utm_campaign=home-negative-price-alert&task=n8n&zone=DE-LU"
  }
}
