Skip to content

Commit

Permalink
- Optimized M160 check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdelprete committed Jan 16, 2025
1 parent 47e690c commit d922440
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/abb_powerone_pvi_sunspec/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
DEVICE_STATUS,
INVERTER_TYPE,
SUNSPEC_M160_OFFSETS,
SUNSPEC_MODEL_160_ID,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -254,8 +255,7 @@ def find_sunspec_modbus_m160_offset(self) -> int:
invmodel = self.data["comm_model"].upper()
found_offset = 0
multi_mppt_id = 0
offsets = SUNSPEC_M160_OFFSETS
for offset in offsets:
for offset in SUNSPEC_M160_OFFSETS:
_LOGGER.debug(
f"(find_m160) Find M160 for model: {invmodel} at offset: {offset}"
)
Expand All @@ -266,7 +266,7 @@ def find_sunspec_modbus_m160_offset(self) -> int:
read_model_160_data.registers, byteorder=Endian.BIG
)
multi_mppt_id = decoder.decode_16bit_uint()
if multi_mppt_id != 160:
if multi_mppt_id != SUNSPEC_MODEL_160_ID:
_LOGGER.debug(
f"(find_m160) Model is not 160 - offset: {offset} - multi_mppt_id: {multi_mppt_id}"
)
Expand Down
1 change: 1 addition & 0 deletions custom_components/abb_powerone_pvi_sunspec/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
DEFAULT_SCAN_INTERVAL = 60
MIN_SCAN_INTERVAL = 30
SUNSPEC_M160_OFFSETS = [122, 1104, 208]
SUNSPEC_MODEL_160_ID = 160
STARTUP_MESSAGE = f"""
-------------------------------------------------------------------
{NAME}
Expand Down

0 comments on commit d922440

Please sign in to comment.