Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add signature for Aqara H1 double switch lumi.switch.n2aeu1 #2826

Merged
merged 7 commits into from
Dec 13, 2023

Conversation

TheJulianJES
Copy link
Collaborator

Proposed change

Adds an alternative signature for the Aqara H1 double rocker switch (with neutral) lumi.switch.n2aeu1.

The following small changes are also done:

  • existing "cluster id comments" are fixed and new ones are added
  • raw cluster ids are replaced by cluster.cluster_id
  • some commas to the end of lists in signature are added to be consistent with the other Opple/H1 switch quirks

Why use part of the signature from opple_switch.py instead of just adding new model info there?

The opple_switch.py file contains signatures strictly from the US lumi.switch.b2naus01 switch now.
The switch_h1_double.py file contains signatures for H1 double switches, but now also bases two quirks off the signatures in opple_switch.py and only changes the MODELS_INFO in its signature.

To avoid the confusion that was caused around this in the past, I've opted to do it this way to keep the US switch vs EU H1 quirks somewhat separate.
All H1 quirks are now either in switch_h1_double.py or switch_h1_single.py. In the past, they were split in a very non-intuitive way.

Additional information

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

Copy link

codecov bot commented Dec 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5291121) 87.37% compared to head (69625e5) 87.37%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2826   +/-   ##
=======================================
  Coverage   87.37%   87.37%           
=======================================
  Files         287      287           
  Lines        8847     8848    +1     
=======================================
+ Hits         7730     7731    +1     
  Misses       1117     1117           

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

@TheJulianJES TheJulianJES merged commit a0c4109 into zigpy:dev Dec 13, 2023
14 checks passed
},
ENDPOINTS: XiaomiOpple2ButtonSwitch1.signature[ENDPOINTS],
}

Choose a reason for hiding this comment

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

@TheJulianJES It looks to me like there may be another signature missing here for the Aqara H1 Double Rocker Switch (with neutral) model lumi.switch.n2aeu1.

I have a ""lumi.switch.n2aeu1" device with the following signature:

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4447, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0000",
        "0x0002",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0009",
        "0x0702",
        "0x0b04"
      ],
      "output_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "2": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0012",
        "0xfcc0"
      ],
      "output_clusters": []
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.switch.n2aeu1",
  "class": "zigpy.device.Device"
}

Which seems to match XiaomiOpple2ButtonSwitch3

Do you think this variant could be added as well? Or am I overlooking something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll PR it. When you delete it from ZHA and re-pair it (maybe repeating that multiple times), does it also report a different signature sometimes? Wondering if XiaomiOpple2ButtonSwitch2 also matches these EU switches sometimes.

Choose a reason for hiding this comment

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

Actually yes, re-pairing gives different signatures as well unfortunately.

I just got the following signature:

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4447, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0000",
        "0x0002",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0012",
        "0xfcc0"
      ],
      "output_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "2": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0012",
        "0xfcc0"
      ],
      "output_clusters": []
    },
    "21": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x000c"
      ],
      "output_clusters": []
    },
    "31": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x000c"
      ],
      "output_clusters": []
    },
    "41": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0012"
      ],
      "output_clusters": []
    },
    "42": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0012"
      ],
      "output_clusters": []
    },
    "51": {
      "profile_id": "0x0104",
      "device_type": "0x0100",
      "input_clusters": [
        "0x0012"
      ],
      "output_clusters": []
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.switch.n2aeu1",
  "class": "zigpy.device.Device"
}

Which is again different than before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this one is already addressed in HA Core 2023.12.4.

elupus pushed a commit to elupus/zha-device-handlers that referenced this pull request Jan 17, 2024
…2826)

* Remove double space in comment

* Add/fix cluster id comments

* Use `OppleSwitchCluster.cluster_id` instead of `0xFCC0`

* Use `ElectricalMeasurement.cluster_id` instead of `0x0B04`

* Add alternative signature based on `XiaomiOpple2ButtonSwitch`

* Add commas at end of list to be consistent

* Deduplicate `lumi.switch.n2aeu1` signatures

This uses `XiaomiOpple2ButtonSwitch1` and `XiaomiOpple2ButtonSwitch4` from `opple_switch.py` for the double H1 rocker switches (with neutral), but still keeps them in the separate `switch_h1_double.py` file.
lgraf pushed a commit to lgraf/zha-device-handlers that referenced this pull request May 6, 2024
…2826)

* Remove double space in comment

* Add/fix cluster id comments

* Use `OppleSwitchCluster.cluster_id` instead of `0xFCC0`

* Use `ElectricalMeasurement.cluster_id` instead of `0x0B04`

* Add alternative signature based on `XiaomiOpple2ButtonSwitch`

* Add commas at end of list to be consistent

* Deduplicate `lumi.switch.n2aeu1` signatures

This uses `XiaomiOpple2ButtonSwitch1` and `XiaomiOpple2ButtonSwitch4` from `opple_switch.py` for the double H1 rocker switches (with neutral), but still keeps them in the separate `switch_h1_double.py` file.
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.

2 participants