Skip to content

Commit

Permalink
fix: ParameterParser KeyError during init
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Aug 16, 2024
1 parent 81ddf2b commit 75a6809
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/solarman/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

5 comments on commit 75a6809

@manuel833
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now working, but I am not getting any data displayed.

solarman

@manuel833
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.solarman.sensor
Quelle: custom_components/solarman/sensor.py:48
Integration: Solarman (Dokumentation, Probleme)
Erstmals aufgetreten: 15:52:00 (7 Vorkommnisse)
Zuletzt protokolliert: 15:56:45

Configuring {'name': 'Battery SOH', 'class': '', 'state_class': 'measurement', 'uom': '%', 'scale': 1, 'rule': 1, 'registers': [1545], 'icon': 'mdi:battery'} failed. [TypeError: '<=' not supported between instances of 'NoneType' and 'int']

@manuel833
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger: homeassistant.components.sensor
Quelle: helpers/entity_platform.py:372
Integration: Sensor (Dokumentation, Probleme)
Erstmals aufgetreten: 15:52:00 (7 Vorkommnisse)
Zuletzt protokolliert: 15:56:45

Error while setting up solarman platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 372, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 631, in async_add_entities
for entity in new_entities:
File "/config/custom_components/solarman/sensor.py", line 66, in
async_add_entities(_create_sensor(coordinator, sensor, battery_nominal_voltage, battery_life_cycle_rating) for sensor in sensors if ((not "class" in sensor or not sensor["class"] in PLATFORMS) and not "configurable" in sensor))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/solarman/sensor.py", line 44, in _create_sensor
entity.update()
File "/config/custom_components/solarman/sensor.py", line 110, in update
if battery_capacity <= 0:
^^^^^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'NoneType' and 'int'

@davidrapan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if battery_capacity <= 0:

It looks like you are not using latest version of the code in the repo.

You did the adjustments from this commit manually?

@davidrapan
Copy link
Owner Author

@davidrapan davidrapan commented on 75a6809 Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in the meanwhile I also noticed another bug which i promptly fixed in: fix: Custom BatterySensor only when missing registers property

Please sign in to comment.