Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Show HEX Modbus addresses too in the logs #495

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions custom_components/solarman/solarman.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def get_statistics(self):
start = request['start']
end = request['end']
mb_fc = request['mb_functioncode']
log.debug(f"Querying [{start} - {end}]...")
range_string = f"{start}-{end} (0x{start:04X}-0x{end:04X})"
log.debug(f"Querying [{range_string}]...")

attempts_left = QUERY_RETRY_ATTEMPTS
while attempts_left > 0:
Expand All @@ -85,15 +86,15 @@ def get_statistics(self):
result = 1
except Exception as e:
result = 0
log.warning(f"Querying [{start} - {end}] failed with exception [{type(e).__name__}: {e}]")
log.warning(f"Querying [{range_string}] failed with exception [{type(e).__name__}: {e}]")
self.disconnect_from_server()
if result == 0:
log.warning(f"Querying [{start} - {end}] failed, [{attempts_left}] retry attempts left")
log.warning(f"Querying [{range_string}] failed, [{attempts_left}] retry attempts left")
else:
log.debug(f"Querying [{start} - {end}] succeeded")
log.debug(f"Querying [{range_string}] succeeded")
break
if result == 0:
log.warning(f"Querying registers [{start} - {end}] failed, aborting.")
log.warning(f"Querying registers [{range_string}] failed, aborting.")
break

if result == 1:
Expand Down
Loading