You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all: thank you for sharing this great project, it is really nice and works pretty well for me.
I noticed some points, which I would like to share, split up to different issues as they are independent from each other.
This issue is about the performance I experienced.
I configured an update rate of 15s, but values only changed every ~45s.
There might be two options to improve this, which could be implemented both:
As far as I understand, Esphome optimizes Modbus requests by grouping multiple consecutive requests to a single one, in order to reduce traffic on the bus. This only works if there are no gaps in the registers we read. We can close gaps by either adding the information in those registers as well or "inflating" the register read request prior to a gap with the "register_count" option. Optimizing Modbus with Esphome
With this script potential gaps are listed:
import os
import re
def extract_registers_from_file(file_path):
registers = []
with open(file_path, 'r') as file:
for line in file:
if 'address' in line:
numbers = re.findall(r'\d+', line)
registers.extend(numbers)
return registers
def iterate_through_files(directory):
all_registers = []
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.yml') or file.endswith('.yaml'):
file_path = os.path.join(root, file)
registers = extract_registers_from_file(file_path)
all_registers.extend(registers)
return all_registers
if __name__ == "__main__":
directory = 'modules'
registers = iterate_through_files(directory)
print("Extracted registers:", sorted(registers))
duplicates = [reg for reg in set(registers) if registers.count(reg) > 1]
print("Duplicate registers:", sorted(duplicates))
registers = sorted(set(int(reg) for reg in registers))
gaps = [(registers[i], registers[i+1]) for i in range(len(registers) - 1) if registers[i+1] != registers[i] + 1]
print("Gaps between registers:", gaps)
Alternatively or additionally, we could configure a two modbus controllers, one with a significantly higher update rate, and one with a lower one and separate "live data values" from parameters. This is what I did in my fork. Now I can reach an update rate of ~2s for measuring the power values. The downside is, that this somehow contradicts 1) a little bit, if we fragment the requested registers too much.
I'm happy with option 2), I would try to fill the gaps nevertheless as this should improve performance even more, but I'm not sure if we can agree on a target update rate and the values we consider relevant to be live data.
The text was updated successfully, but these errors were encountered:
Hi,
first of all: thank you for sharing this great project, it is really nice and works pretty well for me.
I noticed some points, which I would like to share, split up to different issues as they are independent from each other.
This issue is about the performance I experienced.
I configured an update rate of 15s, but values only changed every ~45s.
There might be two options to improve this, which could be implemented both:
With this script potential gaps are listed:
I'm happy with option 2), I would try to fill the gaps nevertheless as this should improve performance even more, but I'm not sure if we can agree on a target update rate and the values we consider relevant to be live data.
The text was updated successfully, but these errors were encountered: