diff --git a/custom_components/solarman/parser.py b/custom_components/solarman/parser.py index 55ac271..279a11a 100644 --- a/custom_components/solarman/parser.py +++ b/custom_components/solarman/parser.py @@ -45,10 +45,12 @@ def __init__(self, profile): for r in i["registers"]: self._registers_table[r] = (i["code"] if isinstance(i["code"], int) else i["code"]["read"]) if "code" in i else (p["code"] if "code" in p else (requests_table[r] if r in requests_table else self._code)) - self._is_single_code = all_same(list(self._registers_table.values())) + registers_table_values = self._registers_table.values() + + self._is_single_code = all_same(list(registers_table_values)) if self._is_single_code: - self._code = self._registers_table[0] + self._code = next(iter(registers_table_values)) self._lambda = lambda x, y: y - x > self._min_span self._lambda_code_aware = lambda x, y: self._registers_table[x] != self._registers_table[y] or y - x > self._min_span