The Local Control Standard: Shelly in-wall relays provide the ultimate architectural escape hatch for pre-1960s switch boxes. By decoupling the physical toggle switch from mains switching and routing state changes strictly over local MQTT with mJS embedded scripting, you maintain authentic vintage aesthetics with sub-10ms response times and zero cloud dependencies.

Interactive Engineering Tool

Calculate Your Smart Retrofit Bill of Materials

Planning a legacy electrical conversion? Input your room count, wiring conditions (K&T, Romex, MWBC), and switch preferences to generate an itemized cost estimate and NEC hardware checklist.

Shelly 1L & Dimmer Gen 3 — The Wi-Fi/MQTT No-Neutral Workhorses

The Shelly 1L and Shelly Dimmer Gen 3 occupy the Wi-Fi/MQTT corner of the no-neutral smart-switch ecosystem. Where Lutron chooses proprietary Clear Connect (433 MHz RF), Inovelli and Aeotec ride Z-Wave, and SONOFF stakes Zigbee — Shelly goes all-in on Wi-Fi with MQTT as the primary transport, BLE for provisioning, and a Matter bridge as the export path. This makes them among the most flexible no-neutral devices available, at the cost of introducing Wi-Fi IoT into the home RF landscape.

Key Specifications

Model Neutral? Min Load (no neutral) Protocols Notes
Shelly 1L No 3 W Wi-Fi, MQTT, CoAP, HTTP, BLE Compact 1-channel relay; designed explicitly for no-neutral switch loops; $14–18
Shelly Dimmer Gen 3 No 20 W (no bypass) Wi-Fi, BLE, Matter (bridge) Trailing-edge dimming; 150 W LED max; bypass required under 20 W; Gen 3 adds Matter bridge path over existing Wi-Fi stack

Shelly 1L Wiring (No-Neutral Switch Loop)

TEXT

Live ───────────────┬──── L (Shelly 1L)
                    │
Load ───────────────┼──── O (Shelly output to light)
                    │
            Bypass in parallel with load at fixture (mandatory for any LED load)
                    │
Existing switch ────┴──── SW (Shelly switch input) [low voltage signal only]

Critical rules:

  • Bypass mandatory for LED loads. A 22µF–47µF non-polarized capacitor wired in parallel with the light fixture load terminals. Without it, single LED bulbs will flicker, glow when “off,” or the switch may appear stuck on.
  • The existing wall switch becomes a low-voltage signal device only — it never carries mains voltage.
  • Ground every device: metal box → ground to box; plastic box → ground to device’s ground terminal.

Shelly Dimmer Gen 3 Wiring (No-Neutral, Trailing-Edge Dimming)

TEXT

Live ───────────────┬──── L (Shelly Dimmer Gen 3 input)
                    │
Load ───────────────┼──── LOAD (Shelly Dimmer output to light fixture)
                    │
            Bypass capacitor (22µF–47µF, non-polarized) in parallel with load at fixture (mandatory for LED < 20 W)
                    │
Neutral (if available at fixture) ─────────────────────┴──── N (Shelly Dimmer neutral input)
                    │
Existing switch ────┴──── SW (Shelly Dimmer switch input) [low voltage signal only]

Critical rules:

  • Bypass mandatory for any LED load under 20 W. The Dimmer Gen 3’s power supply leaks current through the load to maintain state; with a single LED bulb, this leakage is insufficient without a bypass capacitor.
  • Configure the switch’s Load Type parameter (in the Shelly firmware UI) to match the connected load: LED (type 1) or incandescent/halogen (type 0).
  • The existing wall switch becomes a low-voltage signal device only.

Scripting — Shelly HTTP API & MQTT Integration

The Shelly 1L and Dimmer Gen 3 both expose a native HTTP API and an MQTT bridge. The HTTP API is the primary configuration path; MQTT is the data path for Home Assistant and custom integrations.

