Repository navigation
feat(camera): answer the robot's fwapi/createca TURN request for live video (#18) - #144
Conversation
|
Hey @cptntrps This looks good to me! I'm going to merge it in and will do some work on top of it I will make it work with the HA addon, update onboarding, and make some other small tweaks. TYSM! |
… video (Python-roborock#18) When the app requests a camera preview, the firmware fetches a TURN/STUN config from a fwapi endpoint before starting the WebRTC session. The host is derived from the onboarding region as region[:15] + "iot.roborock.com", so a short region resolves it to this server. Without a handler the request hit the catchall and the robot returned -10012 / "request turnserver failed". This adds a routes/fw/createca.py handler that answers with a plain-JSON TURN credential body (both legacy user/pwd and ICE username/credential aliases), driven by a new optional [turn] config section. With [turn].enabled = false (the default) the request still falls through to the catchall, so there is no behaviour change for anyone not running a TURN server. Verified end to end on a Saros 10R (roborock.vacuum.a144): with coturn configured, the robot completes the WebRTC handshake and a go2rtc roborock:// consumer receives frames. The createca shape and the region-host rule look like general firmware behaviour; the two-key activation needed to arm the camera is model-specific and documented in docs/camera.md. - config: [turn] section (enabled/host/port/username/password/realm/ttl) - route: routes/fw/createca.py + registration in endpoint_rules.py - context: TURN fields on ServerContext (default off) - docs: docs/camera.md; known_limitations updated; config.example.toml - tests: tests/test_fw_createca.py (payload shape, path variants, disabled fallback)
|
Thanks a lot @Lash-L, I'm really happy to contribute to this project! One small request before you merge: the commit on this PR has a placeholder author email ( Is it OK if I force-push the branch with only the author fixed (to I'll wait for your OK before I push anything. |
|
Yes, that is fine! @cptntrps Thanks for asking |
9086b9b to
0f1df07
Compare
- Keep package and add-on versions at 1.2.1 and leave the unused beta add-on untouched; version bumps and image publishing belong in a release PR. - Drop the never-released HA turn_enabled option and show turn_mode (default disabled) in the add-on options. config.toml still reads the [turn] enabled = true form from #144 as external mode. - Lowercase turn.mode before choosing the provided-mode username default. - createca docstring and known limitations now describe the model-specific bootstrap host (a144 country_domain, a87 token.r) instead of a single rule. - Remove stray blank lines and a placeholder-free f-string.
* feat(turn): add Home Assistant add-on TURN options and onboarding region notices * fix(ha,gui): avoid reserving unused turn ports in addon and wire camera_domain in web ui * fix(onboarding,addon): validate camera domain hostname format and expose turn_ttl in addon schema * fix(onboarding): warn when 15-character region lacks trailing slash for camera bootstrap * feat(camera): provide TURN relay and validate model-specific bootstrap * style: remove trailing blank lines in camera configuration * chore(camera): drop release bumps and tidy TURN follow-ups from #144 - Keep package and add-on versions at 1.2.1 and leave the unused beta add-on untouched; version bumps and image publishing belong in a release PR. - Drop the never-released HA turn_enabled option and show turn_mode (default disabled) in the add-on options. config.toml still reads the [turn] enabled = true form from #144 as external mode. - Lowercase turn.mode before choosing the provided-mode username default. - createca docstring and known limitations now describe the model-specific bootstrap host (a144 country_domain, a87 token.r) instead of a single rule. - Remove stray blank lines and a placeholder-free f-string.
Follows up on #18, where @Lash-L invited a PR after we both reached the same conclusion from the firmware.
What this does
When the app requests a camera preview, the firmware fetches a TURN/STUN configuration from a fwapi endpoint (
.../fwapi/createca) before starting the WebRTC session. With no handler the request fell through to the catchall, so the robot never got TURN credentials andstart_camera_previewreturned-10012 / request turnserver failed.This adds a
routes/fw/createca.pyhandler that answers with a plain-JSON TURN credential body, driven by a new optional[turn]config section.Behaviour / safety
[turn].enabled = false(the default) the request still falls through to the catchall, so there is no behaviour change for anyone not running a TURN server.user/pwdnames (indata) and the ICE-styleusername/credentialnames (inresult), so either firmware parser is satisfied.Region requirement
As you noted in #18, the firmware derives the fwapi host from
region[:15] + "iot.roborock.com", so the camera needs an onboarding region of 14 characters or fewer plus a trailing/for the createca host to resolve to the server. This is documented indocs/camera.md; the onboarding UI/CLI warning you mentioned is a natural companion on your side.Verification
Verified end to end on a Saros 10R (
roborock.vacuum.a144, FCC/US firmware): with coturn configured the robot completes the WebRTC handshake and a go2rtcroborock://consumer receives frames. Thecreatecashape and the region-host rule look like general firmware behaviour; the two-key activation needed to arm the camera is model-specific and documented.Changes
config.py:[turn]section (enabled/host/port/username/password/realm/ttl)routes/fw/createca.py+ registration inendpoint_rules.pyServerContext: TURN fields (default off)docs/camera.md,known_limitations.md,config.example.tomltests/test_fw_createca.py(payload shape, path variants, disabled fallback)Full suite: 298 passed locally.
Happy to adjust naming/placement or split anything out.