Quick Answer
Shelly devices work in HA two ways: the native Shelly integration (local push, zero config) or MQTT (push-based, and the same data is available to Node-RED and other tools). For MQTT, 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 1PM Gen4 relay (Gen3, Plus and older Gen1 devices such as the Shelly 1, 1PM and Plug S work too)
- 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 and gets pushed updates from them: CoIoT for Gen1, RPC for Gen2 and later. It's easy to set up (zero config) and supports every Shelly generation (Gen1, Gen2 Plus/Pro, Gen3 and Gen4), with a few limitations:
- Gen1 devices need CoIoT set up correctly (HA recommends pointing the CoIoT peer at your HA IP), or updates can be missed on networks with multicast issues
- Gen1 and Gen2+ devices work differently, in the integration and over MQTT
- The data stays inside HA; other systems can't subscribe to it
MQTT mode is also push-based: the Shelly device publishes state changes the instant they happen, with <100ms round-trip for switches and energy readings. The data lands on your broker, so any MQTT client can use it.
Recommendation
Use the native Shelly integration for simple setups with a few devices. Switch to MQTT if you have many Shelly devices, have trouble with Gen1 CoIoT updates, or want to use the same MQTT data in Node-RED or other systems.
Setting Up MQTT on the Shelly Device
For older 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 and Gen4 devices (Plus, Pro, Mini, Gen3, Gen4):
- Open the Shelly device web UI
- Go to Settings → MQTT
- Enable MQTT and configure broker IP, port, and credentials
- Set the topic prefix (the default is the device ID, e.g.
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 them 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, Gen3 and Gen4 use 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.