Skip to content

Commit

Permalink
refactor: Add more debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Feb 10, 2025
1 parent 1fd2627 commit 0bfdfe1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/solarman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def lookup_profile(request, attr):
attr[ATTR_[CONF_PHASE]] = min(1 if t <= 2 or t == 8 else 3, attr[ATTR_[CONF_PHASE]])
if (v := get_addr_value(response, AUTODETECTION_CODE_DEYE, c)) and (t := (v & 0x0F00) // 0x100) and (p := v & 0x000F) and (t := 2 if t > 12 else t) and (p := 3 if p > 3 else p):
attr[ATTR_[CONF_MOD]], attr[ATTR_[CONF_MPPT]], attr[ATTR_[CONF_PHASE]] = max(m, attr[ATTR_[CONF_MOD]]), min(t, attr[ATTR_[CONF_MPPT]]), min(p, attr[ATTR_[CONF_PHASE]])
if device_type in (0x0005, 0x0500, 0x0006, 0x0007, 0x0600, 0x0008, 0x0601) and (response := await request(-1, set_request(0x0003, 0x2712, 0x2713))) and (p := get_addr_value(response, 0x0003, 0x2712)) is not None:
if device_type in (0x0005, 0x0500, 0x0006, 0x0007, 0x0600, 0x0008, 0x0601) and (response := await request(-1, set_request(0x0003, 0x2712, 0x2712))) and (p := get_addr_value(response, 0x0003, 0x2712)) is not None:
attr[ATTR_[CONF_PACK]] = max(p, attr[ATTR_[CONF_PACK]])
return f
raise Exception("Unable to read Device Type at address 0x0000")
Expand Down
4 changes: 3 additions & 1 deletion custom_components/solarman/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, profile, attr):
_LOGGER.debug("Fine control of request sets is enabled!")
self._requests = profile["requests"]

_LOGGER.debug(f"{'Defaults' if 'default' in profile else 'Stock values'} for update_interval: {self._update_interval}, code: {self._code}, min_span: {self._min_span}, max_size: {self._max_size}, digits: {self._digits}")
_LOGGER.debug(f"{'Defaults' if 'default' in profile else 'Stock values'} for update_interval: {self._update_interval}, code: {self._code}, min_span: {self._min_span}, max_size: {self._max_size}, digits: {self._digits}, attributes: {attr}")

table = {r: get_request_code(pr) for pr in profile["requests"] for r in range(pr[REQUEST_START], pr[REQUEST_END] + 1)} if "requests" in profile and not "requests_fine_control" in profile else {}

Expand All @@ -48,6 +48,8 @@ def __init__(self, profile, attr):
if (items_codes := [get_code(i, "read", self._code) for i in self._items if "registers" in i]) and (is_single_code := all_same(items_codes)):
self._is_single_code = is_single_code
self._code = items_codes[0]

_LOGGER.debug(f"Items: {self._items}")

l = (lambda x, y: y - x > self._min_span) if self._min_span > -1 else (lambda x, y: False)

Expand Down

0 comments on commit 0bfdfe1

Please sign in to comment.