esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
413 stars 26 forks source link

Modbus TCP Server support #2726

Open RoganDawes opened 4 months ago

RoganDawes commented 4 months ago

As originally requested in #708, it would be very useful to be able to interact with a modbus server using modbus TCP, ideally at the same time as ESPHome is polling it.

In other words, if there is a UART connected to a modbus server, or esphome is acting as a modbus server itself, it would be useful to be able to interface with it using modbus TCP.

Obviously modbus RTU queries (if there are any) would have priority due to latency requirements.

External modbus TCP queries would need to be interleaved with internal ones such that neither gets corrupted.

I have an esp32 connected to my inverter, and have defined a number of entities the esphome queries. However, it would be useful to allow ad hoc queries of registers that have not already been defined, without having to reflash new firmware.

This can allow eg manufacturers tooling to interact with the device at the same time as esphome does.

I have used stream_server to expose the uart, but that is an exclusive use only.

Additional context

nagyrobi commented 4 months ago

A proper master and slave (in newer naming client and server) implementation for ModBUS would be nice.

My inverters can be queried via TCP too. That would relief the uarts free for more, optional factory peripherals to be connected to them.

Justheretoreportanissue commented 2 months ago

+1 I have my inverter installed remote. Inverter have Modbus TCP. Remote location have network, ethernet and WiFi. Remote location can access the Internet.

I would love to have an esphome device connect to my inverter over Modbus TCP and then act as a gateway to some 'public' MQTT broker over TLS on the Internet. Home Assistant would then be able to get all values from my inverter by reading them from the MQTT broker on the Internet.

I have already verified that the esphome device can access the MQTT broker on the Internet (EMQ) and write to topics when at the remote location.

Adding support for Modbus TCP would make my day/week/month/year/millennium and complete the missing link in my config.

Having a remote location where you would like to communicate to something with Modbus TCP and have it report back to your HA can not be that uncommon, right?

Regards,

/Jonas...

RoganDawes commented 2 months ago

+1 I have my inverter installed remote. Inverter have Modbus TCP. Remote location have network, ethernet and WiFi. Remote location can access the Internet.

I would love to have an esphome device connect to my inverter over Modbus TCP and then act as a gateway to some 'public' MQTT broker over TLS on the Internet. Home Assistant would then be able to get all values from my inverter by reading them from the MQTT broker on the Internet.

I have already verified that the esphome device can access the MQTT broker on the Internet (EMQ) and write to topics when at the remote location.

Adding support for Modbus TCP would make my day/week/month/year/millennium and complete the missing link in my config.

Having a remote location where you would like to communicate to something with Modbus TCP and have it report back to your HA can not be that uncommon, right?

Regards,

/Jonas...

Please note that this is NOT the same as the other issue that you also just commented on. This issue is asking for a modbus TCP server implemented in ESPHome, not a Modbus TCP client which the other issue refers to.

Waz-Cpt commented 1 month ago

+1 for a Modbus TCP gateway feature.

It would be awesome to see is the following could aid in the development. https://github.com/zivillian/esp32-modbus-gateway