Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change 'extra_attributes' type to tuple #227

Merged
merged 1 commit into from
Jan 10, 2024
Merged

change 'extra_attributes' type to tuple #227

merged 1 commit into from
Jan 10, 2024

Conversation

ggajoch
Copy link
Contributor

@ggajoch ggajoch commented Jan 4, 2024

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
Copy link
Contributor

svasek commented Jan 4, 2024

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
Copy link

lancer73 commented Jan 4, 2024

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

@KlausV66
Copy link

KlausV66 commented Jan 4, 2024

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
Copy link

Robman1 commented Jan 4, 2024

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

@rcreate
Copy link

rcreate commented Jan 4, 2024

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
Copy link

iBLtz commented Jan 5, 2024

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

@feu77
Copy link

feu77 commented Jan 5, 2024

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
Copy link

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
Copy link

Had the same problem, restarting Home Assistant helped me.

@kairetzlaff
Copy link

kairetzlaff commented Jan 5, 2024

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
Copy link

FSK4ever commented Jan 5, 2024

@ggajoch works fine, thanks for this quick fix

@MaWeSX
Copy link

MaWeSX commented Jan 7, 2024

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

@feu77
Copy link

feu77 commented Jan 8, 2024

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
Copy link

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
Copy link

MaWeSX commented Jan 10, 2024

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
Copy link

MaWeSX commented Jan 10, 2024

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
Copy link

feu77 commented Jan 10, 2024

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 BenPru merged commit 6f9d1d6 into BenPru:main Jan 10, 2024
1 of 4 checks passed
@BenPru
Copy link
Owner

BenPru commented Jan 10, 2024

Thanks for the PR. LGTM

@Banabeldadsch
Copy link

Banabeldadsch commented Jan 12, 2024

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
Copy link

MaWeSX commented Jan 12, 2024

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
Copy link

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
Copy link
Owner

BenPru commented Jan 12, 2024

Please use a forum or issue, no PR.

Repository owner locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.