Summary
This article provides a step-by-step guide on how to add and configure an MQTT device within Home Assistant running on a Robustel EG5120 Industrial Edge Computing Gateway.
We'll walk through the initial connection, setting up the MQTT integration, and configuring a smart plug sensor using YAML.
The final goal is to display real-time data from the device directly on your dashboard.
Introduction
So, you've got the powerful Robustel EG5120 edge gateway, and you're running Home Assistant on it. Smart move. You've already bypassed the limitations of a typical Raspberry Pi, opting for an industrial-grade platform with a stable Debian OS that's built for the long haul. But let's be clear: the real magic happens when you start connecting devices. In my experience, the most flexible and powerful way to do that in the IoT world is with MQTT.
What's the plan? We're going to bridge the gap between your industrial hardware and a truly smart, local automation hub. Forget relying on the cloud for every little action. We're going to set up an MQTT Home Assistant integration right on your EG5120. I'll guide you through connecting a typical MQTT-enabled smart plug, from initial setup to seeing its data pop up live on your dashboard. It's easier than you think, isn't it?
A Practical Guide to MQTT Home Assistant on the EG5120
Let's dive into the hands-on process. For this walkthrough, I'm using a common scenario: integrating an MQTT smart plug to monitor the power status of a piece of equipment. This is incredibly useful in an industrial setting for tracking machine uptime or energy consumption.
Prerequisites: What You'll Need
Before we roll up our sleeves and dive in, let's make sure you have everything you need. Here’s a quick checklist:
-
Hardware:
- A Robustel EG5120 Industrial Edge Computing Gateway.
- The appropriate power supply for the gateway.
- An Ethernet cable for the initial setup.
- A computer with a web browser.
- An MQTT-enabled device you want to integrate (we're using a smart plug as an example).
-
Software & Setup:
- Your EG5120 must have Home Assistant and HACS installed. For detailed steps, you can refer to " How to Install Home Assistant on an Industrial IoT Gateway (EG5120)".
- You need an MQTT Broker, like Mosquitto, already installed and running on the EG5120. For detailed steps, you can refer to " How to install an MQTT Broker for Home Assistant on the EG5120".
- For easier editing, it's recommended to have a file editor add-on (like the 'File editor' from HACS) installed in Home Assistant. For detailed steps, you can refer to " How to install an file editor for Home Assistant on the EG5120".
Step-by-Step: Adding Your Home Assistant MQTT Device
Step 1: Getting Connected to the Gateway
First things first, we need to access the Home Assistant interface running on the EG5120. It's a straightforward process.
- Power Up: Connect the power supply to your EG5120 gateway and give it a solid minute to fully boot up. The RUN LED should be blinking.
- Physical Connection: Use an Ethernet cable to connect the gateway's LAN port directly to your computer.
- Network Configuration: Set your computer's IPv4 network card settings to obtain an IP address automatically (via DHCP). Your EG5120 will handle the rest.
-
Access Home Assistant: Open your web browser and navigate to
http://192.168.0.1:8123. This is the default address. The real 'aha!' moment for many engineers is realizing that if the device has been used before, the gateway IP might be different. You can easily find the correct address by checking the "Default Gateway" IP in your computer's network details after connecting.

Step 2: Setting Up the MQTT Integration
With Home Assistant up and running, it's time to teach it how to speak MQTT. This involves adding the core integration that listens for MQTT messages.
- Navigate to Integrations: Once you've logged into your Home Assistant account (create one if it's your first time), go to Settings > Devices & services.
-
Add MQTT: You'll land on the Integrations page. Click the ADD INTEGRATION button in the bottom right corner. In the search box that appears, type
MQTTand click on the result. -
Configure the Home Assistant MQTT Client: Here's the crucial part. The "Broker" is the central message hub. Since we are running everything locally on the EG5120, the IP address you need to enter is
127.0.0.1. This is a universal IP address that simply means "this device itself" (also known as localhost). Leave the port as1883and submit. You should see a success message!

Step 3 - Configuring Your MQTT Device in YAML
v3/pub/HA/WPS2/C66FB8. The data it sends is in a standard JSON format, which looks something like this:
We need to tell our MQTT Home Assistant setup how to read this. We'll do this by editing the main configuration file.
-
Open the File Editor: I recommend using the 'File editor' add-on from the HACS (Home Assistant Community Store) for this. Navigate to it and open the
configuration.yamlfile. - Add the MQTT Sensor Configuration: Scroll to the bottom of the file and add the following code block. This tells Home Assistant to listen on the specified topic and create sensors for each piece of data in the JSON payload.


- Save and Restart: Save the file, then go to Developer Tools > YAML and click RESTART. This will apply your changes. For more advanced configuration options, the official Home Assistant MQTT documentation (external link) is an excellent resource. You can also explore our other guides on industrial IoT edge gateways.

Step 4 - Viewing Your New Device
Once Home Assistant restarts, the magic is complete. Navigate back to your main Overview dashboard. Home Assistant is usually smart enough to automatically add your new sensors as cards on the dashboard. You'll see the real-time voltage, current, power, and switch status of your smart plug. You've successfully integrated a physical device into your local smart hub using MQTT Home Assistant. Now, you can use this data to build powerful automations, track energy usage, or create alerts—all processed securely and locally on your Robustel EG5120.

FAQ
Q1: What are the benefits of processing MQTT data locally on the EG5120 instead of sending it to a cloud service?
A1: Processing data at the edge on the EG5120 provides four key advantages over cloud-only solutions:
- Lower Latency: By eliminating the round-trip to a cloud server, automations and decisions happen almost instantly, which is critical for time-sensitive industrial control tasks.
- Enhanced Reliability: Your automation system continues to operate perfectly even if the external internet connection fails, ensuring business continuity.
- Reduced Data Costs: You can process raw data locally and only send essential summaries or alerts to the cloud, dramatically cutting down on cellular data consumption.
- Improved Security & Privacy: Keeping sensitive operational data on your local network significantly reduces the attack surface and helps you comply with data sovereignty regulations.
Q2: Can I run other services besides Home Assistant and an MQTT broker on the EG5120?
A2: Absolutely. This is one of the EG5120's biggest strengths. It runs RobustOS Pro, which is based on Debian 11, giving you a full, open Linux environment. It also has native support for Docker, which means you can easily deploy other containerized applications right alongside Home Assistant. Many users run software like InfluxDB for data history, Grafana for advanced dashboards, and custom Python or Node.js scripts, turning the gateway into a powerful, all-in-one edge server.
Q3: My MQTT device isn't appearing in Home Assistant. What are some common troubleshooting steps?
A3: This is a common hurdle, but it's usually easy to fix. Here's a quick checklist I run through:Check YAML Syntax: A single misplaced space can break the configuration. Go to Developer Tools > YAML in your Home Assistant UI and click the "CHECK CONFIGURATION" button. It will tell you if there are any errors.Verify the Broker: Make sure your MQTT broker is actually receiving the messages. A great tool for this is MQTT Explorer. You can use it to connect to your broker and see all the topics and messages in real-time. This confirms the problem is in Home Assistant, not the device itself.Confirm Topic and Payload: Carefully double-check that the state_topic in your configuration.yaml is exactly the same as the topic the device is publishing to. Also, check that the JSON keys in your value_template (e.g., value_json.voltage) perfectly match the keys in the message payload.Restart Home Assistant: Remember, any changes made to configuration.yaml require a full restart of Home Assistant to be applied. You can do this from the YAML page in Developer Tools.


Comments
Leave a comment