Home > Blog > How to Connect Devices to Home Assistant Using MQTT

How to Connect Devices to Home Assistant Using MQTT

How to Connect Devices to Home Assistant Using MQTT
Sep07, 2026

How to Connect Devices to Home Assistant Using MQTT

This guide uses the PowerUC MCW02-E WiFi Three-Phase Current Monitor to explain how to create a dedicated MQTT user, configure the MCW02-E, add MQTT integration to Home Assistant, and confirm automatic device discovery.

1. Create an MQTT user in Home Assistant

Create a separate MQTT account for the MCW02-E. Using a dedicated account makes access easier to manage and avoids using a Home Assistant administrator account on the sensor.

  1. Open Settings in Home Assistant.
  2. Go to PeopleUsers, then choose Add User.
  3. Enter a name such as esp32mqtt.
  4. Enable Allow login.
  5. Set the username and password. Use the same credentials later in the MCW02-E MQTT page.
  6. Leave Administrator disabled unless there is a specific reason to enable it.
  7. Click Save.
Home Assistant screen for creating a dedicated MQTT user named esp32mqtt
Figure 1. Create a dedicated MQTT user, for example esp32mqtt.

2. Configure the MQTT server on the MCW02-E

Open the MCW02-E Web interface by entering its IP address in a browser. In the MQTT section, enter the address of the MQTT broker, not the Home Assistant internal service name.

FieldExampleWhat to enter
MQTT Server192.168.1.99The LAN IP address of the MQTT broker or Home Assistant host
MQTT Base-topicemon/emonespA unique topic prefix for this device
MQTT Feed-name prefixblankLeave blank for the simplest topic structure
JSON formatuncheckedRecommended when using Home Assistant Discovery
Usernameesp32mqttThe user created in Step 1
Passwordyour MQTT passwordThe matching MQTT password
  1. Enter the MQTT server address and port 1883.
  2. Enter a unique Base-topic, such as PowerUC/MCW02-E.
  3. Enter the MQTT username and password created in Step 1.
  4. Click Save.
MCW02-E web interface showing MQTT server, base-topic, username and password settings
Figure 2. MCW02-E MQTT configuration page.

3. Add the MQTT integration in Home Assistant

Home Assistant must be connected to the same MQTT broker used by the MCW02-E. If the MQTT integration is already configured, verify its broker address, port, username, and password before continuing.

  1. Open SettingsDevices & services.
  2. Click Add Integration.
  3. Search for MQTT.
  4. Select MQTT from the integration list.
  5. Enter the MQTT broker host, port 1883, and the MQTT credentials.
  6. Submit the form and wait for the integration to connect.
Home Assistant Integrations dialog with MQTT selected
Figure 3. Search for MQTT in Home Assistant Integrations.

For the Home Assistant Mosquitto add-on, the broker host shown inside Home Assistant may be core-mosquitto. This is different from the address normally used by an external ESP32 device. The MCW02-E should use the reachable LAN IP address of the broker host.

4. Let Home Assistant discover the MCW02-E

After the MCW02-E connects to MQTT, it publishes Home Assistant MQTT Discovery configuration messages. Home Assistant can then create the device and its entities automatically.

  1. Return to SettingsDevices & services.
  2. Wait for the discovered MQTT device notification, or open the MQTT integration.
  3. Select the discovered MCW02-E device.
  4. Set its area if required, then select Skip and finish or Finish.
  5. Open the device page and confirm that the manufacturer is PowerUC and the model is MCW02-E.
Home Assistant Name and assign dialog for the discovered PowerUC MCW02-E device
Figure 4. Name and assign the discovered MCW02-E device.
Home Assistant device page showing the PowerUC MCW02-E and its MQTT entities
Figure 5. The MCW02-E device and MQTT entities in Home Assistant.
Entity groupExamplesUnit
VoltageVoltage L1, Voltage L2, Voltage L3V
CurrentCurrent L1, Current L2, Current L3, Total CurrentA
Estimated powerPower L1, Power L2, Power L3, Total PowerW
OtherFrequency, Chip Temperature, WiFi RSSI, Free RAMHz, °C, dBm, B

Verification and troubleshooting

  • MCW02-E Web page: MQTT status should show Connected: Yes.
  • Home Assistant: the device should appear under the MQTT integration.
  • Entities: voltage, current, estimated power, frequency, temperature, RSSI, and Free RAM should report values.
  • If no device appears, check the broker IP, port 1883, MQTT credentials, WiFi network, and whether MQTT Discovery is enabled.
  • Use a unique Base-topic for every MCW02-E to prevent devices from overwriting each other’s state.

Example topics:

poweruc/mcw02e_01/status
poweruc/mcw02e_01/V1
poweruc/mcw02e_01/C1
poweruc/mcw02e_01/Total_PW

Once the device is discovered, add the entities to a Home Assistant dashboard to monitor the three current channels and estimated power in real time.

Inquiry Form