JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
947 stars 80 forks source link

Integration doesn't accept the known (cloud)password anymore on new firmware #550

Closed wavemop closed 2 months ago

wavemop commented 2 months ago

Description

2 days ago i ran the new firmware update for my tapo C200 cams. The HA integration asked to "configure" these devices again but rejects the CLOUD password.

Reproduction Steps

  1. In the first Step the (saved) username + password for the CAMERA account were offered, I confirmed them -> worked.

  2. In the second step

    • the CLOUD password** was asked and the (saved) password was offered like in the first step -> For any reason it is getting rejected. -I double and triple checked the password but it's correct. (can copy/paste it from HA in Tapo app and on all TP-Link sites and it is working there)
  3. After that I -kicked out the cams in HA -hard-reset them in the Tapo-App -discovered them new -> they were found perfectly fine but still the same bug persists...

Expected behavior

integration accepts the CLOUD password

If applicable, add error logs.

Protocol: `2024-04-10 23:06:28.027 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-10 23:06:28.035 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration tapo_control which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-10 23:06:28.038 WARNING (SyncWorker_2) [homeassistant.loader] We found custom integration tapo which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-10 23:06:28.042 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration watchman which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-10 23:06:48.598 WARNING (MainThread) [homeassistant.setup] Setup of bluetooth is taking over 10 seconds. 2024-04-10 23:07:20.085 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/discovery_flow.py", line 96, in _async_start await gather_with_limitedconcurrency( File "/usr/src/homeassistant/homeassistant/util/async.py", line 188, in gather_with_limitedconcurrency return await gather( ^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/async.py", line 186, in sem_task return await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 947, in async_init flow, result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 975, in _async_init result = await self._async_handle_step(flow, flow.init_step, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 508, in _async_handle_step if result.get("preview") is not None: ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get' 2024-04-10 23:07:45.551 WARNING (MainThread) [homeassistant.config_entries] Config entry '192.168.178.81' for tapo_control integration could not authenticate: Invalid authentication data 2024-04-10 23:07:45.879 WARNING (MainThread) [homeassistant.config_entries] Config entry '192.168.178.82' for tapo_control integration could not authenticate: Invalid authentication data 2024-04-10 23:12:37.555 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10 TypeError: this.contentElement is null renderHeading (src/components/ha-dialog.ts:53:4) apply (src/scoped-custom-element-registry.js:262:44) mainWindow.history.pushState (src/dialogs/make-dialog-manager.ts:129:7) 2024-04-10 23:12:56.949 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10 TypeError: this.contentElement is null renderHeading (src/components/ha-dialog.ts:53:4) apply (src/scoped-custom-element-registry.js:262:44) mainWindow.history.pushState (src/dialogs/make-dialog-manager.ts:129:7) 2024-04-10 23:14:58.894 ERROR (MainThread) [homeassistant.config_entries] Error calling entry remove callback 192.168.178.82 for tapo_control Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 645, in async_remove await component.async_remove_entry(hass, self) File "/config/custom_components/tapo_control/init.py", line 277, in async_remove_entry coldDirPath = getColdDirPathForEntry(hass, entry_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/utils.py", line 116, in getColdDirPathForEntry if hass.data[DOMAIN][entry_id]["mediaSyncColdDir"] is False:


KeyError: 'mediaSyncColdDir'
2024-04-10 23:15:02.138 ERROR (MainThread) [homeassistant.config_entries] Error calling entry remove callback 192.168.178.81 for tapo_control
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 645, in async_remove
    await component.async_remove_entry(hass, self)
  File "/config/custom_components/tapo_control/__init__.py", line 277, in async_remove_entry
    coldDirPath = getColdDirPathForEntry(hass, entry_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo_control/utils.py", line 116, in getColdDirPathForEntry
    if hass.data[DOMAIN][entry_id]["mediaSyncColdDir"] is False:
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
2024-04-11 04:49:09.522 ERROR (MainThread) [homeassistant.components.met.coordinator] Error fetching met data: Update failed: 
2024-04-11 10:25:07.316 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Error communication with API: Cannot connect to host 192.168.178.85:80 ssl:default [Connect call failed ('192.168.178.85', 80)]
2024-04-11 10:25:07.349 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Error communication with API: Cannot connect to host 192.168.178.84:80 ssl:default [Connect call failed ('192.168.178.84', 80)]
2024-04-11 10:46:20.854 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 12:31:03.855 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 12:48:04.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 13:02:50.855 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 13:09:36.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 13:35:10.854 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 13:47:38.855 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 13:50:39.855 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 13:56:38.856 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 14:07:03.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 14:11:42.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 14:14:43.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 14:22:14.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 14:23:25.856 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 14:48:08.855 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-11 17:02:14.742 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10
TypeError: i is undefined
_keyFunction (src/panels/config/integrations/dialog-add-integration.ts:464:4)
item (src/virtualize.ts:116:53)
r (src/directives/repeat.ts:56:28)
ct (src/directives/repeat.ts:93:52)
update (src/directive.ts:134:16)
_$AS (src/lit-html.ts:1085:23)
S (src/lit-html.ts:1362:12)
_$AI (src/async-directive.ts:366:18)
setValue (src/virtualize.ts:139:13)
dispatchEvent (src/Virtualizer.ts:808:23)
2024-04-11 17:02:14.752 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10
TypeError: i is undefined
_keyFunction (src/panels/config/integrations/dialog-add-integration.ts:464:4)
item (src/virtualize.ts:116:53)
r (src/directives/repeat.ts:56:28)
ct (src/directives/repeat.ts:93:52)
update (src/directive.ts:134:16)
_$AS (src/lit-html.ts:1085:23)
S (src/lit-html.ts:1362:12)
_$AI (src/async-directive.ts:366:18)
setValue (src/virtualize.ts:139:13)
dispatchEvent (src/Virtualizer.ts:808:23)
2024-04-11 17:02:16.320 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10
TypeError: i is undefined
_keyFunction (src/panels/config/integrations/dialog-add-integration.ts:464:4)
item (src/virtualize.ts:116:53)
r (src/directives/repeat.ts:56:28)
ct (src/directives/repeat.ts:93:52)
update (src/directive.ts:134:16)
_$AS (src/lit-html.ts:1085:23)
S (src/lit-html.ts:1362:12)
_$AI (src/async-directive.ts:366:18)
setValue (src/virtualize.ts:139:13)
dispatchEvent (src/Virtualizer.ts:808:23)
2024-04-11 17:02:18.645 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10
TypeError: i is undefined
_keyFunction (src/panels/config/integrations/dialog-add-integration.ts:464:4)
item (src/virtualize.ts:116:53)
r (src/directives/repeat.ts:56:28)
ct (src/directives/repeat.ts:93:52)
update (src/directive.ts:134:16)
_$AS (src/lit-html.ts:1085:23)
S (src/lit-html.ts:1362:12)
_$AI (src/async-directive.ts:366:18)
setValue (src/virtualize.ts:139:13)
dispatchEvent (src/Virtualizer.ts:808:23)
2024-04-11 17:02:18.823 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10
TypeError: i is undefined
_keyFunction (src/panels/config/integrations/dialog-add-integration.ts:464:4)
item (src/virtualize.ts:116:53)
r (src/directives/repeat.ts:56:28)
ct (src/directives/repeat.ts:93:52)
update (src/directive.ts:134:16)
_$AS (src/lit-html.ts:1085:23)
S (src/lit-html.ts:1362:12)
_$AI (src/async-directive.ts:366:18)
setValue (src/virtualize.ts:139:13)
dispatchEvent (src/Virtualizer.ts:808:23)
2024-04-11 17:02:19.606 ERROR (MainThread) [frontend.js.latest.202402071] Uncaught error from Firefox 124.0 on Windows 10
TypeError: i is undefined
_keyFunction (src/panels/config/integrations/dialog-add-integration.ts:464:4)
item (src/virtualize.ts:116:53)
r (src/directives/repeat.ts:56:28)
ct (src/directives/repeat.ts:93:52)
update (src/directive.ts:134:16)
_$AS (src/lit-html.ts:1085:23)
S (src/lit-html.ts:1362:12)
_$AI (src/async-directive.ts:366:18)
setValue (src/virtualize.ts:139:13)
dispatchEvent (src/Virtualizer.ts:808:23)
2024-04-11 17:03:21.808 ERROR (MainThread) [custom_components.tapo_control] Failed to establish a new connection
2024-04-11 18:51:09.858 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-12 08:56:52.235 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-12 11:43:21.747 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-12 16:23:17.855 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-12 16:55:53.854 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-12 16:59:48.857 ERROR (MainThread) [custom_components.tapo.coordinators] Error fetching tapo data: Unexpected exception: 
2024-04-12 17:14:10.229 ERROR (MainThread) [custom_components.tapo.config_flow] Failed to setup cannot connect 
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1119, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1101, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1004, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 637, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 677, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.178.82', 80)

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 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 221, in _guess_protocol
    response = await self.get_component_negotiation()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/api/tapo_client.py", line 81, in get_component_negotiation
    return (await self.execute_raw_request(TapoRequest.component_negotiation())).map(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/api/tapo_client.py", line 78, in execute_raw_request
    return (await self._protocol.send_request(request)).map(lambda x: x.result)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/protocol/passthrough_protocol.py", line 41, in send_request
    response = await self._send_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/protocol/passthrough_protocol.py", line 61, in _send_request
    await self._login_with_version(self._credential)
  File "/usr/local/lib/python3.12/site-packages/plugp100/protocol/passthrough_protocol.py", line 80, in _login_with_version
    session_or_error = await self._passthrough.handshake(self._url)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/protocol/securepassthrough_transport.py", line 70, in handshake
    response = await self._http.async_make_post(url, json=request_body)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/common/utils/http_client.py", line 18, in async_make_post
    async with self.session.post(
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1000, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.178.82:80 ssl:default [Connect call failed ('192.168.178.82', 80)]

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 143, in async_step_user
    device_info = await self._async_get_device_info(user_input)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/config_flow.py", line 314, in _async_get_device_info
    raise CannotConnect from error
custom_components.tapo.errors.CannotConnect

`

