Modbus to mqtt integration to HA

Hi,

currently, I am working on an open source software named modbus2mqtt.
It will be available as docker image and as integration to HA.

It works as follows:
Known modbus device
The user selects a modbus controller (USB RS485 stick) from a list
He/she selects a slave.
If there is a “known” device configured for this slave, it will be detected and can be used in Homeassistant without any further configuration (MQTT discovery).

The device is unknown to modbus2mqtt
The user configures an own specification for the device. This configuration will contain the mapping from modbus data to mqtt topics. It will contain the conversion rules and the mqtt discovery information.
Then, the user saves the specification can can immediately use the new device in HA.

Contribution of Specifications
If a user created a specification, it can be published to the community. In this case, it can be used by everyone in the Known modbus device scenario above. The contribution is an integrated process. It happens on github. However, all interactions except authentication is integrated into modbus2mqtt

I assume, the application will be available by end of june '24.

In the beginning, it will support the following devices:

  1. Dimplex Heatpump (based on PCO5)
  2. Deye Inverter sun-*-sg04lp3-eu
  3. Wasserstandsensor
  4. Hutschiendstromzähler Eastron SDM72D-M-2

Any other modbus devices can easily be added (as long as there is a documentation of the protocol)

If this is of interest, please reply to this post.

2 Likes

That would be great! Especially if polling interval can be set, like below 5 seconds.

The polling interval can be set individually for each slave. It can be configured from 1 ms to whatever you like.

Great! (You mean in your code, not currently in HA, right?) Looking forward to it!

My device is a Sungrow inverter (SH10RT). Registers are here if you’d like to implement. https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant

Just wait for the software. It’s very easy to configure it on your own.
The point is:
Modbus2mqtt works best if you have the converter connected to your own RS485 connector.
It will immediately show the generated mqtt values. That way, it is very easy to configure the device correctly. It doesn’t make sense to configure a device, which you don’t have in your own modbus.
However, once it’s available, I can help you configuring it.

2 Likes

Looks promissing. Does it work in both directions, so one can also send commands to the modbus device? I want to control individual hvac fan units in every (guest)room via Sauter Control NRFC4 thermostats from HA.

Great project! Can it also be used with modbus TCP devices? I have several of this kind, but the modbus implementation in HA is very complicated to use and laggy for writing to modbus registers.Modbus to mqtt would be the perfect solution.

Any progress?

Hi, I would be very interested in this. For control of a Sofar HYD-xxxx-ES inverter.

Finally, I discovered node-red and solved it very easily.

Can you explain how make own device ??
I add entity to device, but got this error: The specification can not be identified with it’s test data

I’ve just seen this. I can’t connect our PCO5 directly to Home Assistant, as the server is somewhere else. However, I plan to use a simple ESPHome/RS485 bridge to connect to the PCO5. Do you have a regiuster map of the PCO5?

The Marstek Venus Venus Energycube – MARSTEK NL-venus-energycube publishes its information with the Modbus.
I have all the documentation and i would like to publish an interface.
But there is a problem: The Mastek publishes its CRC with swapped bytes.
Does Modbus<>MQTT use normal TCP or can it also use RTUoverTCP?
I can only use RTUoverTCP on my Elfin EW11 because the EW11 blocks modbus communication with swapped CRC.
Can Modbus<>MQTT" implement RTUoverTCP and have a “Normal CRC” and a “Reverse CRC” option?
The problem is the response of the Marstek, checked with: Online Modbus RTU Parser & Modbus TCP Parser

Marstek Modbus RTU Reply cannot be passed because of the swapped CRC: 01030208ccd1bf


When I correct it manually, it parses:

Thanks for this great option to have better Modbus in HA!.

Nice so you can have an Aac battery with real time values in HA? Like charge/discharge, state of chsrge? Kann you program it, so it only charges when the PV would otherwise send it to the grid?

Cheery

You can try someting like: Using entso-e and ev smart charging to optimise pv & home battery

1 Like

I’d like to let you know about an alternative Modbus integration via MQTT. It is generic, i.e. open for any Modbus device, and targeted at experienced users willing to edit files without a UI. Modbus device information is managed in a CSV file, and the Modbus to MQTT adapter is running in a separate container, independent of Home Assistant.