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
What You Need
- Shelly relay or smart plug (Shelly 1, 1PM, Plus 1, Plus 1PM, Plug S)
- Home Assistant with Mosquitto broker add-on running
- Shelly device configured on your Wi-Fi network
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:
- Polling-based — state updates may lag 10–30 seconds
- Not as reliable on networks with CoAP broadcast issues
- Shelly Gen1 and Gen2 devices work differently in the integration
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):
- Open the Shelly device web UI (navigate to its IP in your browser, e.g.,
http://192.168.1.105) - Go to Settings → MQTT
- Enable MQTT and enter:
- Server:
192.168.1.100(your HA IP) - Port:
1883 - Username: your HA username
- Password: your HA password
- Server:
- Click Save — the device reconnects and starts publishing to MQTT
For Shelly Gen2/Gen3 devices (Plus, Pro, Mini series):
- Open the Shelly device web UI
- Go to Settings → MQTT
- Enable MQTT and configure broker IP, port, and credentials
- Set the topic prefix (default:
shellyplus1pm-DEVICEID) - 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):
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
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:
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
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
- Shelly connects to MQTT but no state updates in HA: Check the topic prefix in Shelly web UI matches your HA YAML config. Subscribe to
#in mosquitto_sub to see all topics the Shelly is publishing. - Switch entity always shows "unavailable": Check the
availability_topic— the Shelly publishes "true" (string) not true (boolean). Adjust yourpayload_availableaccordingly. - Commands sent from HA don't work: Verify the
command_topicis correct and the payload is "on"/"off" (lowercase). Gen1 Shelly devices are case-sensitive. - Gen2 device not publishing to expected topics: Gen2 uses a different topic structure. Use the Shelly web UI's MQTT debug page to see what it's actually publishing.
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.