I let an AI agent flip my circuit breakers (carefully)
An n8n agentic workflow that reads email notifications and switches smart MCBs over MQTT, and the guardrails you need when an LLM can touch the physical world.
Updated
On this page · 6 sections
Most agentic AI demos stop at the screen: an agent that drafts an email, files a ticket, or summarises a document. I wanted to see what changes when the agent’s output is physical. So I built an agentic workflow in n8n that controls the smart MCBs (miniature circuit breakers) in my home, based on email notifications.
It works. What it taught me about agents that act in the real world turned out to be the more interesting part.
How does the agentic workflow work?
The pipeline has four stages:
- n8n watches an inbox for incoming notifications.
- An AI agent step reads the email and decides whether it calls for an action, and which one.
- Deterministic checks decide whether that action is allowed.
- The approved command is published over MQTT to the smart breaker, and the result is logged and reported back.
n8n suits this well. It has visual workflows, email and MQTT nodes, AI agent nodes, and a Code node for the steps that need real logic.
Where it runs
n8n 2.40 runs on my Raspberry Pi Kubernetes cluster, installed from the official Helm chart and deployed by Argo CD. It runs in queue mode: one main instance handles triggers and the editor, and workers pick up executions from Redis, scaling from one to five on CPU. I keep the main instance at one replica on purpose. Without n8n’s multi-main setup, a second copy would fire every schedule and polling trigger twice, and a breaker is the last thing I want switched twice. Workflows and credentials live in the cluster’s shared Postgres, and the MQTT broker is Mosquitto on the same cluster.
Moving from my own hand-written manifests to the Helm chart taught me one thing the hard way. n8n encrypts stored credentials with a key it generates on first start. The new install had to reuse the same data volume and that exact key, read from the running pod, or every saved credential would have become unreadable.
The model decides intent. Code decides permission.
This was the most important design decision, and it applies well beyond home automation. The language model is very good at reading messy email. It should never be what decides whether a circuit is allowed to switch.
So the agent’s only job is to produce a small, structured intent, something like device, action, reason. Everything after that is plain code:
- An allowlist of devices the workflow may touch, and the actions permitted on each.
- Schema validation: anything that doesn’t parse into a known intent is rejected instead of guessed at.
- Rate limits and cooldowns, so a flood of emails can’t toggle a breaker repeatedly.
- A sender check, so only trusted sources can trigger actions.
Treat every input as hostile
Anyone on the internet can send instructions to an agent that reads email, and prompt injection stops being theoretical when the output is a relay. Because the model only emits an intent and never calls the device directly, a malicious email can at worst produce an intent that the validation layer rejects.
Close the loop
Every action is logged with the triggering email, the parsed intent, the validation result and the device’s confirmed state after the command. When something unexpected happens (and with IoT, something always does), that trail is how you find out whether the model, the rules or the hardware was at fault.
What this taught me about agents
The more real-world power an agent has, the smaller its decision surface should be. The same principle holds at work and at FinMoon AI: let the model interpret, let deterministic code authorise and execute, and log everything. My breakers are the low-stakes version of a question every company adopting agents has to answer: what exactly are we letting it touch?