BenPru / luxtronik

Luxtronik integration for Home Assistant
MIT License
66 stars 23 forks source link

change 'extra_attributes' type to tuple #227

Closed ggajoch closed 5 months ago

ggajoch commented 6 months ago

Hi! After update to home assistant core 2024.1 luxtronik integration does not start properly:

Setup failed for custom integration 'luxtronik2': Unable to import component: Exception importing custom_components.luxtronik2
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 822, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/luxtronik2/__init__.py", line 28, in <module>
    from .coordinator import LuxtronikCoordinator
  File "/config/custom_components/luxtronik2/coordinator.py", line 21, in <module>
    from .common import correct_key_value
  File "/config/custom_components/luxtronik2/common.py", line 25, in <module>
    from .model import LuxtronikCoordinatorData
  File "/config/custom_components/luxtronik2/model.py", line 89, in <module>
    @dataclass
     ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1027, in _process_class
    _init_fn(all_init_fields,
  File "/usr/local/lib/python3.11/dataclasses.py", line 545, in _init_fn
    raise TypeError(f'non-default argument {f.name!r} '
TypeError: non-default argument 'extra_attributes' follows default argument

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 830, in get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.luxtronik2

I've tracked it down to the extra_attributes being set by the default_factory, which is not a value.

This PR changes type of extra_attributes to tuple to give it proper value in dataclass. With that change integration starts at my installation successfully.

All the best!

svasek commented 6 months ago

This PR changes type of extra_attributes to tuple to give it proper value in dataclass. With that change integration starts at my installation successfully.

Hi, thank you for your quick fix. I can confirm it works like a charm but the new firmware is set as unavail.

lancer73 commented 6 months ago

Can confirm that this restores functionality (I don't use the update entity)

KlausV66 commented 6 months ago

I have the same problem and downgraded to HA 2023-12. Do we get a new beta version? I have installed 2023-11-30 beta.

Robman1 commented 6 months ago

@ggajoch Man, you are a genius. Works excellent. Thank you.

rcreate commented 6 months ago

Oh please approve this PR. My statistics and control are not working for days. Hopefully we get a new version within the next days from @BenPru 🤗

iBLtz commented 5 months ago

just change the 3 files in the folder for the meantime :P Thanks for the fix btw !

feu77 commented 5 months ago

Hey, I just edited the 3 files, restarted HA, I get the an unknown error when trying to add the integration. I fill in the correct IP address and port...

Any idea? thanks in advance

Bildschirmfoto 2024-01-05 um 17 06 18
kairetzlaff commented 5 months ago

Hey, I just edited the 3 files, restarted HA, I get the an unknown error when trying to add the integration. I fill in the correct IP address and port...

Any idea? thanks in advance Bildschirmfoto 2024-01-05 um 17 06 18

Same here. Integration does not start

TechSaiyajin commented 5 months ago

Had the same problem, restarting Home Assistant helped me.

kairetzlaff commented 5 months ago

Had the same problem, restarting Home Assistant helped me.

Okey, I´ve copied the 3 entire files and now it works again. Thanks for the fix!!!

FSK4ever commented 5 months ago

@ggajoch works fine, thanks for this quick fix

MaWeSX commented 5 months ago

fix of 3 files worked for me... (https://github.com/BenPru/luxtronik/pull/227/commits/da92c67de66d84ab9291899c4fcbb51ef5fc9683)

when integration fails please double check if you replace [ with an ( and not () (which I oversaw the first time , auto complete of VS code)

Thanks @ggajoch

feu77 commented 5 months ago

I have changed all 3 files, even copied them 1:1, but I get the following error in the logs:

> Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
> 
> Logger: custom_components.luxtronik2
> Source: custom_components/luxtronik2/config_flow.py:223
> Integration: Luxtronik
> First occurred: 14:36:50 (6 occurrences)
> Last logged: 15:09:31
> 
> Could not handle config_flow.async_step_options {'host': '192.168.2.88', 'port': 8889, 'timeout': 60, 'max_data_length': 10000}
> Could not handle config_flow.async_step_options {'host': '192.168.2.88', 'port': 8888, 'timeout': 60, 'max_data_length': 10000}
> Could not handle config_flow.async_step_options {'host': '192.168.2.88', 'port': 8889, 'timeout': 120, 'max_data_length': 10000}
> Traceback (most recent call last):
>   File "/config/custom_components/luxtronik2/config_flow.py", line 223, in async_step_options
>     await self.async_set_unique_id(coordinator.unique_id)
>   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1624, in async_set_unique_id
>     raise data_entry_flow.AbortFlow("already_in_progress")
> homeassistant.data_entry_flow.AbortFlow: Flow aborted: already_in_progress
Banabeldadsch commented 5 months ago

fix of 3 files worked for me... (da92c67)

when integration fails please double check if you replace [ with an ( and not () (which I oversaw the first time , auto complete of VS code)

Thanks @ggajoch

Cannot even find the 3 files or the Files Look different. Is luxtronik2 Integration not similiar?

MaWeSX commented 5 months ago

fix of 3 files worked for me... (da92c67) when integration fails please double check if you replace [ with an ( and not () (which I oversaw the first time , auto complete of VS code) Thanks @ggajoch

Cannot even find the 3 files or the Files Look different. Is luxtronik2 Integration not similiar?

I'm using version 2023.11.30-Beta. if you click on the link you can see in the header the file names: custom_components/luxtronik/model.py custom_components/luxtronik/number_entities_predefined.py custom_components/luxtronik/sensor_entities_predefined.py

which you can find here: image

MaWeSX commented 5 months ago

I have changed all 3 files, even copied them 1:1, but I get the following error in the logs:

> Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
> 
> Logger: custom_components.luxtronik2
> Source: custom_components/luxtronik2/config_flow.py:223
> Integration: Luxtronik
> First occurred: 14:36:50 (6 occurrences)
> Last logged: 15:09:31
> 
> Could not handle config_flow.async_step_options {'host': '192.168.2.88', 'port': 8889, 'timeout': 60, 'max_data_length': 10000}
> Could not handle config_flow.async_step_options {'host': '192.168.2.88', 'port': 8888, 'timeout': 60, 'max_data_length': 10000}
> Could not handle config_flow.async_step_options {'host': '192.168.2.88', 'port': 8889, 'timeout': 120, 'max_data_length': 10000}
> Traceback (most recent call last):
>   File "/config/custom_components/luxtronik2/config_flow.py", line 223, in async_step_options
>     await self.async_set_unique_id(coordinator.unique_id)
>   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1624, in async_set_unique_id
>     raise data_entry_flow.AbortFlow("already_in_progress")
> homeassistant.data_entry_flow.AbortFlow: Flow aborted: already_in_progress

seems like that you added more then one Heat pump ? share all the same IP and different ports / timeouts? => just guessing by the logfile

feu77 commented 5 months ago

ok, my error quoted earlier is clear now: the integration was already configured but ignored thus the error message.

So it's running for me now! a big thank you @ggajoch

BenPru commented 5 months ago

Thanks for the PR. LGTM

Banabeldadsch commented 5 months ago

fix of 3 files worked for me... (da92c67) when integration fails please double check if you replace [ with an ( and not () (which I oversaw the first time , auto complete of VS code) Thanks @ggajoch

Cannot even find the 3 files or the Files Look different. Is luxtronik2 Integration not similiar?

I'm using version 2023.11.30-Beta. if you click on the link you can see in the header the file names: custom_components/luxtronik/model.py custom_components/luxtronik/number_entities_predefined.py custom_components/luxtronik/sensor_entities_predefined.py

which you can find here: image

Model.py seems really short in my HA (V2024.1.2) Do not have the other two files.

I guess i use the one from bouni? Might be a difference . Where can I see which one I have?

Sorry for bothering again...

MaWeSX commented 5 months ago

fix of 3 files worked for me... (da92c67) when integration fails please double check if you replace [ with an ( and not () (which I oversaw the first time , auto complete of VS code) Thanks @ggajoch

Cannot even find the 3 files or the Files Look different. Is luxtronik2 Integration not similiar?

I'm using version 2023.11.30-Beta. if you click on the link you can see in the header the file names: custom_components/luxtronik/model.py custom_components/luxtronik/number_entities_predefined.py custom_components/luxtronik/sensor_entities_predefined.py which you can find here: image

Model.py seems really short in my HA (V2024.1.2) Do not have the other two files.

I guess i use the one from bouni? Might be a difference . Where can I see which one I have?

Sorry for bothering again...

go to HACS click the integration

in the top you see the creator:

image

Banabeldadsch commented 5 months ago

fix of 3 files worked for me... (da92c67) when integration fails please double check if you replace [ with an ( and not () (which I oversaw the first time , auto complete of VS code) Thanks @ggajoch

Cannot even find the 3 files or the Files Look different. Is luxtronik2 Integration not similiar?

I'm using version 2023.11.30-Beta. if you click on the link you can see in the header the file names: custom_components/luxtronik/model.py custom_components/luxtronik/number_entities_predefined.py custom_components/luxtronik/sensor_entities_predefined.py which you can find here: image

Model.py seems really short in my HA (V2024.1.2) Do not have the other two files. I guess i use the one from bouni? Might be a difference . Where can I see which one I have? Sorry for bothering again...

go to HACS click the integration

in the top you see the creator:

image

Its getting worse

Screenshot_20240112_143343_Home Assistant

BenPru commented 5 months ago

Please use a forum or issue, no PR.