The Problem I Was Trying to Solve§

Managing complex commercial building systems (HVAC, lighting, security cameras, access cards) historically required specialized BMS software and manual scripting. We wanted to build a voice-and-text system where facility managers can give high-level instructions (e.g. "adjust the temperatures in the east wing because the server room is overheating") and have a hierarchical multi-agent team safely translate that request into programmatic IoT control commands.

Our IoT simulation stack was composed of:

  • FastAPI serving as our IoT device controller bridge.
  • Supabase storing active device configurations and temperature telemetry.
  • A team of three agents orchestrating task parsing and execution safety.
# A python schema representing device control commands
class DeviceCommand(BaseModel):
    device_id: str
    action: str
    target_value: float
    reason: str

Step-by-Step: What I Actually Did§

1. Role Division: We set up a three-agent hierarchy: a Doorman agent that intercepts human queries and parses location mapping, a Reasoning agent that calculates target heating/cooling offsets, and a Security agent that checks commands against safe temperature bounds. 2. Programmatic Validation: All commands generated by the reasoning agent were serialized to structured JSON and validated against BMS limits before being sent to physical devices. 3. Telemetry Listeners: We connected telemetry updates (live temperature sensor readings) to the agents' context window, letting them monitor the physical results of their actions.

Results and Takeaways§

  • Energy Optimization: The multi-agent controller reduced energy spikes in the test wing by 15% via smart offsets.
  • Safety First: The security agent successfully blocked a simulated attempt to set the temperature to sub-zero limits.
  • Decouple Thinking from Action: Always have a separate, simple validation script that checks the final output of an LLM before sending actions to hardware devices.