Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/test_develco.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,7 +18,7 @@
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
Expand Down Expand Up @@ -84,7 +85,7 @@
request_mock.reset_mock()

# read non-custom attribute
result = await metering_cluster.read_attributes(

Check failure on line 88 in tests/test_develco.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

test_frient_emi TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Check failure on line 88 in tests/test_develco.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.13

test_frient_emi TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
[metering_cluster.AttributeDefs.current_summ_delivered.id]
)

Expand Down Expand Up @@ -141,9 +142,16 @@
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)
Expand Down
23 changes: 22 additions & 1 deletion zhaquirks/develco/emi_led.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
Loading