Quick Answer

Shelly devices work in HA two ways: the native Shelly integration (polling) or MQTT (push-based, faster). For the best local control experience, configure your Shelly device to publish state to your Mosquitto broker, then set up MQTT sensors and switches in HA. Commands and state updates happen in under 100ms.

Table of Contents

  1. Native Integration vs MQTT
  2. Setting Up MQTT on the Shelly Device
  3. HA YAML Config (Real)
  4. Push Update Example
  5. Energy Monitoring Automation
  6. Troubleshooting
  7. FAQ

What You Need

Native Shelly Integration vs MQTT

HA's built-in Shelly integration auto-discovers devices via CoAP/HTTP and polls their state. It's easy to set up (zero config) but has some limitations:

MQTT mode offers push-based updates — the Shelly device actively publishes state changes the instant they happen. This gives you <100ms round-trip for switches and energy readings.

Recommendation

Use the native Shelly integration for simple setups with a few devices. Switch to MQTT if you have many Shelly devices, need instant state updates, or want to use the same MQTT data in Node-RED or other systems.

Setting Up MQTT on the Shelly Device

For Shelly Gen1 devices (Shelly 1, 2.5, Plug S):

  1. Open the Shelly device web UI (navigate to its IP in your browser, e.g., http://192.168.1.105)
  2. Go to Settings → MQTT
  3. Enable MQTT and enter:
    • Server: 192.168.1.100 (your HA IP)
    • Port: 1883
    • Username: your HA username
    • Password: your HA password
  4. Click Save — the device reconnects and starts publishing to MQTT

For Shelly Gen2/Gen3 devices (Plus, Pro, Mini series):

  1. Open the Shelly device web UI
  2. Go to Settings → MQTT
  3. Enable MQTT and configure broker IP, port, and credentials
  4. Set the topic prefix (default: shellyplus1pm-DEVICEID)
  5. Save and reboot

HA YAML Config for Shelly via MQTT

Add these to your configuration.yaml. Replace shelly1pm-A1B2C3 with your device's MQTT topic prefix (visible in the Shelly web UI under MQTT settings):

configuration.yaml — Shelly 1PM via MQTT
mqtt:
  switch:
    - name: "Kitchen Light Relay"
      unique_id: kitchen_light_shelly
      state_topic: "shellies/shelly1pm-A1B2C3/relay/0"
      command_topic: "shellies/shelly1pm-A1B2C3/relay/0/command"
      payload_on: "on"
      payload_off: "off"
      state_on: "on"
      state_off: "off"
      availability_topic: "shellies/shelly1pm-A1B2C3/online"
      payload_available: "true"
      payload_not_available: "false"
      optimistic: false

  sensor:
    - name: "Kitchen Power"
      unique_id: kitchen_power_shelly
      state_topic: "shellies/shelly1pm-A1B2C3/relay/0/power"
      unit_of_measurement: "W"
      device_class: power
      state_class: measurement

    - name: "Kitchen Energy"
      unique_id: kitchen_energy_shelly
      state_topic: "shellies/shelly1pm-A1B2C3/relay/0/energy"
      unit_of_measurement: "Wmin"
      device_class: energy
Gen2 devices use different topic structure: Shelly Gen2 (Plus/Pro series) uses shellyplus1pm-DEVICEID/status/switch:0 with JSON payloads. The native HA Shelly integration handles Gen2 automatically; manual MQTT config requires parsing JSON with value_templates.

Push Update Example

When you flip the physical switch on a Shelly 1PM, it immediately publishes:

MQTT topic published by Shelly on state change
Topic:   shellies/shelly1pm-A1B2C3/relay/0
Payload: on

Topic:   shellies/shelly1pm-A1B2C3/relay/0/power
Payload: 47.3

Topic:   shellies/shelly1pm-A1B2C3/relay/0/energy
Payload: 15423

HA receives these within milliseconds and updates the entity state — no polling delay.

Energy Monitoring Automation

automations.yaml — Notify when washing machine finishes
automation:
  - alias: "Washing machine finished"
    description: "Detect when washing machine drops from high to low power"
    trigger:
      - platform: numeric_state
        entity_id: sensor.washing_machine_power
        below: 5
        for:
          minutes: 3
    condition:
      - condition: numeric_state
        entity_id: sensor.washing_machine_power
        above: 0
        value_template: >
          {{ states('sensor.washing_machine_power') | float > 0 }}
    action:
      - service: notify.mobile_app_your_phone
        data:
          title: "Washing Done! 🧺"
          message: "The washing machine has finished its cycle."

Troubleshooting

FAQ

Do Shelly devices work without the cloud?

Yes — Shelly devices have always supported local operation. They have a local REST API and MQTT support. The Shelly Cloud is optional and can be disabled in the device settings.

Should I use the native Shelly integration or configure MQTT manually?

Start with the native integration — it works well and requires zero config. Switch to manual MQTT only if you need real-time push updates or want to share Shelly data with non-HA systems.

Can Shelly devices act as Zigbee repeaters?

No — Shelly devices are Wi-Fi only. They don't participate in the Zigbee mesh. For Zigbee mesh extension, use Zigbee-based smart plugs or bulbs as repeaters.

SmartWired uses affiliate links. If you buy through our links, we may earn a commission at no extra cost to you. See our Affiliate Disclosure.