-
Notifications
You must be signed in to change notification settings - Fork 729
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 Wall Outlet H2 EU #3653
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #3653 +/- ##
==========================================
- Coverage 89.84% 89.83% -0.01%
==========================================
Files 322 320 -2
Lines 10371 10403 +32
==========================================
+ Hits 9318 9346 +28
- Misses 1053 1057 +4 ☔ View full report in Codecov by Sentry. |
I noticed that for 1 out of my 5 devices the 'Summation delivered' reading was fluctuating up and down causing warnings and wrong data in the Energy dashboard.
The former one seems to lag behind in updating the summ and still sends the outdated value. The latter one sends values that are up to date. This leads the aggregated value switching between the outdated and the actual value: To avoid this, I've added the |
zhaquirks/xiaomi/aqara/plug_eu.py
Outdated
cluster_id=PlugAEU001Cluster.cluster_id, | ||
force_inverted=True, | ||
translation_key="button_lock", | ||
fallback_name="Button Lock", |
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.
Per HA spec, only the first letter should be capitalized, all other words should be lowercase (except for abbreviations). So, this should be "Buton lock", although we may want to use child_lock
for the translation_key
(and fallback_name
if that is the same, as that's what we use for other devices).
Please also adjust the names of the other entities. (E.g. "Power on behavior", "LED indicator", ...) Thanks!
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.
Changed to child_lock
and updated the other names as well. 👍
class PlugAEU001MeteringCluster(MeteringCluster): | ||
"""Custom cluster for Aqara lumi plug AEU001.""" | ||
|
||
def _update_attribute(self, attrid, value): | ||
if attrid == self.CURRENT_SUMM_DELIVERED_ID: | ||
current_value = self._attr_cache.get(attrid, 0) | ||
if value < current_value: | ||
_LOGGER.debug( | ||
"Ignoring attribute update for %s: new value %s is less than current value %s", | ||
attrid, | ||
value, | ||
current_value, | ||
) | ||
return | ||
super()._update_attribute(attrid, value) |
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.
Hmm, I'll have to check back on this. If the custom Xiaomi reports are more up-to-date/accurate and are also always sent, we could just ignore the ZCL reports coming in by overriding handle_cluster_general_request
like this:
zha-device-handlers/zhaquirks/xiaomi/__init__.py
Lines 568 to 579 in 57bcec8
class LocalOccupancyCluster(LocalDataCluster, OccupancyCluster): | |
"""Local occupancy cluster that ignores messages from device.""" | |
def handle_cluster_general_request( | |
self, | |
hdr: zigpy.zcl.foundation.ZCLHeader, | |
args: list, | |
*, | |
dst_addressing: AddressingMode | None = None, | |
) -> None: | |
"""Ignore occupancy attribute reports on this cluster, as they're invalid and sent by the sensor every hour.""" | |
That would ignore all attribute reports from the EM cluster though, since we essentially remove all of this: https://github.com/zigpy/zigpy/blob/07e0451ce5317185e04b38e43aeb9fb168c62f28/zigpy/zcl/__init__.py#L464-L530
We could probably also block the calls to set up attribute reporting for that attribute, but we should still block incoming attribute reports, as some devices may have been connected before.
I'll need to come back to this. Hopefully soon.
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.
Let me know if/how I could help in this regard.
Proposed change
This PR should add new configuration options and remove unused entities for Aqara Wall Outlet H2 EU (Aqara lumi.plug.aeu001) using the quirks v2 api.
Additional information
This is my first time writing a quirk and first time coding in Python, so please advise where improvements are possible.
Changes:
All the new configuration options have been tested on a device I own.
Related: #3265 #3187
Checklist
pre-commit
checks pass / the code has been formatted using Black