Skip to content

feat: discover new Tuya devices on the LAN#5605

Merged
make-all merged 1 commit into
make-all:mainfrom
neneonline:feat/discovery-new-devices
Jul 18, 2026
Merged

feat: discover new Tuya devices on the LAN#5605
make-all merged 1 commit into
make-all:mainfrom
neneonline:feat/discovery-new-devices

Conversation

@neneonline

Copy link
Copy Markdown
Contributor

Third increment for #5526 (follow-up you invited when closing it), building on the merged #5532 and #5573. This adds the new-device discovery piece.

What it does

  • Turns the periodic (~10 min) pass into a single tinytuya.deviceScan that does two things from one scan:
    1. Configured devices — the product-id check from feat: log unmatched product ids for configured devices #5573 (WARN once/device/run when the reported productKey isn't listed in the config's products:), now fed by the shared scan instead of a per-device find_device.
    2. Unconfigured devices — raises an integration_discovery flow so each unknown Tuya device on the LAN surfaces in Home Assistant for one-click setup.
  • Adds ConfigFlowHandler.async_step_integration_discovery: it sets the unique id to the device's gwId, aborts if already configured or ignored, and reuses the existing manual-setup prefill (id / ip / version from the scan; the user still supplies the local key). The built-in per-unique_id ignore therefore works out of the box.
  • The fast 60 s IP-rediscovery sweep from feat: auto-update device IP via background LAN rediscovery #5532 is untouched; both tasks share a scan guard so they never run concurrently.

Notes

Tests

tests/test_discovery.py: product-id warn (fed by the scan), new-device flow raised for unconfigured devices, configured devices skipped, deduped per run, empty scan is a no-op. tests/test_config_flow.py: discovery step advances to the local form; aborts when already configured. uv run pytest (403 passed) and ruff check / ruff format --check green.

Third increment for make-all#5526. Extends the discovery service's periodic scan to a
single tinytuya.deviceScan that (a) checks product ids for configured devices
(folding in the per-device check from make-all#5573) and (b) raises an
integration_discovery flow for each unconfigured device found, so it surfaces
in Home Assistant for one-click setup with the built-in per-unique_id ignore.

Adds ConfigFlowHandler.async_step_integration_discovery, which reuses the
existing manual-setup prefill (id/ip/version from discovery; the user supplies
the local key) and aborts if the device is already configured or ignored.
Keyed on gwId. The fast IP-rediscovery sweep from make-all#5532 is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@make-all

Copy link
Copy Markdown
Owner

Thanks, this is a clean addition, there doesn't seem to be any risk of regression to other functionality, so should be OK to go.

@make-all
make-all merged commit cafa367 into make-all:main Jul 18, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Tuya Local Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants