AutomationFlowsGeneral › Home Assistant Event Triggering with Appdaemon Webhooks

Home Assistant Event Triggering with Appdaemon Webhooks

ByAdrian Kendall @akendall1966 on n8n.io

This is a minimal template that focuses on how to integrate n8n and Home Assistant for event-based triggering from Home Assistant using the AppDaemon addon to call a webhook node.

Webhook trigger★★☆☆☆ complexity4 nodes
General Trigger: Webhook Nodes: 4 Complexity: ★★☆☆☆ Added:

This workflow corresponds to n8n.io template #6693 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "RJ4nSdsxI4FQiDI4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AppDaemon Webhook",
  "tags": [],
  "nodes": [
    {
      "id": "2c448b0c-acba-415b-854e-6413e0070d51",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        -48
      ],
      "parameters": {
        "width": 1024,
        "height": 1664,
        "content": "## Triggering N8N from Home Assistant using AppDaemon\n\n\n\n\n\n\n\n\n\n\nThere is no N8N node or API endpoint in Home Assistant that allows a workflow to be triggered on an event in Home Assistant.\nA workaround is to use the AppDaemon addon in Home Assistant to create a listener to catch an event in Home Assistant that calls a N8N webhook to trigger the flow.\n \nThe python code implements an AppDaemon class that initialises an event listener. When an event is registered the N8N webhook is called POSTing the event data to N8N to process in the workflow. The N8N webhook trigger node should use the POST method.\n\nSee the Home Assistant event documentation, for details of events. https://www.home-assistant.io/docs/configuration/events/\n\nThe lines in the code commented #EDIT should be changed to your instance and use case.\n\nCode:\n\n```\nimport appdaemon.plugins.hass.hassapi as hass\nimport requests\nimport json\nclass EventToN8NWebhook(hass.Hass):\n    \"\"\"\n    AppDaemon app that listens for Home Assistant events and forwards them to n8n webhook\n    \"\"\"\n#\n# \n    def initialize(self):\n        \"\"\"\n        Initialize the event listener and configure webhook settings\n        \"\"\"\n        # EDIT: Replace 'your_event_name' with the actual event you want to listen for\n        # Common HA events: 'state_changed', 'call_service', 'automation_triggered', etc.\n        self.target_event = self.args.get('target_event', 'event_name')\n        \n        # EDIT: Set your n8n webhook URL in apps.yaml or replace the default here\n        self.webhook_url = self.args.get('webhook_url', 'n8n_webhook_url')\n        \n        # EDIT: Optional - set timeout for webhook requests (seconds)\n        self.webhook_timeout = self.args.get('webhook_timeout', 10)\n        \n        # EDIT: Optional - enable/disable SSL verification\n        self.verify_ssl = self.args.get('verify_ssl', True)\n        \n        # Set up the event listener\n        self.listen_event(self.event_handler, self.target_event)\n        \n        self.log(f\"Event listener initialized for event: {self.target_event}\")\n        self.log(f\"Webhook URL configured: {self.webhook_url}\")\n#\n#\n    def event_handler(self, event_name, data, kwargs):\n        \"\"\"\n        Handle the triggered event and forward to n8n webhook\n        Args:\n            event_name (str): Name of the triggered event\n            data (dict): Event data from Home Assistant\n            kwargs (dict): Additional keyword arguments from the event\n        \"\"\"\n        try:\n            # Prepare payload for n8n webhook\n            payload = {\n                'event_name': event_name,\n                'event_data': data,\n                'event_kwargs': kwargs,\n                'timestamp': self.datetime().isoformat(),\n                'source': 'home_assistant_appdaemon'\n            }\n            \n            self.log(f\"Received event '{event_name}' - forwarding to n8n\")\n            self.log(f\"Event data: {data}\")\n            \n            # Send to n8n webhook\n            self.send_to_n8n(payload)\n            \n        except Exception as e:\n            self.log(f\"Error handling event {event_name}: {str(e)}\", level=\"ERROR\")\n#\n#\n    def send_to_n8n(self, payload):\n        \"\"\"\n        Send payload to n8n webhook\n        Args:payload (dict): Data to send to n8n\n        \"\"\"\n        try:\n            headers = {\n                'Content-Type': 'application/json',\n#EDIT assume header authentication parameter and value below need to match what is set in the credential used in the node.\n                'CredName': 'credValue', #set to what you set up as a credential for the webhook node\n            }\n            \n            response = requests.post(\n                self.webhook_url,\n                json=payload,\n                headers=headers,\n                timeout=self.webhook_timeout,\n                verify=self.verify_ssl\n            )\n            \n            response.raise_for_status()\n            \n            self.log(f\"Successfully sent event to n8n webhook. Status: {response.status_code}\")\n            \n            # EDIT: Optional - log response from n8n for debugging\n            if response.text:\n                self.log(f\"n8n response: {response.text}\")\n                \n        except requests.exceptions.Timeout:\n            self.log(f\"Timeout sending to n8n webhook after {self.webhook_timeout}s\", level=\"ERROR\")\n        except requests.exceptions.RequestException as e:\n            self.log(f\"Error sending to n8n webhook: {str(e)}\", level=\"ERROR\")\n        except Exception as e:\n            self.log(f\"Unexpected error sending to n8n: {str(e)}\", level=\"ERROR\")\n       ```"
      },
      "typeVersion": 1
    },
    {
      "id": "a2c5ad96-0547-415d-8276-f2a95dbf1b60",
      "name": "Home Assistant Event Trigger",
      "type": "n8n-nodes-base.webhook",
      "position": [
        96,
        -32
      ],
      "parameters": {
        "path": "758ef827-bafc-4241-83f8-6e745b21fc44",
        "options": {},
        "httpMethod": "POST",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b5055ca1-817f-4e15-81ad-0dc995b43b4c",
      "name": "Process data from webhook",
      "type": "n8n-nodes-base.noOp",
      "position": [
        400,
        -32
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "935d2974-1a08-42da-8fe4-231905921e4a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        -64
      ],
      "parameters": {
        "color": 3,
        "width": 448,
        "height": 384,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Continue the workflow as needed\n"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cd794c4b-e82f-454b-b05a-5c3f508f88f6",
  "connections": {
    "Home Assistant Event Trigger": {
      "main": [
        [
          {
            "node": "Process data from webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This is a minimal template that focuses on how to integrate n8n and Home Assistant for event-based triggering from Home Assistant using the AppDaemon addon to call a webhook node.

Source: https://n8n.io/workflows/6693/ — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

HR tool. Uses googleSheets. Webhook trigger; 12 nodes.

Google Sheets
General

Http Stickynote. Uses stickyNote, httpRequest, highLevel. Webhook trigger; 10 nodes.

HTTP Request, High Level
General

Http Keap. Uses stickyNote, httpRequest, keap. Webhook trigger; 10 nodes.

HTTP Request, Keap
General

Http Stickynote. Uses stickyNote, httpRequest. Webhook trigger; 10 nodes.

HTTP Request
General

Trigger Local Falcon scan from webhook request. Uses @local-falcon/n8n-nodes-localfalcon. Webhook trigger; 10 nodes.

@Local Falcon/N8N Nodes Localfalcon