### Device Firmware

1.3.13

### Integration Version

5.4.17

### Using stream component

Yes

### Does camera work via official integrations?

N/A

### Camera has all attributes filled out in developer tools

No

### HASS Environment

Docker on Raspi

### Search for similar issues

Yes

### Additional information

Aside of these steps no more changes are done in Network, Firewall etc.
tomtpcz commented 2 months ago

I have the same thing now. I was referred to the FAQ. I did everything that was asked but it still doesn't work. Quite an annoying problem.

Výstřižek

JurajNyiri commented 2 months ago

Device Firmware 1.3.13

Please post full firmware version. New firmware might have broken the integration.

JurajNyiri commented 2 months ago

Good news. My camera received this firmware as well, going to test it out.

JurajNyiri commented 2 months ago

I updated my camera C200 v3 to 1.3.13 Build 240327 Rel.63336n(4555) and it works as expected.

Tested also via pytapo.

Screenshot 2024-04-12 at 22 34 06
JurajNyiri commented 2 months ago

Please run following script and post output:

from pytapo import Tapo
import time
from pytapo.version import PYTAPO_VERSION

host = "192.168.100.105" // set to correct local camera ip
password_cloud = "cloud password" //set to correct cloud password

redactInformation = True
tapo = Tapo(
    host,
    "admin",
    password_cloud,
    printDebugInformation=True,
    retryStok=True,
)

