-
Notifications
You must be signed in to change notification settings - Fork 664
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 Aqara H2 plug #3265
base: dev
Are you sure you want to change the base?
Add Aqara H2 plug #3265
Conversation
there are some things not quite clear to me :-( comparing the INPUT_CLUSTERS from plug_eu.py with plug.py: plug_eu.py
plug.py
it seems, that IDs 3. 4, 6, 16 are not the same? Is there a resource about the clusters somewhere? |
zhaquirks/xiaomi/aqara/plug_eu.py
Outdated
@@ -346,3 +346,55 @@ class PlugMAEU01Alt3(PlugMAEU01): | |||
} | |||
|
|||
replacement = PlugMAEU01.replacement | |||
|
|||
class PlugAEU001(PlugAEU001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a missing :
at the end here.
zhaquirks/xiaomi/aqara/plug_eu.py
Outdated
@@ -346,3 +346,55 @@ class PlugMAEU01Alt3(PlugMAEU01): | |||
} | |||
|
|||
replacement = PlugMAEU01.replacement | |||
|
|||
class PlugAEU001(PlugAEU001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also can't inherit from the same class that you're creating.
Either use PlugMAEU01
or CustomDevice
. CustomDevice
might make more sense here, since it seems like there's quite a big difference between the older plugs and this H2 plug.
Ideally, we'd use the new v2 quirks API, but I'll try to explain this with an example of the old "API". class PlugAeu001(CustomDevice):
"""Aqara lumi.plug.aeu001 custom device implementation."""
# The signature is unaltered. It has to match the device signature exactly for the quirk to apply.
signature = {
MODELS_INFO: [("Aqara", "lumi.plug.aeu001")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
MultistateInput.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
0xfcc0, # this is a custom Aqara cluster, it will be replaced with a implementation in the replacement
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [
],
},
21: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
AnalogInput.cluster_id,
],
OUTPUT_CLUSTERS: [
],
},
},
}
# This replaces the device signature when exposed to ZHA.
# We can remove clusters (or even endpoints completely). We can also use custom clusters here.
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BasicCluster, # this modified basic cluster catches some special Aqara reports, not sure if needed
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
# OnOff.cluster_id, # we can remove the `OnOff` cluster from endpoint 1, as it doesn't seem to work according to the linked issue
MultistateInput.cluster_id,
TemperatureMeasurement.cluster_id, # if this shows wrong temperatures, remove it completely
MeteringCluster, # we're replacing this with a custom cluster
ElectricalMeasurementCluster, # we're replacing this with a custom cluster
OppleCluster, # we're adding our Aqara cluster implementation here
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [
],
},
21: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
AnalogInputCluster, # we're using a custom cluster here too to "catch" some energy reports and forward it to the main ElectricalMeasurement cluster on endpoint 1
],
OUTPUT_CLUSTERS: [
],
},
},
} |
Thank you for working on this! I just installed this device today and was sad to see it was missing some options and had a duplicated toggle, glad to see someone is working on this! Let me know when this is ready for testing, I'd be glad to help out. |
Proposed change
This PR should add the Aqara H2 EU Wall-Plug to the Xiaomi Aqara Quirk to address #3187
Additional information
Work in Progress!
Since this is my first work on ZHA Device Handlers at all, I am not even sure if this is the correct approach.
I don't have any way to test this atm - and there are still several unknown topics, such as "unknown cluster_id's" and profile_id's etc.
It would be great, if someone who's more into this could assist... :)
Checklist
pre-commit
checks pass / the code has been formatted using Black