Skip to content

Commit

Permalink
feat: Hardcoded max modbus request size
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Aug 15, 2024
1 parent 4a473ee commit c51ff0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/solarman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ async def yaml_open(file):
def all_same(values):
return all(i == values[0] for i in values)

def group_when(iterable, predicate):
def group_when(iterable, predicate, max_size = REQUEST_MAX_SIZE):
i, x, size = 0, 0, len(iterable)
while i < size - 1:
if predicate(iterable[i], iterable[i + 1]):
if predicate(iterable[i], iterable[i + 1]) or iterable[i + 1] - iterable[x] > max_size:
yield iterable[x:i + 1]
x = i + 1
i += 1
Expand Down
1 change: 1 addition & 0 deletions custom_components/solarman/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
ATTR_FRIENDLY_NAME = "friendly_name"

REQUEST_UPDATE_INTERVAL = "update_interval"
REQUEST_MAX_SIZE = 125
REQUEST_MIN_SPAN = "min_span"
REQUEST_CODE = "code"
REQUEST_CODE_ALT = "mb_functioncode"
Expand Down

0 comments on commit c51ff0b

Please sign in to comment.