Remove Aqara motion detection_interval sync and read detection_interval after pairing

Open
#985 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend, testing

Research direction

Read zha/application/platforms/virtual.py and inspect AqaraMotionDetectionIntervalSync, AqaraMotionAc02Init, and AqaraMotionAgl04Init. Check the minimum supported zha-quirks version and the related issue #782 before changing startup behavior. Add or update tests to verify detection_interval is cached after pairing and no write to ias_zone.reset_s occurs.

Written by the indexing model from the issue text.

Description

code quality quirks
Problem

zigpy/zha-device-handlers#5067 (merged) lets the Aqara motion quirks (lumi.motion.ac02 and lumi.motion.agl04) read detection_interval from the Opple cluster cache themselves via an overridable reset_after property, and removes the quirk-side write_attributes overrides that pushed the value into ias_zone.reset_s. ZHA still carries the old startup workaround: AqaraMotionDetectionIntervalSync in zha/application/platforms/virtual.py copies detection_interval into ias_zone.reset_s on startup, which the quirks no longer need.

Proposed fix
  • Remove AqaraMotionDetectionIntervalSync once the minimum zha-quirks version contains #5067 (otherwise older quirks lose the behaviour).
  • Make sure detection_interval is read from the device once after pairing. Both AqaraMotionAc02Init and AqaraMotionAgl04Init currently declare it with read_on_startup=False, so the cache can stay empty until the number entity is used and the quirk falls back to its static reset_s (30 s for ac02, 60 s for agl04). Either read it once on join, or let this happen through quirks v2 attribute config.
  • Tests for the above (no ias_zone.reset_s write, detection_interval present in the cache after joining).
Context

Related: zigpy/zha#782, which touches the same virtual entities, so this is best done after it lands. Quirk-side follow-ups are tracked in the linked zha-device-handlers issue.

Dominant language
Python
Stars
96
Forks
84
Avg merge
2d 4h
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zigpy/zha

All issues in zigpy/zha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.