home-assistant-tapo-p100 icon indicating copy to clipboard operation
home-assistant-tapo-p100 copied to clipboard

Authentication Failed P100

Open scornflake opened this issue 11 months ago • 2 comments

Version of the integration

v3.0.0

Configuration

P100, Hardware 1.0.0, Firmware 1.3.0 build 20210310 Rel 63416

Describe the bug

Cannot authenticate to device. Cannot add the device to HA.

Debug log


This error originated from a custom integration.

Logger: custom_components.tapo.config_flow
Source: custom_components/tapo/config_flow.py:231
integration: TP-Link Tapo (documentation, issues)
First occurred: 9:53:07 PM (3 occurrences)
Last logged: 10:01:37 PM

Failed to setup, invalid auth
Traceback (most recent call last):
  File "/config/custom_components/tapo/config_flow.py", line 307, in _async_get_device_info
    (await client.get_device_info())
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/api/tapo_client.py", line 92, in get_device_info
    return await self.execute_raw_request(get_info_request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/api/tapo_client.py", line 77, in execute_raw_request
    await self._initialize_protocol_if_needed()
  File "/usr/local/lib/python3.12/site-packages/plugp100/api/tapo_client.py", line 71, in _initialize_protocol_if_needed
    await self._guess_protocol()
  File "/usr/local/lib/python3.12/site-packages/plugp100/api/tapo_client.py", line 232, in _guess_protocol
    raise error
plugp100.responses.tapo_exception.TapoException: Returned error_code: TapoError.INVALID_CREDENTIAL: Invalid credentials

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

Traceback (most recent call last):
  File "/config/custom_components/tapo/config_flow.py", line 231, in async_step_discovery_auth_confirm
    device_info = await self._async_get_device_info_from_discovered(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/config_flow.py", line 294, in _async_get_device_info_from_discovered
    return await self._async_get_device_info(config | {CONF_HOST: discovered.ip})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/config_flow.py", line 312, in _async_get_device_info
    self._raise_from_tapo_exception(error)
  File "/config/custom_components/tapo/config_flow.py", line 319, in _raise_from_tapo_exception
    raise InvalidAuth from exception
custom_components.tapo.errors.InvalidAuth

scornflake avatar Mar 24 '24 09:03 scornflake

I'm new to dev on HA / HACS (not python).

Im trying to provide better info. Can someone tell me how i'd breakpoint or hot-reload the HACS code? is it possible?

e.g: Im messing with it like so:

 async def _async_get_device_info(self, config: dict[str, Any]) -> DeviceInfo:
        if not config[CONF_HOST]:
            raise InvalidHost
        try:
            session = async_create_clientsession(self.hass)
            credential = AuthCredential(config[CONF_USERNAME], config[CONF_PASSWORD])
            host, port = get_host_port(config[CONF_HOST])
            client = TapoClient.create(
                credential, address=host, port=port, http_session=session
            )
            info = await client.get_device_info()
            _LOGGER.info(f"_async_get_device_info info: {info}")
            
            if info is not None:
                dev_info = DeviceInfo(**info)
                
            return (
                (await client.get_device_info())
                .map(lambda x: DeviceInfo(**x))
                .get_or_raise()

namely:

_LOGGER.info(f"_async_get_device_info info: {info}")

is there a better / faster way to interact with the code other than what I'm doing? which is:

  1. change it using vs code server within HA
  2. reboot the HA instance
  3. observe
  4. get a cup of tea

scornflake avatar Mar 24 '24 09:03 scornflake

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 23 '24 22:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 08 '24 22:05 github-actions[bot]