print(tapo.getMost())
wavemop commented 2 months ago

Device Firmware 1.3.13

Please post full firmware version. New firmware might have broken the integration.

Version: 1.3.13 Build 240327 Rel.63336n(4555)

wavemop commented 2 months ago

Please run following script and post output:

from pytapo import Tapo
import time
from pytapo.version import PYTAPO_VERSION

host = "192.168.100.105" // set to correct local camera ip
password_cloud = "cloud password" //set to correct cloud password

redactInformation = True
tapo = Tapo(
    host,
    "admin",
    password_cloud,
    printDebugInformation=True,
    retryStok=True,
)

print(tapo.getMost())

Since it is HA container here, I've (for any reasons) got no terminal access to the docker container via portainer to install pytapo !?

JurajNyiri commented 2 months ago

You will need to install it on another machine or computer.

Pihlflykt commented 2 months ago

Having the same problem. All my 9 cameras stopped working a couple of days ago. Firmware version: on the C310 cameras: 1.3.9 on the C200 (hardware 2.0): 1.3.9 on the C200 (hardware 3.0)1.3.13

JurajNyiri commented 2 months ago

For anyone experiencing this issue the instructions to help debug this are above.

Please post output of the script.

tomtpcz commented 2 months ago

Sorry, I don't know if this is correct, I have almost no Python knowledge

