Skip to content

Conversation

@julesxxl
Copy link
Collaborator

@julesxxl julesxxl commented Feb 6, 2025

That was not easy... So no more errors with ruff check, ruff format, mypy. But there are the TODOs with pylint and two other problems.
Unfortunately, I didn't get it work in HA. Pfff... Anyway, the code is there and since it's not urgent, we'll have to understand what's wrong... So many changes...
(I rebased onto #281.)

Errors in the logs:

2025-02-06 11:32:08.536 WARNING (MainThread) [pymodbus.logging] BinaryPayloadDecoder is deprecated and will be removed in v3.9.0 !
Please use "client.convert_from_registers()" or "client.convert_to_registers"
See documentation: "https://pymodbus.readthedocs.io/en/latest/source/client.html#pymodbus.client.mixin.ModbusClientMixin.convert_from_registers"
2025-02-06 11:32:08.547 WARNING (MainThread) [pymodbus.logging] BinaryPayloadDecoder is deprecated and will be removed in v3.9.0 !
Please use "client.convert_from_registers()" or "client.convert_to_registers"
See documentation: "https://pymodbus.readthedocs.io/en/latest/source/client.html#pymodbus.client.mixin.ModbusClientMixin.convert_from_registers"
2025-02-06 11:32:08.552 WARNING (MainThread) [pymodbus.logging] BinaryPayloadDecoder is deprecated and will be removed in v3.9.0 !
Please use "client.convert_from_registers()" or "client.convert_to_registers"
See documentation: "https://pymodbus.readthedocs.io/en/latest/source/client.html#pymodbus.client.mixin.ModbusClientMixin.convert_from_registers"
2025-02-06 11:32:08.552 ERROR (MainThread) [custom_components.victron.coordinator] Unexpected error fetching victron data
Traceback (most recent call last):
  File "/Users/julienpichavant/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julienpichavant/.homeassistant/custom_components/victron/coordinator.py", line 104, in _async_update_data
    self.parse_register_data(
    ~~~~~~~~~~~~~~~~~~~~~~~~^
        data, register_info_dict[name], unit
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ).items()
    ^
  File "/Users/julienpichavant/.homeassistant/custom_components/victron/coordinator.py", line 155, in parse_register_data
    raise DecodedataTypeUnsupported(
        f"Not supported data_type: {value.data_type}"
    )
custom_components.victron.coordinator.DecodedataTypeUnsupported: Not supported data_type: <custom_components.victron.const.STRING object at 0x11f0c4750>

@sfstar
Copy link
Owner

sfstar commented Feb 6, 2025

Thanks for the PR and effort, wil check out/review this weekend

@sfstar sfstar added enhancement Enhancement of the code, not introducing new features. refactor Improvement of existing code, not introducing new features. maintenance Generic maintenance tasks. labels Feb 6, 2025
@julesxxl
Copy link
Collaborator Author

julesxxl commented Feb 9, 2025

OK. Fixed those ones and others. 👍

@sfstar
Copy link
Owner

sfstar commented Feb 12, 2025

Great, wasn't able to finish the review this weekend.
Will look at the latest changes in the coming couple days

Copy link
Owner

@sfstar sfstar left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @julesxxl.

I've added feedback and questions as they arose.
Once they have been processed I will run this version locally and do a final lookover.

Keep up the good work :)

"""
config = dict(self.config_entry.options)
user_input.pop(CONF_RESCAN, None)
if user_input:
Copy link
Owner

Choose a reason for hiding this comment

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

TODO's run this locally and go through config flow


class EntityType:
"""Base entityType."""
"""Base entity_type."""
Copy link
Owner

Choose a reason for hiding this comment

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

EntityType is an class here and should therefore not be renamed in the comment from class style to var style

super().__init__(entity_type_name=entity_type_name)


class GenericAlarmLedger(Enum):
Copy link
Owner

Choose a reason for hiding this comment

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

Is this removed elsewhere?

Copy link
Owner

Choose a reason for hiding this comment

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

removed from line 180 probably due to the use of class on 166 and needing to be declared before used

2608, UINT16, UnitOfEnergy.KILO_WATT_HOUR, 100
),
"grid_serial": RegisterInfo(2609, STRING(7)),
"grid_serial": RegisterInfo(2609, str(STRING(7))),
Copy link
Owner

Choose a reason for hiding this comment

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

Why cast the string as an str here?

),
"battery_error": RegisterInfo(
register=1283, dataType=UINT16, entityType=TextReadEntityType(battery_error)
"BatteryError": RegisterInfo(
Copy link
Owner

Choose a reason for hiding this comment

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

use batteryError here since generic Alarm ledger doesn't do the same as the battery error enum class

first_register = next(iter(registerInfoDict))
return registerInfoDict[first_register].register
first_register = next(iter(register_infoDict))
return register_infoDict[first_register].register
Copy link
Owner

Choose a reason for hiding this comment

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

should the name be register_info_dict to conform to convention?

if self.description.key:
full_key = str(self.description.slave) + "." + self.description.key
else:
full_key = str(self.description.slave) + "."
Copy link
Owner

Choose a reason for hiding this comment

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

I believe this returns an invalid entity_id.

from typing import Any


class PopBuffer:
Copy link
Owner

Choose a reason for hiding this comment

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

Ignored in review as it is still being written

) # Perhaps change this to water if only water is measured in volume units
if unit in [member.value for member in UnitOfSpeed]:
if "meteo" in name:
if name and "meteo" in name:
Copy link
Owner

Choose a reason for hiding this comment

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

add seperate check for name to exist and not check 2 times in different if statements.

self._attr_native_value = self.entity_type.decodeEnum(
if data in {
item.value # type: ignore[union-attr]
for item in self.entity_type.entity_type_name
Copy link
Owner

Choose a reason for hiding this comment

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

has the decode enum been replaced?

@github-actions
Copy link

This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Apr 14, 2025
@github-actions github-actions bot closed this May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement of the code, not introducing new features. maintenance Generic maintenance tasks. refactor Improvement of existing code, not introducing new features. stale There has not been activity on this issue or PR for quite some time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants