diff --git a/tests/test_develco.py b/tests/test_develco.py index dd95d12130..f813e026cb 100644 --- a/tests/test_develco.py +++ b/tests/test_develco.py @@ -2,8 +2,9 @@ from unittest import mock +import pytest import zigpy.types as t -from zigpy.zcl import ClusterType, foundation +from zigpy.zcl import foundation from zigpy.zcl.clusters.smartenergy import Metering from tests.common import ClusterListener @@ -17,7 +18,7 @@ async def test_frient_emi(zigpy_device_from_v2_quirk): device = zigpy_device_from_v2_quirk( "frient A/S", "EMIZB-141", - cluster_ids={2: {Metering.cluster_id: ClusterType.Server}}, + endpoint_ids=[2], ) metering_cluster = device.endpoints[2].smartenergy_metering @@ -141,9 +142,16 @@ async def test_frient_emi(zigpy_device_from_v2_quirk): assert result == (foundation.Status.SUCCESS, "done") -async def test_mfg_cluster_events(zigpy_device_from_v2_quirk): +@pytest.mark.parametrize( + ("manufacturer", "model"), + [ + ("frient A/S", "EMIZB-132"), + ("frient A/S", "EMIZB-141"), + ], +) +async def test_mfg_cluster_events(zigpy_device_from_v2_quirk, manufacturer, model): """Test Frient EMI Norwegian HAN ignoring incorrect divisor attribute reports.""" - device = zigpy_device_from_v2_quirk("frient A/S", "EMIZB-132", endpoint_ids=[1, 2]) + device = zigpy_device_from_v2_quirk(manufacturer, model, endpoint_ids=[1, 2]) metering_cluster = device.endpoints[2].smartenergy_metering metering_listener = ClusterListener(metering_cluster) diff --git a/zhaquirks/develco/emi_led.py b/zhaquirks/develco/emi_led.py index 5a97d82ce8..54aa819414 100644 --- a/zhaquirks/develco/emi_led.py +++ b/zhaquirks/develco/emi_led.py @@ -1,6 +1,6 @@ """Frient Electricity Meter Interface LED variant.""" -from typing import Final +from typing import Any, Final from zigpy.quirks import CustomCluster from zigpy.quirks.v2 import QuirkBuilder @@ -33,8 +33,29 @@ class AttributeDefs(BaseAttributeDefs): ) +class FrientMetering(CustomCluster, Metering): + """Frient EMI LED Metering cluster definition.""" + + # fix device issue (conflicting with manufacturer specific interface mode attr) + _CONSTANT_ATTRIBUTES = { + Metering.AttributeDefs.divisor.id: 1000, + Metering.AttributeDefs.multiplier.id: 1, + } + + def _update_attribute(self, attrid: int | t.uint16_t, value: Any) -> None: + """Update attribute with value.""" + # prevent attribute_updated events for divisor and multiplier + if attrid in ( + Metering.AttributeDefs.divisor.id, + Metering.AttributeDefs.multiplier.id, + ): + return + super()._update_attribute(attrid, value) + + ( QuirkBuilder("frient A/S", "EMIZB-141") + .replaces(FrientMetering, endpoint_id=2) .replaces(ManufacturerMetering, endpoint_id=2) .device_class(ManufacturerDeviceV2) .number(