| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
|
||
|
|
||
| def _md5_hex(value: str) -> str: | ||
| return hashlib.md5(value.encode()).hexdigest() # noqa: S324 |
| def _digest_password(cloud_password: str, encrypt_type: str | None) -> str: | ||
| """Return the camera media password derived from the cloud password.""" | ||
| hash_func = hashlib.sha256 if encrypt_type == "3" else hashlib.md5 | ||
| return hash_func(cloud_password.encode()).hexdigest().upper() |
| [ | ||
| pytest.param( | ||
| ', encrypt_type="3"', | ||
| hashlib.sha256(PASSWORD.encode()).hexdigest().upper(), |
| ), | ||
| pytest.param( | ||
| "", | ||
| hashlib.md5(PASSWORD.encode()).hexdigest().upper(), # noqa: S324 |
| ), | ||
| pytest.param( | ||
| ', encrypt_type="2"', | ||
| hashlib.md5(PASSWORD.encode()).hexdigest().upper(), # noqa: S324 |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## master #1784 +/- ##
==========================================
+ Coverage 93.41% 93.58% +0.17%
==========================================
Files 159 161 +2
Lines 10113 10390 +277
Branches 1043 1076 +33
==========================================
+ Hits 9447 9724 +277
Misses 472 472
Partials 194 194 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Adds speaker-only talkback for Tapo cameras, the first step proposed in #1763.
audio_stream must already be encoded as G.711 A-law (PCMA), 8 kHz, mono, raw bytes (8000 bytes = 1 s).
python-kasa does no decoding, resampling or transcoding; the caller (e.g. Home Assistant with FFmpeg)
produces the camera-compatible audio. There are no new dependencies.
The call returns when the input is exhausted and its playback time has elapsed. Cancelling the task stops
playback and closes the session. Only one playback per camera can be active; a second call raises
KasaException. The camera never acknowledges playback, so returning does not guarantee the audio was heard.
Implementation
The camera media server is a second connection, separate from the management API, so it is not a
BaseTransport:
from the challenge's encrypt_type
0x90, PID 0x100)
handling. It rejects hub children, devices without the audio component, and missing credentials
(AuthenticationError).
Notes on the sending side:
absolute monotonic schedule, independent of the caller's chunk sizes. The schedule restarts instead of
bursting if the producer stalls.
rate.
The protocol follows go2rtc's pkg/tapo and was
checked against a C200. Microphone/preview, codec negotiation and other codecs are out of scope.
Tests
Tests are deterministic, with no sockets and a fake clock. They cover:
The generated stream was also checked with ffprobe.
Hardware validation
Tested on a Tapo C200 (HW 1.0, FW 1.3.17 Build 260112) over Wi-Fi (RSSI -55 dBm), client wired.
Audio was raw PCMA 8 kHz mono, generated tones and a macOS TTS sample converted with
ffmpeg -ar 8000 -ac 1 -f alaw.
Observations:
previous one ended.
camera-side TCP latency spikes (median RTT ~10 ms, peaks ~330–380 ms, no retransmissions; ~4 spikes per
10 s idle, ~9 with live view).
burst caused retransmissions), so strict real-time pacing is kept.
@rytilahti I haven't tested on a TC65 yet. If you can try it with yours, that would help; a small test script
is available on request.
Part of #1763.
Development of this PR was driven by Claude AI. I reviewed the changes and validated them on the hardware above.