Skip to content

Commit

Permalink
Ignore summation delivered if lower value received
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibsk committed Dec 31, 2024
1 parent f5c09c4 commit a8e6e3c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion zhaquirks/xiaomi/aqara/plug_eu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Xiaomi Aqara EU plugs."""

from enum import Enum
import logging

import zigpy
from zigpy import types
Expand Down Expand Up @@ -44,6 +45,8 @@

OPPLE_MFG_CODE = 0x115F

_LOGGER = logging.getLogger(__name__)


async def remove_from_ep(dev: zigpy.device.Device) -> None:
"""Remove devices that are in group 0 by default, so IKEA devices don't control them.
Expand Down Expand Up @@ -375,14 +378,31 @@ class PlugAEU001Cluster(XiaomiAqaraE1Cluster):
}


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(

Check warning on line 388 in zhaquirks/xiaomi/aqara/plug_eu.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/xiaomi/aqara/plug_eu.py#L385-L388

Added lines #L385 - L388 were not covered by tests
"Ignoring attribute update for %s: new value %s is less than current value %s",
attrid,
value,
current_value,
)
return
super()._update_attribute(attrid, value)

Check warning on line 395 in zhaquirks/xiaomi/aqara/plug_eu.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/xiaomi/aqara/plug_eu.py#L394-L395

Added lines #L394 - L395 were not covered by tests


(
QuirkBuilder("Aqara", "lumi.plug.aeu001")
.friendly_name(model="Wall Outlet H2 EU", manufacturer="Aqara")
.removes(TemperatureMeasurement.cluster_id)
.adds(DeviceTemperature)
.removes(OnOff.cluster_id, endpoint_id=2)
.replaces(BasicCluster)
.replaces(MeteringCluster)
.replaces(PlugAEU001MeteringCluster)
.replaces(ElectricalMeasurementCluster)
.replaces(PlugAEU001Cluster)
.replaces(AnalogInputCluster, endpoint_id=21)
Expand Down

0 comments on commit a8e6e3c

Please sign in to comment.