zachcheatham / ha-omada

Home Assistant TP-Link Omada Integration
191 stars 26 forks source link

roleType no longer present in login() for Controller 5.13 #83

Closed ejpenney closed 10 months ago

ejpenney commented 10 months ago

Upgraded my Omada Software controller to 5.13.22 today and the integration started throwing this error:

2023-12-02 13:03:48.362 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Omada Controller_EE735E: Default for omada
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/omada/__init__.py", line 32, in async_setup_entry
    await omada_controller.async_setup()
  File "/config/custom_components/omada/controller.py", line 117, in async_setup
    self.api = await get_api_controller(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/omada/controller.py", line 288, in get_api_controller
    await controller.login()
  File "/config/custom_components/omada/api/controller.py", line 56, in login
    self.role_type = response["roleType"]
                     ~~~~~~~~^^^^^^^^^^^^
KeyError: 'roleType'

I wrapped the relevant line like so:

    try:
        self.role_type = response["roleType"]
    except KeyError:
        LOGGER.warning(f"Omada roleType is undefined!")

Everything works now, so it appears self.role_type isn't used? Or the default value of "0" is working in any event.

ippo112 commented 10 months ago

same error after upgrating OMADA software Controller to 5.13.22. the integration was broken.

AghilasMessara commented 10 months ago

The response doesn't have a roleType anymore. I get this {'omadacId': 'XXXXXXX', 'token': 'XXXXXXX'} I can't find the API documentation so I can't really find why...

AghilasMessara commented 10 months ago

I don't see that role_type being used anywhere, so simply remove it seems to fix it. Needs more testing and checking the documentation changes.

mdallaire commented 10 months ago

Commenting out the lines containing self.role_type in controller.py allowed the integration to start on my installation.

custom_components/omada/api/controller.py

Line 32: # self.role_type = 0 Line 56: # self.role_type = response["roleType"] Line 59: # LOGGER.info(f"Login successful. Role type {self.role_type}.")