Skip to content

Remove Parkside valve entities duplicated by its quirk - #1040

Draft
zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/remove-parkside-valve-duplicate-entities
Draft

zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/remove-parkside-valve-duplicate-entities

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Summary

Severity: low (the audit's estimate)

The Lidl Parkside smart watering timer (_TZE200_htnnfasr / TS0601) gets its "Frost lock reset" button twice, and its "Timer duration" number twice once the timer duration has been reported. ZHA's device-specific FrostLockResetButton and TimerDurationMinutes date from before the valve's quirk exposed entities; since its conversion to a v2 quirk in zigpy/zha-device-handlers#3650 the quirk exposes the same button and number on the same attributes, under different unique IDs. This removes ZHA's copies and keeps the quirk's, the way #883 handled the Aqara pet feeder.

Existing installs keep the quirk's button and number (same names); ZHA's copies (unique ID suffixes 61184-reset_frost_lock and 61184-timer_duration) become orphaned in Home Assistant. Home Assistant's reset_frost_lock button translation is unused afterwards and can be dropped there.

Changes

  • zha/application/platforms/button/__init__.py: remove FrostLockResetButton (and the now unused TUYA_MANUFACTURER_CLUSTER import).
  • zha/application/platforms/number/__init__.py: remove TimerDurationMinutes (and the now unused import).
  • tests/test_button.py: test_frost_unlock (which already joins the valve with its v2 quirk) now checks that exactly one button writes frost_lock_reset, and presses that one.
  • tests/test_number.py: new test_parkside_valve_timer_duration_not_duplicated, which caches a timer_duration value before the join and checks that exactly one number entity is created for it.

Testing

  • Both tests fail at 2da1a5b with assert 2 == 1 (two buttons, two numbers) and pass with this change.
  • Full test suite: 1782 passed. pre-commit (codespell, ruff check, ruff format, mypy) clean on the changed files.

Opened by the scheduled code audit; not requested by a maintainer.

Fixes #1039

The Lidl Parkside watering timer (_TZE200_htnnfasr) has a v2 quirk that
exposes a "Frost lock reset" button and a "Timer duration" number. ZHA's
device-specific FrostLockResetButton and TimerDurationMinutes match the
same Tuya cluster and write the same attributes, so the device ends up
with two buttons and, once the timer duration has been reported, two
numbers. Drop ZHA's copies and keep the quirk's.
@zigpy-review-bot zigpy-review-bot added bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bugfix This PR fixes a bug bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) labels Nov 21, 2026
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (2da1a5b) to head (503bd83).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1040      +/-   ##
==========================================
- Coverage   97.48%   97.48%   -0.01%     
==========================================
  Files          61       61              
  Lines       10870    10848      -22     
==========================================
- Hits        10597    10575      -22     
  Misses        273      273              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zigpy-review-bot zigpy-review-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would-be verdict: ready to merge. No blockers or must-address items. This is a COMMENT because it is the bot's own PR, and the PR is still a draft. Two notes and one related PR below.

  • Behaviour changes for existing installs, beyond the orphaned entities the body names: the remaining "Frost lock reset" button has no device class (ZHA's copy had restart, so its icon changes), and the remaining "Timer duration" number starts at 1 minute instead of 0. Zigbee2MQTT exposes the same 1–599 minute range for this valve's auto-off timer, so 0 was never a useful setting. This is worth a line in the release note, not a code change.
  • Optional follow-up: ZHA's TimeLeft sensor for this valve (zha/application/platforms/sensor/__init__.py, _attribute_name = "timer_time_left") is dead code. The v2 quirk has no timer_time_left attribute, so the sensor is never created; the quirk's own "Time left" sensor replaced it. Joining the valve with the installed quirk confirms this. It can go in this PR or in a separate cleanup; #1039 left it out on purpose.
  • Related: #1037, also a draft from the code audit, fixes the polarity of ZHA's FrostLock binary sensor on the same valve. The two PRs change different files and don't conflict. If maintainers want this PR's direction (the quirk owns the valve's entities), the alternative named in #1037 fits it: move the read-only frost lock sensor into the quirk and drop ZHA's copy. That choice is a maintainer's call.
Verified (6 checks)
  • I joined the valve with the real v2 quirk from zha-quirks 2.4.1, at dev 2da1a5b and at the head 503bd83. On dev, the device gets two frost lock reset buttons (FrostLockResetButton plus the quirk's WriteAttributeButton). With timer_duration cached, it also gets two timer duration numbers (TimerDurationMinutes 0–599 plus the quirk's 1–599). Without a cached value, ZHA's number isn't created, as the body says. At the head, the device gets one of each.
  • Both changed tests fail on dev with assert 2 == 1 and pass at the head, so they actually test the duplication.
  • At the head: the full suite passes (1782 tests), mypy zha/ reports no issues, pre-commit is clean on the changed files, and CI is green.
  • Nothing else in zha or zha-quirks references FrostLockResetButton, TimerDurationMinutes or the reset_frost_lock translation key. TUYA_MANUFACTURER_CLUSTER is still used by other platforms. pyproject.toml requires zha-quirks>=2.4.0, which ships the v2 quirk.
  • Home Assistant's ZHA strings.json has frost_lock_reset ("Frost lock reset") and timer_duration ("Timer duration"), so the remaining entities keep their names. reset_frost_lock is unused once this merges.
  • A Copilot CLI pass raised one point, the 0 → 1 minimum. I checked it against Zigbee2MQTT's converter and folded it into the first note above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parkside water valve shows its frost lock reset button and timer duration number twice

1 participant