{
  "name": "Mammal Detection",
  "description": "Ontvang mammal-watcher detecties via MQTT en stuur Telegram/InfluxDB alerts. Compatibel met n8n 2.8.4.",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83e\udda1 Mammal-watcher workflow\n\nDeze workflow ontvangt detecties van de **mammal-watcher** service via MQTT.\n\n- **Tier 1** (zeldzaam): directe Telegram-alert met sirene-emoji\n- **Tier 2** (gewoon-interessant): vriendelijke Telegram-melding\n- **Alle tiers**: opslaan in InfluxDB voor Grafana-dashboard\n\n**Importeren:** Ga in n8n naar *Workflows \u2192 Import from file* en selecteer dit bestand.\nPas daarna de MQTT-, Telegram- en InfluxDB-credentials aan.\n\n**MQTT broker:** homeassistant:1883 \u2014 zelfde broker als BirdNET-Go.\n**Topic:** mammal/detection\n\n_Compatibel met n8n 2.8.4_"
      },
      "id": "sticky-note-intro",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -200
      ]
    },
    {
      "parameters": {
        "topics": "mammal/detection",
        "options": {}
      },
      "id": "mqtt-trigger-node",
      "name": "MQTT Trigger",
      "type": "n8n-nodes-base.mqttTrigger",
      "typeVersion": 1,
      "position": [
        300,
        0
      ],
      "credentials": {
        "mqtt": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"tier\"]}}",
              "operation": "equal",
              "value2": 1
            }
          ]
        }
      },
      "id": "if-tier1",
      "name": "Tier 1?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        550,
        0
      ]
    },
    {
      "parameters": {
        "chatId": "JOUW_TELEGRAM_CHAT_ID",
        "text": "=\ud83d\udea8 TIER 1 ZOOGDIER: {{$json[\"species_nl\"]}} {{$json[\"emoji\"]}} (conf={{$json[\"confidence\"]}}) \u2014 {{$json[\"source\"]}}",
        "additionalFields": {}
      },
      "id": "telegram-tier1",
      "name": "Telegram Tier 1",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        800,
        -100
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"tier\"]}}",
              "operation": "equal",
              "value2": 2
            }
          ]
        }
      },
      "id": "if-tier2",
      "name": "Tier 2?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        800,
        100
      ]
    },
    {
      "parameters": {
        "chatId": "JOUW_TELEGRAM_CHAT_ID",
        "text": "={{$json[\"emoji\"] || \"\ud83e\udda1\"}} {{$json[\"species_nl\"]}} gehoord (conf={{$json[\"confidence\"]}})",
        "additionalFields": {}
      },
      "id": "telegram-tier2",
      "name": "Telegram Tier 2",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        1050,
        0
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "write",
        "url": "http://hp640.local:8086",
        "bucket": "wildlife",
        "org": "thuis",
        "measurement": "mammal_detection",
        "tags": {
          "tag": [
            {
              "name": "species_scientific",
              "value": "={{$json[\"species_scientific\"]}}"
            },
            {
              "name": "tier",
              "value": "={{$json[\"tier\"]}}"
            },
            {
              "name": "model_version",
              "value": "={{$json[\"model_version\"]}}"
            }
          ]
        },
        "fields": {
          "field": [
            {
              "name": "confidence",
              "type": "float",
              "value": "={{$json[\"confidence\"]}}"
            },
            {
              "name": "rms",
              "type": "float",
              "value": "={{$json[\"rms\"]}}"
            },
            {
              "name": "duration_s",
              "type": "float",
              "value": "={{$json[\"duration_s\"]}}"
            }
          ]
        }
      },
      "id": "influxdb-node",
      "name": "InfluxDB",
      "type": "n8n-nodes-base.influxDb",
      "typeVersion": 1,
      "position": [
        550,
        200
      ],
      "credentials": {
        "influxDbApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "MQTT Trigger": {
      "main": [
        [
          {
            "node": "Tier 1?",
            "type": "main",
            "index": 0
          },
          {
            "node": "InfluxDB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tier 1?": {
      "main": [
        [
          {
            "node": "Telegram Tier 1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tier 2?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tier 2?": {
      "main": [
        [
          {
            "node": "Telegram Tier 2",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "active": false,
  "settings": {},
  "tags": [
    "mammal-watcher",
    "wildlife"
  ]
}