Improving modbus "slave entities"

I’m setting up a couple of generic modbus devices (current sensors and relays), each with 8-16 “channels”, meaning I need to read/poll in total maybe 24-50 registers many times a minute. It is quite useful therefore to combine register reads using the modbus commands that do read multiple registers in one go.

Thankfully there is support in the modbus component now for such “slave entities”. However while setting this up, I would like to suggest some possible improvements:

  1. Terminology: The word “slave” in standard modbus terminology is used for the 8-bit value that identifies devices on the bus. It is confusing both for the end-user and in the source code to use the same word for the dependant entities.

  2. Configuration: Currently “slave entities” are configured by slave_count. There is no option to specify individual entity names, data types, scale, or units. Also, the “slave entity” concept and how it interacts with count, data_type etc is not intuitive.

In summary, “slave entities” is a very useful feature that I think could be even more useful with some improvements.

I would be happy to provide code and PRs for this “feature request”. I thought it’d be a good idea to discuss it first, hopefully this here is the place to do this.

My suggestion would be to add a new config entry multiple_sensors or somesuch, where each config entry specifies the several entities with individual names, units, etc. This strategy would not unduly mess up the existing sensors config schema.