Home / Knowledge Base / Integration Hub / Home Assistant
Smart Home & OT Integration

Home Assistant: Modbus RTU to MQTT Auto-Discovery

Decouple physical RS485 wiring from your Home Assistant server. Push clean, parsed data from industrial inverters and meters directly into HA using native MQTT auto-discovery JSON payloads.

1. The Limitations of Direct USB-RS485 Dongles

The standard way of integrating industrial hardware (e.g. Growatt inverters or Eastron energy meters) into Home Assistant is to plug a USB to RS485 adapter into the machine running HA (e.g. Raspberry Pi or NUC), and defining the modbus: platform in the configuration.yaml file.

This approach introduces two critical points of failure:

  • Physical Distance & Ground Loops: Industrial equipment is usually not located near the HA server. Long RS485 cables throughout a residential or light commercial building will cause voltage drops, ground loops, and CRC errors.
  • OS-Level Disconnects: In Linux environments it is common to reset USB ports experiencing electromagnetic interference (EMI), causing the /dev/ttyUSB0 path to drop and all data acquisition to stop indefinitely until reboot.

2. The MQTT Edge-Decoupled Solution

Isolating the physical OT network from the IT server resolves these instabilities. By deploying an Edge Gateway locally at the inverter or meter panel, the vulnerable RS485 cable run is kept under 1 meter.

🔌 Recommended Physical Topology

Device Panel Inverter (A+)
Inverter (B-)
— Max 1 Meter –>

— Max 1 Meter –>
Edge Gateway Terminal T+
Terminal T-
==== Ethernet/Wi-Fi ====>
HA Server Mosquitto

The Gateway performs the Modbus polling natively and transmits the parsed data to Home Assistant’s Mosquitto broker over Ethernet or Wi-Fi via MQTT.

Eliminating YAML Maintenance

Rather than having to write complicated YAML templates in HA to parse the data coming from a generic MQTT state topic, you can format the Gateway’s output to use Home Assistant’s MQTT Auto-Discovery. The devices and their entities will populate automatically in the HA Devices dashboard.

3. The Two-Part Auto-Discovery Strategy

🔓 Open-Source HA Blueprint

Home Assistant’s Auto-Discovery requires two components: a static configuration payload and a continuous stream of state data. Because industrial gateways push data to a single unified global topic, we split this integration into a one-time setup and an automated hardware loop.

Step A: The One-Time Config Payload (Publish via MQTT Explorer)

Since this data never changes, use any MQTT client (like MQTT Explorer) or an HA automation to publish this configuration JSON once with the Retained = True flag. Topic: homeassistant/sensor/inverter_01/active_power/config

{ “name”: “Inverter Active Power”, “state_topic”: “valtoris/inverter_01/state”, “value_template”: “{{ value_json.power_kw }}”, “unit_of_measurement”: “kW”, “device_class”: “power”, “state_class”: “measurement”, “unique_id”: “inv01_power_001”, “device”: { “identifiers”: [“inv01_hardware”], “name”: “Deye Hybrid Inverter”, “manufacturer”: “Deye” } }

Step B: The Hardware State Loop (Valtoris Gateway)

In the Vircom configuration tool, set the Gateway’s global Publish Topic to valtoris/inverter_01/state. The hardware now handles the grueling Modbus polling and autonomously pushes this clean JSON 24/7:

{ “power_kw”: 5.42, “grid_voltage”: 230.1 }

4. Hardware Implementation Options

To execute this architecture, the edge device must support native Modbus polling, data normalization (handling Float32 byte-swapping), and custom MQTT payload templating.

❌ DIY: ESP32 & ESPHome

A popular hobbyist route is wiring a MAX485 chip to an ESP32 flashed with ESPHome.

  • The Risk: Generic ESP32 boards lack Galvanic Isolation. A voltage spike or common-mode transient from a large inverter will instantly fry the microcontroller.
  • The Hassle: Manual reboots for Wi-Fi drops. You need to write and compile custom C++/YAML logic for each individual Modbus register mapping.

✅ Valtoris Edge Gateways

Specialized DIN-rail protocol bridges for continuous environments.

  • Built to Survive: The board has 2500V isolation built-in for protection. Hardware watchdogs recover lost connections automatically.
  • Zero-Code JSON: Map registers to JSON Keywords using the Valtoris VirCom Tool. No YAML templates required.

See the “Zero-Code JSON” in Action

Watch this step-by-step community tutorial demonstrating how to use the Vircom tool to map Modbus holding registers directly to JSON payloads and enable ‘Transmit on Change’ for network optimization.

Need offline documentation?

Download the complete YAML and JSON payload blueprint for Home Assistant Integrations.

Download PDF

Tired of Dropped USB-RS485 Connections?

No more rebooting your Raspberry Pi due to EMI noise and Modbus lockups. Tell us about your smart home or commercial OT setup and we will spec the exact Edge Gateway to stream clean MQTT Auto-Discovery data directly to your Mosquitto broker.

SKU/Part No.