Modbus input bit filtering

Help with Modbus…I am new to HA. I have installed a number of modbus RTU’s in my house and a Ras Pi 4Gb with 32Gb sd, Loaded the standard image and BINGO it came up first time! I have added an USB to RS485 converter, connected to the RS485. All good so far. I have added the modbus Add-on to my YAML configuration file using Visual studio. The OS is HA2021.12.10 frontend 202112294.

The modbus boards have I/O for eight inputs and eight outputs. They are all working well.
To read an input on these boards one has to load eight (and only eight) bits from the selected address, and then AND the bit you want from the rest. I think I’d like to read the eight bits into a variable and do the bit filter for each switch (input) rather than read read the modbus eight times so reduce traffic.
Using my terminal I can see the bits over RS485 by sending the following; (hex)
6E 02 00 00 00 00 08 70 93
Received data will be 6E 02 01 00 BC 96 where 96BC is the CRC, and 00 is the data.
Address is 110d (6E) command 02 (read single bit base register 0 Number of bits 8.
Now the problem for me is I haven’t a clue how this can be achieved, and how to make the config file read the specified number of bits. How to create a temporary variable and filter it.
All answers gratefully received.
David.

Hi Nikito, Thank you very much for taking the trouble to point me in the right direction. I’m sure the

Will be very very helpful. I did look through a lot of the FAQ’s but didn’t find that one!
Regards David.

1 Like