feat: discover new Tuya devices on the LAN#5605
Merged
Merged
Conversation
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>
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. |
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.
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
tinytuya.deviceScanthat does two things from one scan:productKeyisn't listed in the config'sproducts:), now fed by the shared scan instead of a per-devicefind_device.integration_discoveryflow so each unknown Tuya device on the LAN surfaces in Home Assistant for one-click setup.ConfigFlowHandler.async_step_integration_discovery: it sets the unique id to the device'sgwId, 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_idignore therefore works out of the box.Notes
SOURCE_INTEGRATION_DISCOVERY, so it uses the LAN scan (not DHCP/zeroconf), consistent with the active-only direction agreed on Background LAN rediscovery: auto-update a device's IP after a DHCP change #5526.deviceScanfrom my side (needs the LAN), but it rides on the same scanner already proven in production by feat: auto-update device IP via background LAN rediscovery #5532/feat: log unmatched product ids for configured devices #5573; the new HA glue (flow init + discovery step) is unit-tested. Happy to adjust the discovery UX (e.g. a confirm step, or a startup trigger) to your preference.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) andruff check/ruff format --checkgreen.