nbogojevic / homeassistant-midea-air-appliances-lan

This Home Assistant custom component adding support for controlling Midea air conditioners and dehumidifiers on local network.
MIT License
268 stars 29 forks source link

Home Assistant 2023.5.0b0 - Integration configures but fails to start #110

Closed arcangelweb closed 5 months ago

arcangelweb commented 1 year ago

I am sending you this data if it is of interest to you, surely it cannot be considered a failure, until the final version.

Version of the custom_component

midea-beautiful-air = 0.9.15

Add your logs here.

Beta 0

Logger: homeassistant.config_entries Source: custom_components/midea_dehumidifier_lan/init.py:68 Integration: Midea Air Appliances (LAN) (documentation, issues) First occurred: 18:47:58 (1 occurrences) Last logged: 18:47:58

Error setting up entry Midea Air Appliance (LAN) for midea_dehumidifier_lan Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/midea_dehumidifier_lan/init.py", line 68, in async_setup_entry hass.config_entries.async_setup_platforms(config_entry, PLATFORMS) AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'

Beta 4

Este error se originó a partir de una integración personalizada.

Logger: homeassistant.config_entries Source: custom_components/midea_dehumidifier_lan/init.py:68 Integration: Midea Air Appliances (LAN) (documentation, issues) First occurred: 10:35:11 (2 occurrences) Last logged: 11:13:00

Error setting up entry Midea Air Appliance (LAN) for midea_dehumidifier_lan Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/midea_dehumidifier_lan/init.py", line 68, in async_setup_entry hass.config_entries.async_setup_platforms(config_entry, PLATFORMS) AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'

Describe the bug

Integration configures but fails to start

home-assistant_midea_dehumidifier_lan_2023-04-27T16-54-41.192Z.log

Gui576 commented 1 year ago

Hello,

Same issue but with the production build HAS 2023.5.0

Integration work fine if I rollback to the previous HAS version

arcangelweb commented 1 year ago

hello, the problem has been maintained until the final version.

raoulx24 commented 1 year ago

in your custom integration, edit the init.py file, search for

    hass.config_entries.async_setup_platforms(entry, PLATFORMS)

and replace it with

    try:
        await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
    except AttributeError:
        hass.config_entries.async_setup_platforms(entry, PLATFORMS)

Mind the indentation, I do not know if they are important in python, I live my life in a different realm (c#).

After that, I had to restart HA (I use it in docker, it was not enough to reload the integration, do not ask me why it didn't work like that). I tested it on a fresh test installation of HA 2023.05. Start, stop, fan control, sensors all seems to work. Hopefully, the maintainer of this repo will include it and also will check if there are other hidden side effects or other fixes.

Source: commit: https://github.com/mmaarrkk02/hass-blueair/commit/b43a07b686bc88b7d751e381444f96e0ebb7bc70 from this issue: https://github.com/aijayadams/hass-blueair/issues/19

Hope it helps.

arcangelweb commented 1 year ago

Your modification worked for me, with a small correction, "config_entry" instead of "entry".

Thank you so much @raoulx24

    try:
        await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
    except AttributeError:
        hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
raoulx24 commented 1 year ago

Your modification worked for me, with a small correction, "config_entry" instead of "entry".

I think it is because I use an older version of the integration.

As a side comment, I think the try except should be the other way around. This is true if I understood correctly its logic and that it is similar to (let's say) try {} catch(AttributeError ex) {} from c#.

And even more, considering that somewhere I read that hass.config_entries.async_setup_platforms is deprecated, I think that the whole try except should be dropped and it should be just like

    await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)

But again, I'm from another realm and I leave this for others to decide. 😃

Cheers 😃

ddawley commented 1 year ago

Nice save, @raoulx24. Very much appreciated!

mmaarrkk02 commented 1 year ago

Hi @raoulx24, You can remove try except if your HA core version >= 2022.8.0.

I think most people will update to a newer version, so it will not execute to the except block.

But I still want the old HA versions to work as well, because the custom components don't contain the core library, they use the server's core functionality.

Hope it helps you.

fabiobaleizao91 commented 1 year ago

I’m also facing the same issue, but tried to apply the changes on init.py file but didn’t help. I just downgraded HA to a previous release. I’m running Home Assistant 2023.3.6 and it’s working. I’ll keep it until we get a fix

fabiobaleizao91 commented 1 year ago

Is this issue being worked on? Any idea in which update will the fix be released?

arcangelweb commented 1 year ago

@fabiobaleizao91 It seems that currently the project is on pause, but the solution worked for me in version 2023.6.0b1, I hope we have luck and continue, great work.

fabiobaleizao91 commented 1 year ago

@fabiobaleizao91 It seems that currently the project is on pause, but the solution worked for me in version 2023.6.0b1, I hope we have luck and continue, great work.

Thank you for your reply. Would it be ok if you could help me fixing it on the the version you're running? I tried it but it didn't help.

This is what I am running right now: Home Assistant 2023.3.6 Supervisor 2023.04.1 Interface: 20230309.1 - latest

And the latest version is 2023.5.4

github-actions[bot] commented 5 months ago

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