Skip to content

Conversation

@cl445
Copy link

@cl445 cl445 commented Jan 12, 2026

Summary

Removes legacy hardcoded entity definitions for the Aqara E1 TRV (lumi.airrtc.agl001).

The device now has a proper quirk in zha-device-handlers that defines all necessary entities using the quirks v2 API (see zigpy/zha-device-handlers#4604).

Problem

These legacy definitions create duplicate entities alongside the quirk-defined ones:

  • Legacy entities have translated names (e.g., "Kindersicherung", "Fenstererkennung")
  • Quirk entities have English names (e.g., "Child lock", "Window detection")

This confuses users who see both sets of entities for the same functionality.

Changes

Removed from manufacturerspecific.py:

  • ZCL_INIT_ATTRS block for lumi.airrtc.agl001 in OppleRemoteClusterHandler

Removed from platform files:

File Removed Classes
binary_sensor/__init__.py AqaraThermostatWindowOpen, AqaraThermostatValveAlarm, AqaraThermostatCalibrated, AqaraThermostatExternalSensor
switch.py AqaraThermostatWindowDetection, AqaraThermostatValveDetection, AqaraThermostatChildLock
select.py AqaraThermostatPresetMode (enum), AqaraThermostatPreset
number/__init__.py AqaraThermostatAwayTemp

Total: 128 lines removed

Test Plan

Related

Thanks to @TheJulianJES for explaining that ZCL_INIT_ATTRS alone doesn't create entities - the actual entity classes in platform files needed to be removed as well!

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (37d2efb) to head (01cdc36).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #621      +/-   ##
==========================================
- Coverage   97.01%   97.00%   -0.02%     
==========================================
  Files          63       63              
  Lines       10569    10508      -61     
==========================================
- Hits        10254    10193      -61     
  Misses        315      315              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

This only initializes the attributes during pairing/reconfiguration for ZHA entities. (This is automatically done by entities defined with v2 quirks.)

The ZHA entities themselves are defined in the relevant ZHA platforms. Search the repo for the model string (here). They need to be removed from there.

Also, we should set the unique_id_suffix for the v2 quirk defined entities accordingly to match what the ZHA entities auto-generated. It should be something like this: 1-64704-child_lock (endpoint id + cluster id + ZHA unique id suffix).
Otherwise, users would see new entities and we'd break old ones. We can't do that.

@cl445
Copy link
Author

cl445 commented Jan 12, 2026

Thanks for the detailed explanation @TheJulianJES! You're absolutely right - I misunderstood where the actual entity definitions come from.

I've now added unique_id_suffix to all entity definitions in the v2 quirk (zigpy/zha-device-handlers#4604) to match the legacy entity IDs:

  • Switches: child_lock, window_detection, valve_detection, schedule
  • Binary sensors: valve_alarm, window_open, calibrated
  • Enums: preset, sensor
  • Number: away_preset_temperature

This should ensure that the quirk entities "take over" the existing legacy entity IDs, preventing duplicates and preserving user automations/dashboards.

Given this approach, is this PR (#621) still needed? Or would the unique_id_suffix solution in the quirk be sufficient to handle the migration?

@TheJulianJES
Copy link
Contributor

The ZHA entities can be removed if they're all properly replaced by the quirks entities. Refer to my message above on what else needs to be done in this PR:

The ZHA entities themselves are defined in the relevant ZHA platforms. Search the repo for the model string here. They need to be removed from there.

The Aqara E1 TRV (lumi.airrtc.agl001) now has a proper quirk in
zha-device-handlers that defines all necessary entities using the
quirks v2 API.

This PR removes:
- ZCL_INIT_ATTRS from OppleRemoteClusterHandler (manufacturerspecific.py)
- Legacy entity classes from platform files:
  - binary_sensor: WindowOpen, ValveAlarm, Calibrated, ExternalSensor
  - switch: WindowDetection, ValveDetection, ChildLock
  - select: ThermostatPreset (and PresetMode enum)
  - number: AwayTemp

These legacy definitions create duplicate entities alongside the
quirk-defined ones, confusing users with both legacy (translated)
and quirk (English) entity names.

Removing these eliminates duplicates once the improved quirk
(zigpy/zha-device-handlers#4604) is merged.

Closes zigpy#620
@cl445 cl445 force-pushed the remove-legacy-agl001-attrs branch from c7835d0 to 01cdc36 Compare January 12, 2026 22:03
@cl445
Copy link
Author

cl445 commented Jan 12, 2026

I've expanded this PR to also remove the legacy entity class definitions from the platform files:

Removed:

  • binary_sensor/__init__.py: 4 classes (WindowOpen, ValveAlarm, Calibrated, ExternalSensor)
  • switch.py: 3 classes (WindowDetection, ValveDetection, ChildLock)
  • select.py: 1 enum + 1 class (PresetMode, Preset)
  • number/__init__.py: 1 class (AwayTemp)

Total: 128 lines removed across 5 files

I tested locally and confirmed that these legacy entity classes were indeed creating duplicates:

  • Legacy: switch.tvr_badezimmer_oben_kindersicherung (German translation)
  • Quirk: switch.lumi_lumi_airrtc_agl001_child_lock (English)

The unique_id_suffix approach I tried earlier didn't work because the unique_id base format is completely different between legacy (device-name based) and quirk (model-name based) entities.

This PR should now properly eliminate all duplicates when paired with the quirk PR (zigpy/zha-device-handlers#4604).

@TheJulianJES
Copy link
Contributor

The unique_id_suffix approach I tried earlier didn't work because the unique_id base format is completely different between legacy (device-name based) and quirk (model-name based) entities.

From my previous message:

Also, we should set the unique_id_suffix for the v2 quirk defined entities accordingly to match what the ZHA entities auto-generated. It should be something like this: 1-64704-child_lock (endpoint id + cluster id + ZHA unique id suffix).
Otherwise, users would see new entities and we'd break old ones. We can't do that.

You need to add the endpoint id and cluster id in v2 quirks UID, only then add the ZHA unique ID suffix. The example I mentioned should work for the child lock entity. The rest are very similar. 1-64704- should work fine as a prefix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove legacy hardcoded attributes for lumi.airrtc.agl001 (Aqara E1 TRV)

2 participants