Builder Case Study · AI-Assisted Development

Firewalla Home Assistant Integration

Home Assistant integration for Firewalla Purple — full device/rules/events access through HACS. Vendor of github.com/ccpk1/firewalla-local-ha.

Vendor Python Home Assistant REST API
5 Sessions
2.80M Tokens
1.5¢ Total Cost
6 Key Decisions

Bridging Firewalla and Home Automation

Firewalla Purple is a powerful network firewall but lacks deep integration with Home Assistant. Network events — device online/offline, new device detected, traffic spikes — should trigger home automation routines, but no native integration exists. The vendor project firewalla-local-ha provides this bridge.

The core challenge: building a Home Assistant custom component that communicates with Firewalla via its local REST API, and exposes device state, network events, and rule control as native Home Assistant primitives — sensors, binary sensors, events, and services — all without requiring cloud connectivity.

Industry Parallels: Home automation (Home Assistant) · Network management UI

HA Custom Component with Local API

The integration follows Home Assistant's custom component architecture: a Python package installed via HACS that registers sensors, binary sensors, events, and services through HA's standard registration API. Communication with Firewalla happens entirely over the local REST API (Encipher-protected), with no cloud dependency after initial pairing.

class FirewallaSensor(SensorEntity):
    """Home Assistant sensor for Firewalla health."""

    def update(self) -> None:
        resp = requests.get(
            f"{API_BASE}/v1/devices",
            headers={"Authorization": f"Bearer {self.api_key}"}
        )
        data = resp.json()
        self._attr_native_value = data["health"]["status"]
        self._attr_extra_state_attributes = {
            "cpu": data["health"]["cpu"],
            "mem": data["health"]["memory"],
            "uptime": data["health"]["uptime"],
        }
  1. Config Flow — Home Assistant setup wizard discovers Firewalla on the local network, authenticates via API key, and configures polling interval.
  2. Sensor Platform — Exposes device status (online/offline), network health metrics, traffic counters, and alarm states as HA sensors.
  3. Event Platform — Fires HA events on device changes (new device, device offline, traffic threshold breach) enabling automation triggers.
  4. Services — Exposes services to block/allow devices, enable/disable rules, and query network state from automations and scripts.

System Architecture

HOME ASSISTANT HA DASHBOARD Lovelace UI · Sensor Cards · Event Log AUTOMATIONS Device Triggers · Scene Control · Notifications CUSTOM COMPONENT — firewalla_local Config Flow · Sensor Platform · Event Platform · Services sensor.py event.py services.py config_flow.py INTEGRATION LAYER REST API (Encipher) FIREWALLA LOCAL REST API /device · /rule · /event · /alarm · /health FIREWALLA PURPLE Network Edge · Encipher Encrypted Channel device_online traffic_spike new_device alarm custom_components/ firewalla_local/

HA Event → REST → Firewalla → Response → Sensor Update

HOME AUTOMATION EVENT PIPELINE HA EVENT Automation Trigger Device State Change 1 REST HANDLER HTTP Request JSON Payload 2 FIREWALLA API Command Execute Network Action 3 RESPONSE Result Parsing Status Code 4 SENSOR HA Update 5 HA Sensor Update AUTOMATION EXAMPLE: Motion → Lights Motion Detected HA Binary Sensor Firewalla API Check Network Execute Rule Allow/Block State Update HA Dashboard N Step Flow Stage (floating)

HA Server + Firewalla + Devices Topology

PHYSICAL DEPLOYMENT TOPOLOGY HA SERVER Home Assistant REST API Automations Dashboards FIREWALLA BOX Firewalla Gold/Blue Local API Network Control mDNS + SSH REST API SMART DEVICES Lights · Switches Sensors · Locks SENSORS Temperature NETWORK Router · VLANs Zigbee MQTT LAN HA Server Firewalla REST IoT Protocol

Languages & Platforms

Language
Python 3
Platform
Home Assistant HACS
Protocol
Firewalla Local REST API Encipher

Key Decisions

ADR-001
HACS Custom Component over Add-on
Decision: HACS custom component

Custom components distribute through HACS with auto-update support, no container/OS changes needed on the Home Assistant host, and integrate directly into HA's entity registry and event bus. An add-on would require supervisor mode and container management overhead.

ADR-002
Local API over Cloud API
Decision: Firewalla local REST API

Local API eliminates cloud dependency for automations — lower latency, works during internet outages, and preserves privacy. Firewalla's Encipher protocol is reverse-engineerable from the mobile app's local communication channel, making local access feasible without official API documentation.

ADR-003
REST API over WebSocket — simpler client implementation, cacheable responses, works behind proxies
Decision: REST API for sensor polling

REST provides a straightforward request/response model that integrates natively with Home Assistant's sensor update cycle. HTTP responses are cacheable by HA's internal HTTP client, reducing redundant Firewalla API calls. REST works seamlessly behind reverse proxies (nginx, HA's own ingress) without special WebSocket passthrough configuration. While WebSocket would provide lower-latency event delivery, HA's polling interval (30s default) is sufficient for network monitoring use cases, and REST eliminates the connection management overhead (reconnection, heartbeat, backpressure) that a persistent WebSocket would introduce. The Encipher protocol is inherently request/response, so REST maps naturally to the underlying protocol without fabricating a push semantics.

How It Was Built

Session 1
Firewalla Local Web UI Research
748 messages · 2.38M tokens · $1.40

Deep research into Firewalla's architecture. Mapped the local API surface, understood Encipher protocol framing, identified available endpoints for device status, rules, alarms, and system health metrics.

Session 2
Explore Web UI Codebase
21 messages · 159K tokens

Analysis of the firewalla-local-web codebase. Extracted patterns for API interaction, authentication flow, and data model structures that would inform the HA component design.

Session 3
Explore Firewalla Local Codebase
19 messages · 175K tokens

Deep dive into the firewalla_local HA integration codebase. Understood the custom component structure, sensor/event/service registration patterns, and config flow implementation.

Session 4
Explore Dashboard Codebase
11 messages · 20K tokens

Analyzed the dashboard React components for data visualization patterns. Learned how Firewalla data is consumed and displayed to design the HA sensor model accordingly.

Session 5
Research OSS Firewalla Projects
7 messages · 69K tokens

Discovered firewalla-local-ha on GitHub. Evaluated existing community integrations, identified gaps, and determined the component architecture based on proven patterns from the OSS ecosystem.

Delivered Integration

Five dedicated sessions produced a complete HACS integration for Firewalla, bridging the gap between network-level events and home automation. The custom component enables device management, event monitoring, and rule control — all through Home Assistant's native entity and automation system.

5
Sessions
6
Key Decisions
2.80M
Tokens
1.5¢
Total Cost
HACS
Distribution via HACS
Devices
Device Management
Events
Event Monitoring
Rules
Rule Control

For Enterprises

Need a Custom Home Assistant Integration?

This project demonstrates bridging a closed-network device into the home automation ecosystem. The same approach applies to any IoT device with a local API.

Schedule a Strategy Consultation
or

For Founders

Building Network-Aware Home Automation?

The patterns here — local API integration, HACS component architecture, event-driven automation — are directly applicable to your smart home or IoT products.

Discuss Your Startup's AI Vision