Synchronise refresh rates from multiple modbus pollers

Hello everyone,

sorry if this has been asked or explained before but I could not find an answer to my question yet in the community. I just recently integrated my solar inverter into OH with the modbus binding. While in general this works great I encounter some strange value combinations that I believe stem from different pollers that are not synchronised in time.

First let me explain what I observe from time to time: there are (very short) periods of time where the data itself is inconsistent. For example I see that the battery gets charged with 800W but the sum of the solar power and incoming grid power is less than that. Since this does not make any sense I started thinking about possible reasons.

I believe that I found the reason in the thing configuration: the modbus registers I need to collect all the required data are not all very close to each other. Following the binding documentation this requires me to create multiple poller bridges. Although all poller bridges have the same poll rates I don’t think that they are all polled at the same time. And why would they? I could define completely different poll rates for different bridges so it would not make sense to assume that they are polled at the same time. And even if they would, there would be no guarantee that the results would come in roughly at the same time.

So as far as I can see there is probably no real solution to this problem. Because even if I would create some kind of logic that manually refreshes all polled bridges at the same time there is still no guarantee that all the values match perfectly. Nevertheless I just wanted to ask whether there is a good approach around that minimises these kind of problems. Thanks for any input!

Maintainer of the binding here

Yes, it is essentially limitation of the protocol

Have you tried polling one contiguous piece of data? Some devices refuse with that but with some it works

You mean all registers at once? No I haven’t tried that so far. I thought I would need more than 1000 but it’s actually not that bad. The items that need Synchronisation are spread over roughly 250 registers. I will try that and report back. Thank you for your input!

1 Like

Unfortunately the binding already prevents this:

However I saw that in fact the range I would need is even higher. There is another item that would require me to really go over 1000 registers so I guess I’m just gonna live with it. However I will create a rule to refresh all pollers at the same time so that at least the polls are in sync.

Unfortunately synchronising the pollers with a ruler does not work either. Two of my three pollers always get a connection refused, without the rule the retry logic in the binding fixed this automatically at the cost of being out of sync. But I guess I just have to live with that :man_shrugging:

The only way to “synchronize” information from registers is reading all related data within same poller. Recently I was reworking configuration for my modbus meter and I ended with several pollers. One for energy (1 min), one for powers and currents and other for voltage (500 ms).
It is really specific to device, cause some of them might limit data block size (poller length) below 125. Have a look and register layout and try to optimize your configuration.

Once you fetch information from device within single poll you will see only minor missalignments coming from asynchronous processing of items on OH side.

1 Like

Unfortunately the power values are not organised as a single block by the manufacturer but the order follows a different logic (one block for all Meter values, one block for the battery and so on). So I need registers in the 30s, around 300 and somewhere a bit over 1000. so I’m stuck with at least three pollers to get all relevant values.

That’s pity because there is no way to organize this data outside of data block. Each power reading will be different, even if you do it frequently.
Other way would be to scan power registers very frequently and take maybe average?

I recently been looking at openEMS and its polling cycle can be as low as 200 ms. Maybe looking at their stuff you will be able to identify a pattern how to deal with it.

What if you disable / enable the modbus bridge?
then all pollers are enabled too
 Are they in sync then?

I poll every 4 seconds and the unsync is visible but not too bad. And really short

Greets

The pollers at first also run into connection refused errors when I do that. But the binding internal retry mechanism is able to recover and the pollers come online after that. Of course this implies that I have a bit of delay after that, I don’t know how big it is though.