Skip to content

Migrate Aqara pet feeder ACN001 to quirks v2 - #5296

Open
iamjoshk wants to merge 6 commits into
zigpy:devfrom
iamjoshk:iamjoshk-feeder_acn001-v2-migration
Open

Migrate Aqara pet feeder ACN001 to quirks v2#5296
iamjoshk wants to merge 6 commits into
zigpy:devfrom
iamjoshk:iamjoshk-feeder_acn001-v2-migration

Conversation

@iamjoshk

@iamjoshk iamjoshk commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Proposed change

PR for the migration to quirks v2 for the Aqara Pet Feeder ACN001.
This will also allow for the feeder entities in ZHA to be removed, in PR zigpy/zha#883
Split from this PR: #5294

Additional information

This prepares for changes in ZHA mentioned here: zigpy/zha#705

Device diagnostics

{
  "node_descriptor": {
    "logical_type": 1,
    "complex_descriptor_available": 0,
    "user_descriptor_available": 0,
    "reserved": 0,
    "aps_flags": 0,
    "frequency_band": 8,
    "mac_capability_flags": 142,
    "manufacturer_code": 4447,
    "maximum_buffer_size": 82,
    "maximum_incoming_transfer_size": 255,
    "server_mask": 11264,
    "maximum_outgoing_transfer_size": 255,
    "descriptor_capability_field": 0
  },
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x0002",
      "input_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0xfcc0"
      ],
      "output_clusters": [
        "0x0003",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "Aqara",
  "model": "aqara.feeder.acn001",
  "class": "feeder_acn001_v2_base:(None / aqara.feeder.acn001)"
}

Updated with the diagnostics from the existing quirk:
zha-diagnostics-Aqara_aqara.feeder.acn001.json

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works
  • Device diagnostics data has been attached

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.60%. Comparing base (6a3822c) to head (8764556).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #5296      +/-   ##
==========================================
- Coverage   92.60%   92.60%   -0.01%     
==========================================
  Files         424      424              
  Lines       14667    14665       -2     
==========================================
- Hits        13582    13580       -2     
  Misses       1085     1085              

☔ 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.

@iamjoshk
iamjoshk marked this pull request as ready for review September 1, 2026 21:21
Copilot AI lite review requested due to automatic review settings September 1, 2026 21:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The migration drops the previously injected Time cluster behavior (and needs corresponding v2 handling), which risks a functional regression for devices relying on time sync for scheduling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR migrates the Aqara Pet Feeder ACN001 quirk from a legacy v1 CustomDevice implementation to a quirks v2 QuirkBuilder definition in zhaquirks, and updates the Xiaomi test suite to construct the device using the v2 quirk fixture.

Changes:

  • Replace the v1 AqaraFeederAcn001 device definition with a v2 QuirkBuilder registration and explicit entity exposures.
  • Update feeder enums to include Schedule and rename RemoteHomeAssistant.
  • Adjust tests to use zigpy_device_from_v2_quirk and validate the updated enum name.
File summaries
File Description
zhaquirks/xiaomi/aqara/feeder_acn001.py Migrates the feeder to quirks v2 and defines exposed entities via QuirkBuilder.
tests/test_xiaomi.py Updates tests to instantiate the feeder via v2 quirk construction and align expected enum values.
Review details

Suppressed comments (1)

zhaquirks/xiaomi/aqara/feeder_acn001.py:273

  • This migration drops the previously injected Time cluster (the old v1 replacement explicitly added Time.cluster_id). If the feeder relies on the Time cluster for time sync (important for onboard scheduling), this will be a behavioral regression after migrating to v2.
    .friendly_name(manufacturer="Aqara", model="aqara.feeder.acn001")
    .removes(OnOff.cluster_id)
    .replaces(OppleCluster)
    .enum(
        attribute_name=OppleCluster.AttributeDefs.last_feeding_source.name,
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread zhaquirks/xiaomi/aqara/feeder_acn001.py
Comment thread zhaquirks/xiaomi/aqara/feeder_acn001.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The v2 migration is consistent with existing quirks v2 patterns and the updated tests cover the changed behavior and API surface used by this quirk.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@zigpy-review-bot zigpy-review-bot added bot: needs changes PR needs changes per LLM bot: 2.0 migration done PR is on the ZHA/quirks 2.0.0 API (migrated or written for 2.0) per LLM enhancement Improve an existing quirk Aqara Request/PR regarding an Aqara or Xiaomi device bot: needs maintainer PR does something questionable that needs a maintainer decision per LLM labels Sep 1, 2026
Copilot AI review requested due to automatic review settings September 3, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated tests don’t currently exercise the real-world “manufacturer is missing” pairing scenario that the v2 quirk explicitly relies on.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

tests/test_xiaomi.py:1230

  • Same as above: this test uses manufacturer="Aqara", but the device/quirk pairing scenario described in the quirk is that manufacturer is missing during interview. Use None here to ensure quirk resolution continues to work in that case.
    device = zigpy_device_from_v2_quirk(
        "Aqara",
        "aqara.feeder.acn001",
        cluster_ids={
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread tests/test_xiaomi.py
Copilot AI review requested due to automatic review settings September 3, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A new v2 sensor is declared with TOTAL_INCREASING but without a unit/device_class, which is inconsistent with existing usage and may cause HA statistics/validation issues.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

.sensor(
attribute_name=OppleCluster.AttributeDefs.portions_dispensed.name,
cluster_id=OppleCluster.cluster_id,
state_class=SensorStateClass.TOTAL_INCREASING,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

state_class=SensorStateClass.TOTAL_INCREASING for portions_dispensed and weight_dispensed matches the existing legacy entities in ZHA.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thinking about this, I could add unit="portions" and keep the legacy state_class=SensorStateClass.TOTAL_INCREASING

    .sensor(
        attribute_name=OppleCluster.AttributeDefs.portions_dispensed.name,
        cluster_id=OppleCluster.cluster_id,
        state_class=SensorStateClass.TOTAL_INCREASING,
        unit="portions",
        unique_id_suffix=f"{OppleCluster.cluster_id}-portions_dispensed",
        translation_key="portions_dispensed_today",
        fallback_name="Portions dispensed today",
    )

@inomdzhon

Copy link
Copy Markdown

Wait it 🥹 Thanks 🙏🙏🙏

Copilot AI review requested due to automatic review settings September 7, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The migration to quirks v2 and the corresponding test updates are coherent, self-contained, and consistent with the PR’s stated goal.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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

Labels

Aqara Request/PR regarding an Aqara or Xiaomi device bot: needs changes PR needs changes per LLM bot: needs maintainer PR does something questionable that needs a maintainer decision per LLM bot: 2.0 migration done PR is on the ZHA/quirks 2.0.0 API (migrated or written for 2.0) per LLM enhancement Improve an existing quirk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants