A robust "Diagnostic Toolbox" to troubleshoot, benchmark, and discover Modbus devices (RTU & TCP) directly within Home Assistant.
- Independent Driver: Builds on a custom, synchronous Modbus implementation (using
socketandpyserial). It operates completely independently ofpymodbus, ensuring no conflicts and allowing for specialized low-level control. - Device Discovery: Scan your bus to find responding Slave IDs.
- Traffic Analysis: View raw TX/RX packets with decoded MBAP headers and function codes.
- Stress Testing: Benchmark connection stability, latency, and throughput to identify flaky wiring or hardware.
- Intelligent Heuristics: Automatically detects and warns about:
- Zero-latency responses (Gateway Caching)
- Silent Gateways (Connection blocking)
- Connection Refusals vs Timeouts
Read raw data from a device and see it decoded instantly (Int16, Float32, Hex, etc.).
- Slave ID: Address of the target device (1-247).
- Register: Starting address.
- Trace: See the exact query sent and response received.
Iterate through a range of Slave IDs to find active devices.
- Range: Start and End Slave ID.
- Scan Mode:
- Standard: Sequential, safe scan (wait for timeout on each).
- Smart: Rapidly scans the entire range to detect active devices much faster than the standard method.
Hammer a device with requests to verify stability.
- Throughput: Measure actual bus speed in bits per second.
- Error Analysis: Distinguishes between network failures (IP/Port) and device failures (Wiring/Baudrate).
- Ensure HACS is installed.
- Go to HACS -> Integrations -> 3 dots (top right) -> Custom repositories.
- Paste
https://github.com/spjakob/ha-modbus-debuggerand select CategoryIntegration. - Click Add, then find Modbus Debugger and click Download.
- Restart Home Assistant.
- Copy the
custom_components/modbus_debuggerfolder to your Home Assistantconfig/custom_components/directory. - Restart Home Assistant.
- Go to Settings > Devices & Services.
- Click Add Integration.
- Search for Modbus Debugger.
- Choose your connection type:
- TCP: Enter Host IP and Port (default 502).
- Serial (RTU): Enter Port (e.g.,
/dev/ttyUSB0), Baudrate, Parity, etc.
-
Install test requirements:
pip install -r requirements_test.txt
-
Run tests:
python -m pytest tests/
For detailed information on the architecture, see TESTING.md.