Skip to content

feat: log unmatched product ids for configured devices#5573

Merged
make-all merged 1 commit into
make-all:mainfrom
neneonline:feat/discovery-productkey-log
Jul 16, 2026
Merged

feat: log unmatched product ids for configured devices#5573
make-all merged 1 commit into
make-all:mainfrom
neneonline:feat/discovery-productkey-log

Conversation

@neneonline

Copy link
Copy Markdown
Contributor

Second increment for #5526, building on the merged #5532.

Implements the issue item: "logging of product ids for already configured devices where the config file does not have a match (to allow improvement of configs)."

What it does

  • Adds a periodic (~10 min) product scan to the discovery service. For each configured device it looks up the current product_id via tinytuya.find_device(...) (the same call feat: auto-update device IP via background LAN rediscovery #5532 uses for IP rediscovery). If that id is not listed in the device's config file under products:, it logs one WARNING per device per HA start:
    <device>: device product id <id> is not listed in its config (<config>); please report it so support can be improved
  • WARNING level so it's visible under HA's default logging; deduped per device so it isn't noisy.
  • Adds TuyaDeviceConfig.matches_product(product_id).
  • The fast 60 s IP-rediscovery sweep from feat: auto-update device IP via background LAN rediscovery #5532 is untouched; the two share a scan guard so they never run concurrently.

Scope / follow-ups

Coverage comes from the periodic scan (first pass ~10 min after start). The remaining #5526 items (a deviceScan-based pass that surfaces unknown devices as discovery notifications with an ignore option, and a startup trigger) are the next PR. Kept separate to keep this one small and reviewable.

Tests

tests/test_discovery.py adds cases for: warn-once on an unmatched product id (and no repeat on a second scan), silence when it matches, skip when no product id is reported, and graceful handling of a missing config. uv run pytest (397 passed) and ruff check / ruff format --check are green.

Second increment for make-all#5526 (builds on make-all#5532). Adds a periodic (~10 min)
product scan to the discovery service: for each configured device it looks
up the product id via tinytuya.find_device and, when that id is not listed
in the device's config file (products:), logs a WARNING once per device per
HA start so the config can be improved. Adds TuyaDeviceConfig.matches_product()
and tests. The fast IP-rediscovery sweep from make-all#5532 is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-project-automation github-project-automation Bot moved this to 👀 In review in Tuya Local Jul 12, 2026
@make-all
make-all merged commit 92c5adb into make-all:main Jul 16, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Tuya Local Jul 16, 2026
make-all pushed a commit that referenced this pull request Jul 18, 2026
Third increment for #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 #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 #5532 is unchanged.

Co-authored-by: neneonline <2820882+neneonline@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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