C:\Pytapo>custom_test.py Refreshing stok... New request: {'data': {'method': 'login', 'params': {'encrypt_type': '3', 'username': 'admin'}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8'}, 'verify': False} 200 {'error_code': -40413, 'result': {'data': {'code': -40401, 'encrypt_type': ['3'], 'key': 'REDACTED', 'nonce': 'REDACTED', 'device_confirm': 'REDACTED'}}} Connection is secure. New request: {'data': {'method': 'login', 'params': {'cnonce': 'REDACTED', 'encrypt_type': '3', 'username': 'admin'}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8'}, 'verify': False} 200 {'error_code': -40413, 'result': {'data': {'code': -40401, 'encrypt_type': ['3'], 'key': 'REDACTED', 'nonce': 'REDACTED', 'device_confirm': 'REDACTED'}}} Status code: 200 Processing secure response. Validating device confirm. Incorrect device_confirm value, retrying: 1/2. Refreshing stok... Connection is secure. New request: {'data': {'method': 'login', 'params': {'cnonce': 'REDACTED', 'encrypt_type': '3', 'username': 'admin'}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8'}, 'verify': False} 200 {'error_code': -40413, 'result': {'data': {'code': -40401, 'encrypt_type': ['3'], 'key': 'REDACTED', 'nonce': 'REDACTED', 'device_confirm': 'REDACTED'}}} Status code: 200 Processing secure response. Validating device confirm. Incorrect device_confirm value, retrying: 2/2. Refreshing stok... Connection is secure. New request: {'data': {'method': 'login', 'params': {'cnonce': 'REDACTED', 'encrypt_type': '3', 'username': 'admin'}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8'}, 'verify': False} 200 {'error_code': -40413, 'result': {'data': {'code': -40401, 'encrypt_type': ['3'], 'key': 'REDACTED', 'nonce': 'REDACTED', 'device_confirm': 'REDACTED'}}} Status code: 200 Processing secure response. Validating device confirm. Incorrect device_confirm value, raising Exception. Traceback (most recent call last): File "C:\Pytapo\custom_test.py", line 11, in tapo = Tapo( ^^^^^ File "C:\Pytapo\pytapo__init.py", line 86, in init self.basicInfo = self.getBasicInfo() ^^^^^^^^^^^^^^^^^^^ File "C:\Pytapo\pytapo\init.py", line 1009, in getBasicInfo return self.executeFunction( ^^^^^^^^^^^^^^^^^^^^^ File "C:\Pytapo\pytapo\init.py", line 491, in executeFunction data = self.performRequest( ^^^^^^^^^^^^^^^^^^^^ File "C:\Pytapo\pytapo\init.py", line 530, in performRequest self.ensureAuthenticated() File "C:\Pytapo\pytapo\init.py", line 108, in ensureAuthenticated return self.refreshStok() ^^^^^^^^^^^^^^^^^^ File "C:\Pytapo\pytapo\init.py", line 418, in refreshStok return self.refreshStok(loginRetryCount) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Pytapo\pytapo\init.py", line 418, in refreshStok return self.refreshStok(loginRetryCount) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Pytapo\pytapo\init__.py", line 423, in refreshStok raise Exception("Invalid authentication data") Exception: Invalid authentication data

JurajNyiri commented 2 months ago

It looks like the authorisation model and flow has been changed. Based on the reports it affects only some users and more older firmwares than the latest ones.

I have been in touch with tplink regarding a vulnerability I reported in the past and this might be caused by the fix they implemented for it and seem to be rolling out slowly.

I am currently waiting for the information from them on how can this be fixed and a permission to connect to cloud if needed. I will also unblock one of my cameras to the internet so that hopefully this update gets pushed to me as well and I can test / debug.

At this point, if you were affected and you wish to use this integration further I would suggest rolling back the firmware and factory resetting the camera. Or ideally, help me fix this by investigating on what has changed if you have the knowledge.

JurajNyiri commented 2 months ago

Users that were affected: What application are you using? iOS or Android?

tomtpcz commented 2 months ago

Camera C200 hw 3.0 Was carried out:

Same for C510W and C110 camera model

Everything is fine in the TAPO app, the password works. Android app version 3.2.976

JurajNyiri commented 2 months ago

Moving to https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues/551 please continue discussion there.