Our house runs on two systems that each do what they’re best at. Home Assistant manages devices — lights, covers, sensors, switches, presence. It’s the entity layer: it knows what exists, what state things are in, and exposes them to dashboards and voice control. Node-RED handles the logic — the flows that decide what should happen when. It’s the brain.
The split exists because HA’s native automations are YAML-based and limited in expressiveness. Node-RED gives us a visual, debuggable flow engine with proper programming constructs. But flows without structure become opaque spaghetti. We learned that the hard way when a Shelly device reconnecting at 3am triggered the house into “day mode” while everyone was asleep.
So we built a state machine. One function node in Node-RED that controls the entire house mode. Six states: night, morning, day, evening, away, manual. Every transition goes through a single entry point (system:transition-request) and gets validated against a transition map, source-type gating, and cooldown guards.
The core rule: only intentional actions change house mode. Buttons always work. The sun sensor drives morning→day and day→evening transitions. Presence detection handles away/return. Everything else — reboots, WiFi reconnections, relay state changes — is rejected. The state machine doesn’t care what your Shelly did at 3am.
Morning mode is special. When you press the good morning button and it’s still dark, the house enters a gentle activation: lights ramp over two minutes instead of snapping on, covers open after a 15-second delay. When it’s already light, you skip straight to day mode — instant everything.
The consumer side is a subflow with 36 instances across every room tab. Each instance routes messages by current mode: morning gets the gentle treatment, day and evening get instant activation, night only turns things off (sensors clearing → off, but never auto-on), away kills everything. Buttons always work regardless of mode — they’re wired independently.
HA for devices. Node-RED for decisions. A state machine that refuses to be surprised.
// end