HTTP API Endpoints (base: http://<shelly-ip>)

Endpoint Description
/rpc JSON-RPC 2.0 for all operations
/status Current device state (output, input, Wi-Fi, metrics)
/led Control the status LED
/meter Power metrics (if supported)
/time NTP time sync

MQTT Topics (default: cmnd/<prefix>/ and tele/<prefix>/)

Topic Direction Payload
cmnd/<prefix>/SWITCH Outbound ON, OFF, TOGGLE
cmnd/<prefix>/BRIGHTNESS Outbound (Dimmer) 0–100 %
tele/<prefix>/STATE Inbound JSON: {"Switch":1,"Time":"...","Uptime":"..."}
tele/<prefix>/SENSOR Inbound (Dimmer) JSON: {"Brightness":42,"Input":"..."}
tele/<prefix>/PLUGSTATE Inbound JSON: {"Switch":1,"Source":"..."}

Minimal Python Scripting Example

PYTHON

#!/usr/bin/env python3
"""Shelly 1L MQTT bridge script: subscribe to switch state changes, forward to Home Assistant."""

import asyncio import json import os from typing import Dict

import paho.mqtt.client as mqtt import requests

SHELLY_IP = os.getenv("SHELLY_IP", "192.168.1.50") SHELLY_PREFIX = os.getenv("SHELLY_PREFIX", "shelly1l") HA_MQTT_BROKER = os.getenv("HA_MQTT_BROKER", "192.168.1.100") HA_MQTT_PORT = int(os.getenv("HA_MQTT_PORT", "1883")) HA_MQTT_USER = os.getenv("HA_MQTT_USER", "homeassistant") HA_MQTT_PASSWORD = os.getenv("HA_MQTT_PASSWORD", "secret")

def get_shelly_status(): """Fetch current Shelly status via HTTP API.""" try: r = requests.get(f"http://{SHELLY_IP}/status", timeout=5) r.raise_for_status() return r.json() except Exception as e: print(f"Shelly status fetch error: {e}") return None

def publish_to_ha(client, topic, payload): """Publish payload to Home Assistant MQTT bridge.""" client.publish(topic, json.dumps(payload), retain=True)

async def shelly_mqtt_bridge(): """Bridge Shelly HTTP status to Home Assistant MQTT."""

# Connect to HA MQTT
client = mqtt.Client()
client.username_pw_set(HA_MQTT_USER, HA_MQTT_PASSWORD)
client.connect(HA_MQTT_BROKER, HA_MQTT_PORT, 60)
client.loop_start()

# Subscribe to Shelly SWITCH command topic
switch_topic = f"cmnd/{SHELLY_PREFIX}/SWITCH"
client.subscribe(switch_topic)

try:
    while True:
        # Poll Shelly status every 5 seconds
        status = get_shelly_status()
        if status:
            # Publish STATE to HA tele topic
            state_topic = f"tele/{SHELLY_PREFIX}/STATE"
            publish_to_ha(client, state_topic, status)

        # Check for pending SWITCH commands from HA
        # (Home Assistant publishes to cmnd topics when entities are triggered)
        await asyncio.sleep(5)

except KeyboardInterrupt:
    client.loop_stop()
    client.disconnect()

if name == "main":
asyncio.run(shelly_mqtt_bridge())

KVS (Key-Value Store) Integration

For local caching of Shelly device state without relying on Home Assistant’s internal database, a simple KV store can be implemented via JSON files or a lightweight embedded database.

Shelly state snapshot (JSON):

JSON

{
  "switch": 1,
  "brightness": 100,
  "input": "switch",
  "timestamp": "2026-11-02T14:00:00Z",
  "rssi": -52,
  "uptime": 34210
}

KVS shell script (bash):

BASH

#!/bin/bash
# Simple KV store for Shelly device state
KVS_DIR="$HOME/.shelly_kvs"
mkdir -p "$KVS_DIR"

Write Shelly state to KV store

write_kvs() { local prefix="$1" local state_file="$KVS_DIR/${prefix}_state.json" echo "$2" > "$state_file" }

Read Shelly state from KV store

read_kvs() { local prefix="$1" local state_file="$KVS_DIR/${prefix}_state.json" if [[ -f "$state_file" ]]; then cat "$state_file" else echo "{}" fi }

Example: write current state

CURRENT_STATE='{"switch":1,"brightness":85}' write_kvs "shelly1l" "$CURRENT_STATE"

Example: read state

echo "Current shelly1l state: $(read_kvs "shelly1l")"

BLE Gateway — Provisioning and Local Discovery

Shelly devices use BLE (Bluetooth Low Energy) for initial provisioning and local network discovery. The BLE advertisement package contains:

  • Device model (Shelly 1L, Dimmer Gen 3)
  • Firmware version
  • MAC address
  • SSID hint (if

Related Architecture Guides

// LOCAL-FIRST HOME AUTOMATION & PROTOCOLS

// The Local Mesh

Bi-weekly architectures for local-first smart homes, Home Assistant YAML patterns, Matter/Thread co-existence, and private NVR pipelines.