Works with the AI Agents you already use

    Home Assistant Local LAN Protocol Bridge Builder

    by Sam3gp8

    1

    Design and debug resilient local LAN custom integrations and socket bridges for Home Assistant — defensive frame validation, jittered backoff reconnects, clean teardown, and zero cloud lock-in.

    $6.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    What it does

    • Designs local TCP, UDP, or MQTT bridges to bypass vendor cloud servers
    • Adds safety checks to prevent crashes from messy or incomplete device data
    • Fixes infinite retry loops that clutter logs or heat up device hardware
    • Ensures connections close cleanly when your home system shuts down
    • Creates specific plans for handling unstable Wi-Fi connections

    Who it's for

    Homeowners with smart devices that need a cloud app to work

    Take back control by moving your device control from the vendor's server to your local network.

    Try asking: “Help me write a local bridge for my smart light that currently requires a cloud login.”

    Home Assistant users with flaky custom integrations

    Fix crashes caused by bad network connections or weird data packets from your devices.

    Try asking: “My custom TCP integration for my pool heater keeps crashing when the Wi-Fi blips. Fix the reconnect logic.”

    Privacy-focused tech enthusiasts

    Remove the need for outside internet connections for your internal home gadgets.

    Try asking: “Design a local MQTT bridge for my smart plugs so I can block them from the internet.”

    Home Assistant Local LAN Protocol Bridge Builder

    Home Assistant Local LAN Protocol Bridge Builder

    Example session with this skill installed

    I have a smart heater that uses a local TCP port but it crashes Home Assistant whenever the Wi-Fi signal drops. Can you help me fix the reconnect logic?

    • Read your context and instructions
    • Compiled the home assistant local

    Local TCP Bridge Failure-Mode Audit (heater_client.py)

    SeverityFailure ModeRoot CauseRemediation
    CRITICALUnhandled IncompleteReadError / struct.error crashes the listener loop on Wi-Fi dropParses raw reader.read(1024) chunks without checking frame header or byte lengthValidate fixed header and bounded payload length before readexactly()
    CRITICALTight while True reconnect loop floods HA logs and wedges the heater's Wi-Fi stackImmediate retry with zero backoff or jitter after ConnectionResetErrorEnforce bounded exponential backoff (2s → 60s) with ±20% jitter and cooldown logging
    HIGHReloading the integration or restarting HA leaves ghost sockets openBackground task not cancelled or awaited in async_unload_entryBind task to entry.async_create_background_task() and close StreamWriter in finally:
    MEDIUMHalf-open Wi-Fi drop hangs the reader indefinitely with no unavailable stateMissing read timeout / heartbeat checkWrap reads in asyncio.wait_for(..., timeout=30) and mark entities unavailable on disconnect

    Hardened Async TCP Transport (transport.py)

    import asyncio
    import logging
    import random
    from collections.abc import Callable
    
    _LOGGER = logging.getLogger(__name__)
    
    FRAME_MAGIC = b"\xAA\x55"
    MAX_PAYLOAD_BYTES = 256
    
    class HeaterLocalBridge:
        def __init__(self, host: str, port: int, on_frame: Callable[[bytes], None], on_state: Callable[[bool], None]) -> None:
            self._host = host
            self._port = port
            self._on_frame = on_frame
            self._on_state = on_state
            self._stop_event = asyncio.Event()
    
        async def run_forever(self) -> None:
            backoff = 2.0
            while not self._stop_event.is_set():
                writer: asyncio.StreamWriter | None = None
                try:
                    reader, writer = await asyncio.wait_for(
                        asyncio.open_connection(self._host, self._port), timeout=10.0
                    )
                    backoff = 2.0  # Reset backoff on healthy connect
                    self._on_state(True)
                    await self._read_loop(reader)
                except asyncio.CancelledError:
                    raise
                except (OSError, asyncio.TimeoutError, asyncio.IncompleteReadError) as err:
                    self._on_state(False)
                    delay = min(backoff, 60.0) * random.uniform(0.8, 1.2)
                    _LOGGER.warning("Heater %s disconnected (%s); retrying in %.1fs", self._host, err, delay)
                    await asyncio.sleep(delay)
                    backoff = min(backoff * 2, 60.0)
                finally:
                    if writer is not None:
                        writer.close()
                        try:
                            await asyncio.wait_for(writer.wait_closed(), timeout=3.0)
                        except (OSError, asyncio.TimeoutError):
                            pass
    
        async def _read_loop(self, reader: asyncio.StreamReader) -> None:
            while not self._stop_event.is_set():
                header = await asyncio.wait_for(reader.readexactly(4), timeout=30.0)
                if header[:2] != FRAME_MAGIC:
                    _LOGGER.debug("Dropping malformed frame header: %s", header.hex())
                    continue
                length = int.from_bytes(header[2:4], "big")
                if length == 0 or length > MAX_PAYLOAD_BYTES:
                    _LOGGER.debug("Dropping out-of-bounds payload length: %d", length)
                    continue
                payload = await asyncio.wait_for(reader.readexactly(length), timeout=10.0)
                self._on_frame(payload)
    
        def stop(self) -> None:
            self._stop_event.set()
    

    Home Assistant Lifecycle Checklist

    • Launch bridge.run_forever() via entry.async_create_background_task(hass, ..., "heater_tcp_bridge")
    • Register bridge.stop() on EVENT_HOMEASSISTANT_STOP and cancel/await the task inside async_unload_entry()
    • Keep entity updates decoupled inside on_frame / on_state callbacks so socket hiccups mark entities unavailable instead of raising
    • Simulate a mid-frame Wi-Fi drop (nc disconnect) to verify clean recovery with zero orphaned sockets

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Turns your agent into a builder and debugger of local-network protocol bridges for Home Assistant devices that lack clean official APIs.

    • Validate framing & lengths before parsing — defensive buffer/header/boundary checks so malformed or partial packets never raise unhandled exceptions.
    • Bounded exponential backoff — jittered reconnects with circuit/cooldown visibility instead of tight loops that flood logs or drain device radios.
    • Separate transport from entity state — isolate connection/framing logic; cancel sockets and tasks cleanly on unload/shutdown.
    • No cloud lock-in — local TCP/UDP/HTTP/MQTT, no vendor servers.

    Instruction-only design/debug guidance; adapt to your own protocols, ports, and entities.

    This skill provides design and debugging guidance only. It cannot make network calls or run scripts directly on your hardware.

    Built for Claude Code, Cursor, ChatGPT, and MCP-compatible coding agents targeting Home Assistant 2024.10+ custom integrations and local LAN bridges (TCP, UDP, HTTP, and MQTT). Engineering patterns enforced: • Defensive frame validation — Explicit header, payload-length, and buffer-boundary checks on asyncio.StreamReader before parsing so partial or malformed packets never raise unhandled exceptions. • Bounded jittered exponential backoff — Configurable retry caps, random jitter, and circuit/cooldown visibility instead of tight reconnect loops that flood logs or lock up device Wi-Fi radios. • Transport/entity separation — Decouples raw socket I/O and framing from Home Assistant entity state updates. • Clean lifecycle teardown — Registers background listeners via entry.async_create_background_task, cancels cleanly on async_unload_entry and EVENT_HOMEASSISTANT_STOP, and closes sockets without orphan tasks.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 2 days ago

    Software
    Home Assistant 2024.10+

    Permissions

    No special permissions declared or detected

    Listed2 days ago
    Updatedtoday

    What's inside

    Frequently Asked Questions

    Design and debug resilient local LAN custom integrations and socket bridges for Home Assistant — defensive frame validation, jittered backoff reconnects, clean teardown, and zero cloud lock-in.

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use Home Assistant Local LAN Protocol Bridge Builder on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    New in Workflow Automation

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Workflow Automation.