Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the camera path of the branch work against a real camera on the new firmware, a Tapo C510W 2.0 (fw 1.3.4 Build 260523). Three things were in the way:
{"sub_method":"discover"}with-40209, soTpapEncryptionSession._discover()raised before any login. Cameras announce TPAP in the UDP discovery instead (encrypt_type: ["4"]plustpap: {pake: [2], tls: 1, noc: 1, port: 443}), so for the camera families the session now falls back to those values when the in-band discover fails or has notpapobject: password login, TLS on the management port, no DAC. Other families keep raising as before.httpsset the transport defaulted to 4433; cameras listen on 443.encrypt_info.sym_schm: "AES"for these cameras. I did not want to route every camera that advertises["4"]to TPAP, because the C101 fw 1.4.3 fixture in the repo advertises exactly that and was captured over the AES login, and my own C510W accepts the AES login again once Third-Party Compatibility is switched on in the Tapo app. So insteadSslAesTransportnow attaches the error code to the handshake1 failure,-40211gets a name (MISSING_NECESSARY_PARAMS, the name the Tapo app uses), and_connectretries a camera overSmartCamProtocol+TpapTransportwhen the AES login fails with that code, updatingconfig.connection_type.encryption_typeso Home Assistant stores the new transport. Any other authentication error is raised as before.Live result on the C510W (DeviceConfig with
SMART.IPCAMERA,TPAP,https=True, useradmin, TP-Link account password): handshake in 5 s (about 4 of them spent on the refused in-band discover),update()returns the model, firmware, 9 modules and 15 features (motion / person / tamper detection, LED, pan/tilt, RSSI, device time), and a secondupdate()on the same session works. The-40211switch itself is covered by unit tests only: my camera no longer refuses the AES login since compatibility mode is on, so if someone in the linked Home Assistant threads still gets-40211, that is the case worth trying.Tests: 3596 pass locally, new ones cover the discover fallback (refused and missing
tpapobject), the camera default port, the handshake1 error code, and the_connectfallback (taken on-40211, not taken on other auth errors). Ruff and mypy are clean on the touched files.The protocol details behind this (login,
/dsframing, error codes) are written up at https://github.com/freeKC/tapo-v4-protocol in case that helps the review.