hass-n8n
Copilot instructions220 starsChanged 4 days agoApache-2.0View on GitHub
This is a Home Assistant addon that packages n8n (workflow automation tool) as a Docker container with nginx reverse proxy for secure access through Home Assistant's ingress system. Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
- Installs packages
We split this copilot-instructions.md into the rules it gives an agent
26 rules. About 3 are common, 18 are distinctive, and 5 are very specific to this project.
≈3
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 5
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does …
- Distinctive: line 32
Run tests manually (recommended approach):
- Distinctive: line 40
Run tests with automated container management:
- Distinctive: line 57
Always test your changes using the same commands before submitting PRs
- Distinctive: line 62
After making code changes, ALWAYS run through these validation scenarios:
- Distinctive: line 67
All services (nginx, n8n) start successfully
- Common: line 71
No critical network failures (500+ HTTP errors)
- Distinctive: line 72
All required ports respond (5000, 5678, 5690, 8081)
- Common: line 76
No JavaScript console errors
- Distinctive: line 86
ALWAYS: run network health tests after any configuration changes
- Very specific: line 87
ALWAYS: test container lifecycle (start/stop/restart) after infrastructure changes
- Distinctive: line 88
ALWAYS: verify ingress configuration after nginx.conf modifications
- Very specific: line 89
ALWAYS: test environment variable parsing after n8n-exports.sh changes
- Distinctive: line 104
Test execution: Set timeout to 300+ seconds (5+ minutes)
- Distinctive: line 131
5000: Test ingress port (testing only)
- Common: line 157
Permission errors: Ensure scripts have execute permissions
- Very specific: line 160
Container not ready: Wait longer, check docker ps and curl localhost:5000
- Distinctive: line 162
Port conflicts: Stop conflicting services, use different ports
- Distinctive: line 165
n8n not accessible: Check nginx configuration and ingress setup
- Very specific: line 166
Webhook failures: Verify port 8081 accessibility and WEBHOOK_URL setting
- Distinctive: line 173
ALWAYS: run full validation scenarios for your change area
- Distinctive: line 175
ALWAYS: test both production and test configurations when modifying nginx
- Distinctive: line 179
nginx.conf changes: Test both ingress ports (5000, 5690) and webhook port (8081)
- Very specific: line 180
n8n-exports.sh changes: Verify environment variable parsing and n8n startup
- Distinctive: line 181
supervisord.conf changes: Test process management and service startup
- Distinctive: line 182
test scripts: Run full test suite and verify CI compatibility
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
hass-n8n - Home Assistant Addon for n8n
This is a Home Assistant addon that packages n8n (workflow automation tool) as a Docker container with nginx reverse proxy for secure access through Home Assistant's ingress system.
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
Working Effectively
Prerequisites and Dependencies
- Docker must be installed and running
- Node.js and npm are required for running tests
- Internet access is required for Docker image downloads and package installations
Bootstrap and Build Process
- Build the Docker image:
docker build --build-arg NGINX_ALLOWED_IP=all --target hass-n8n-end-to-end-test -t hass-n8n-test .- NEVER CANCEL: Build takes 3-5 minutes for dependencies download. NEVER CANCEL. Set timeout to 10+ minutes.
- May fail in restricted network environments due to Alpine package repository access
Test Setup and Execution
- Install test dependencies:
cd tests npm install npx playwright install- NEVER CANCEL: Playwright browser installation takes 2-3 minutes. Set timeout to 10+ minutes.
- May fail in restricted environments due to browser download restrictions
- Run tests manually (recommended approach):
cd tests ./start-addon.sh # In one terminal npm test # In another terminal after container is ready- NEVER CANCEL: Container startup takes up to 2 minutes. Test suite takes 1-2 minutes.
- Run tests with automated container management:
cd tests ./run-tests.sh # Headless mode ./run-tests.sh --ui # With Playwright UI ./run-tests.sh --debug # Debug mode ./run-tests.sh --headed # Visible browser
CI/CD Validation
- The CI pipeline (
.github/workflows/pull-request-change.yaml) runs:cd tests npm i npx playwright install npm run test:e2e - Always test your changes using the same commands before submitting PRs
Validation Scenarios
Manual Testing Requirements
After making code changes, ALWAYS run through these validation scenarios:
- Container Build and Startup:
- Build completes without errors
- Container starts within 2 minutes
- All services (nginx, n8n) start successfully
- Network Health Validation:
- Main application loads on localhost:5000 (test mode)
- No critical network failures (500+ HTTP errors)
- All required ports respond (5000, 5678, 5690, 8081)
- Core Functionality Testing:
- n8n web interface loads completely
- No JavaScript console errors
- Authentication system works if configured
- Basic workflow creation/editing functions
- Integration Testing:
- Webhook endpoints respond on port 8081
- Home Assistant ingress simulation works
- Environment variable configuration loads properly
Required Test Scenarios
- ALWAYS run network health tests after any configuration changes
- ALWAYS test container lifecycle (start/stop/restart) after infrastructure changes
- ALWAYS verify ingress configuration after nginx.conf modifications
- ALWAYS test environment variable parsing after n8n-exports.sh changes
Build Timing and Expectations
Expected Durations
- Docker Build: 3-5 minutes (first time), 1-2 minutes (cached)
- Test Dependencies: 1-2 minutes for npm install, 2-3 minutes for Playwright
- Container Startup: 30-120 seconds depending on system
- Test Execution: 1-2 minutes for full suite
- Total Validation: 5-10 minutes for complete cycle
Timeout Recommendations
- Docker build commands: Set timeout to 600+ seconds (10+ minutes)
- Playwright install: Set timeout to 600+ seconds (10+ minutes)
- Container startup: Set timeout to 180+ seconds (3+ minutes)
- Test execution: Set timeout to 300+ seconds (5+ minutes)
Repository Structure
Key Configuration Files
config.json- Home Assistant addon configurationDockerfile- Multi-stage Docker build (base → test → final)supervisord.conf- Process management for nginx and n8nnginx.conf- Reverse proxy configuration with ingress simulationn8n-exports.sh- Environment variable setup and n8n configuration
Build Scripts and Entry Points
n8n-entrypoint.sh- n8n startup scriptnginx-entrypoint.sh- nginx configuration and startuptests/start-addon.sh- Test container build and startuptests/playwright.config.ts- Test configuration
Test Structure
tests/e2e/- End-to-end test scenariostests/supervisor/- Mock Home Assistant supervisor datatests/nginx.tests.conf- Test-specific nginx configuration
Port Configuration
Application Ports
- 5678: n8n main application (internal)
- 5690: Home Assistant ingress port (production)
- 5000: Test ingress port (testing only)
- 8081: Webhook and API traffic (exposed)
Network Access Patterns
- Production: HA Ingress → nginx:5690 → n8n:5678
- Testing: Browser → nginx:5000 → n8n:5678
- Webhooks: External → nginx:8081 → n8n:5678
Environment Variables
Critical Environment Variables
NGINX_ALLOWED_IP: Controls nginx access (use "all" for testing)N8N_PATH: URL path prefix for n8nWEBHOOK_URL: External webhook URL for triggersEXTERNAL_URL: External URL for OAuth redirects
Configuration Loading
- Environment variables defined in
env_vars_listin config.json - Processed by
n8n-exports.shscript - External npm packages installed if
NODE_FUNCTION_ALLOW_EXTERNALis set
Troubleshooting Common Issues
Build Failures
- Alpine package errors: Usually network/firewall restrictions
- Docker build timeouts: Increase timeout, check Docker daemon
- Permission errors: Ensure scripts have execute permissions
Test Failures
- Container not ready: Wait longer, check
docker psandcurl localhost:5000 - Browser dependency errors: Install system dependencies or use alternative browser
- Port conflicts: Stop conflicting services, use different ports
Runtime Issues
- n8n not accessible: Check nginx configuration and ingress setup
- Webhook failures: Verify port 8081 accessibility and WEBHOOK_URL setting
- OAuth issues: Confirm EXTERNAL_URL is correctly configured
Development Workflow
Making Changes
- ALWAYS build and test locally before committing
- ALWAYS run full validation scenarios for your change area
- NEVER skip container startup verification
- ALWAYS test both production and test configurations when modifying nginx
Code Areas and Validation
- Dockerfile changes: Build and test container functionality
- nginx.conf changes: Test both ingress ports (5000, 5690) and webhook port (8081)
- n8n-exports.sh changes: Verify environment variable parsing and n8n startup
- supervisord.conf changes: Test process management and service startup
- test scripts: Run full test suite and verify CI compatibility
Git Workflow
- Feature branches are tested via GitHub Actions
- Pull requests trigger automatic testing
- Releases use multi-architecture Docker builds (amd64, aarch64)
Common Tasks Reference
Repository Root Contents
.github/ # GitHub Actions workflows and configurations
tests/ # Playwright end-to-end tests
config.json # Home Assistant addon configuration
Dockerfile # Multi-stage Docker build definition
supervisord.conf # Process supervisor configuration
nginx.conf # Reverse proxy configuration
n8n-exports.sh # Environment setup script
n8n-entrypoint.sh # n8n startup script
nginx-entrypoint.sh # nginx startup scriptTest Package.json Scripts
{
"test": "npx playwright test",
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:e2e:debug": "playwright test --debug",
"test:headed": "playwright test --headed",
"test:with-docker": "./run-tests.sh",
"start-addon": "./start-addon.sh"
}Docker Build Targets
base: Core n8n setup with dependencieshass-n8n-end-to-end-test: Test configuration with test nginx configfinal: Production image for Home Assistant
This addon enables n8n workflow automation within Home Assistant with secure ingress access and proper webhook handling for external integrations.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

