From 38c36104e2745bbed169aa68b47848a379c4406c Mon Sep 17 00:00:00 2001 From: jamesharrow <93921463+jamesharrow@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:13:12 +0000 Subject: [PATCH] QA team requested that all attributes in EPM cluster be turned on in energy-management-app (#32095) * Fixes: #32089 In all-clusters-app, Set the EPM PowerMode attribute to AC. In energy-management-app turned on all features and attributes for testing. Fixed issue in TC_EPM_2_1.py when valid attribute is returned. Improved type checking for HarmonicCurrents and HarmonicPhases * Turned on additional attributes in EPM cluster on energy-management-app. Now runs tests without skipping unsupported attributes. * Turned on additional attributes in EPM cluster on energy-management-app. Now runs tests without skipping unsupported attributes. * Fixes #31925 - QA team expect HarmonicCurrents and HarmonicPhases to have 1 entry in the list for testing * Turned off 3 provisional features which fail the TC_DeviceConformance.py test * Removed EVSE attributes which are provisional in 1.3 (SOC, PNC, V2X) --- .../all-clusters-app.matter | 6 - .../all-clusters-common/all-clusters-app.zap | 105 +------ .../src/electrical-power-measurement-stub.cpp | 2 + .../src/energy-evse-stub.cpp | 4 +- .../energy-management-app.matter | 18 +- .../energy-management-app.zap | 290 ++++++++++++------ .../ElectricalPowerMeasurementDelegate.cpp | 55 ++-- .../src/EnergyEvseMain.cpp | 22 +- src/python_testing/TC_EPM_2_1.py | 39 ++- 9 files changed, 284 insertions(+), 257 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 64d3a8f6283dba..a499ce042d37cd 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -8301,11 +8301,9 @@ endpoint 1 { callback attribute supplyState; callback attribute faultState; callback attribute chargingEnabledUntil; - callback attribute dischargingEnabledUntil; callback attribute circuitCapacity; callback attribute minimumChargeCurrent; callback attribute maximumChargeCurrent; - callback attribute maximumDischargeCurrent; callback attribute userMaximumChargeCurrent; callback attribute randomizationDelayWindow; callback attribute nextChargeStartTime; @@ -8313,13 +8311,9 @@ endpoint 1 { callback attribute nextChargeRequiredEnergy; callback attribute nextChargeTargetSoC; callback attribute approximateEVEfficiency; - callback attribute stateOfCharge; - callback attribute batteryCapacity; - callback attribute vehicleID; callback attribute sessionID; callback attribute sessionDuration; callback attribute sessionEnergyCharged; - callback attribute sessionEnergyDischarged; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index cb3e8ec2930b5e..f659f44a45c808 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -3097,10 +3097,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3113,10 +3113,10 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0002", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -8570,6 +8570,7 @@ "define": "LAUNDRY_DRYER_CONTROLS_CLUSTER", "side": "server", "enabled": 1, + "apiMaturity": "provisional", "attributes": [ { "name": "SupportedDrynessLevels", @@ -13815,22 +13816,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "DischargingEnabledUntil", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "epoch_s", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "CircuitCapacity", "code": 5, @@ -13879,22 +13864,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "MaximumDischargeCurrent", - "code": 8, - "mfgCode": null, - "side": "server", - "type": "amperage_ma", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "UserMaximumChargeCurrent", "code": 9, @@ -14007,54 +13976,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "StateOfCharge", - "code": 48, - "mfgCode": null, - "side": "server", - "type": "percent", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "BatteryCapacity", - "code": 49, - "mfgCode": null, - "side": "server", - "type": "energy_mwh", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "VehicleID", - "code": 50, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "SessionID", "code": 64, @@ -14103,22 +14024,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "SessionEnergyDischarged", - "code": 67, - "mfgCode": null, - "side": "server", - "type": "energy_mwh", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "GeneratedCommandList", "code": 65528, diff --git a/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp index 4bcea0e8ed9895..2a4c422d581e55 100644 --- a/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp @@ -47,5 +47,7 @@ void emberAfElectricalPowerMeasurementClusterInitCallback(chip::EndpointId endpo OptionalAttributes::kOptionalAttributeNeutralCurrent)); gEPMInstance->Init(); + + gEPMDelegate->SetPowerMode(PowerModeEnum::kAc); } } diff --git a/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp index f9983d47883852..72fe588995784e 100644 --- a/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp @@ -35,9 +35,7 @@ void emberAfEnergyEvseClusterInitCallback(chip::EndpointId endpointId) { gInstance = std::make_unique( endpointId, *gDelegate, - BitMask(EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kPlugAndCharge, - EnergyEvse::Feature::kRfid, EnergyEvse::Feature::kSoCReporting, - EnergyEvse::Feature::kV2x), + BitMask(EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kRfid), BitMask(OptionalAttributes::kSupportsUserMaximumChargingCurrent, OptionalAttributes::kSupportsRandomizationWindow, OptionalAttributes::kSupportsApproximateEvEfficiency), diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.matter b/examples/energy-management-app/energy-management-common/energy-management-app.matter index 1ab71d2cc0769d..c56280b2b72f08 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.matter +++ b/examples/energy-management-app/energy-management-common/energy-management-app.matter @@ -1896,7 +1896,19 @@ endpoint 1 { callback attribute ranges; callback attribute voltage; callback attribute activeCurrent; + callback attribute reactiveCurrent; + callback attribute apparentCurrent; callback attribute activePower; + callback attribute reactivePower; + callback attribute apparentPower; + callback attribute RMSVoltage; + callback attribute RMSCurrent; + callback attribute RMSPower; + callback attribute frequency; + callback attribute harmonicCurrents; + callback attribute harmonicPhases; + callback attribute powerFactor; + callback attribute neutralCurrent; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; @@ -1963,11 +1975,9 @@ endpoint 1 { callback attribute supplyState; callback attribute faultState; callback attribute chargingEnabledUntil; - callback attribute dischargingEnabledUntil; callback attribute circuitCapacity; callback attribute minimumChargeCurrent; callback attribute maximumChargeCurrent; - callback attribute maximumDischargeCurrent; callback attribute userMaximumChargeCurrent; callback attribute randomizationDelayWindow; callback attribute nextChargeStartTime; @@ -1975,13 +1985,9 @@ endpoint 1 { callback attribute nextChargeRequiredEnergy; callback attribute nextChargeTargetSoC; callback attribute approximateEVEfficiency; - callback attribute stateOfCharge; - callback attribute batteryCapacity; - callback attribute vehicleID; callback attribute sessionID; callback attribute sessionDuration; callback attribute sessionEnergyCharged; - callback attribute sessionEnergyDischarged; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.zap b/examples/energy-management-app/energy-management-common/energy-management-app.zap index ba1fa29d585485..d795b4fd482448 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.zap +++ b/examples/energy-management-app/energy-management-common/energy-management-app.zap @@ -2860,7 +2860,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2898,6 +2898,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "ReactiveCurrent", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ApparentCurrent", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ActivePower", "code": 8, @@ -2914,6 +2946,166 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "ReactivePower", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ApparentPower", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "RMSVoltage", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "voltage_mv", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "RMSCurrent", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "RMSPower", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Frequency", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "int64s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "HarmonicCurrents", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "HarmonicPhases", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PowerFactor", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int64s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NeutralCurrent", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "amperage_ma", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -3701,22 +3893,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "DischargingEnabledUntil", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "epoch_s", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "CircuitCapacity", "code": 5, @@ -3765,22 +3941,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "MaximumDischargeCurrent", - "code": 8, - "mfgCode": null, - "side": "server", - "type": "amperage_ma", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "UserMaximumChargeCurrent", "code": 9, @@ -3893,54 +4053,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "StateOfCharge", - "code": 48, - "mfgCode": null, - "side": "server", - "type": "percent", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "BatteryCapacity", - "code": 49, - "mfgCode": null, - "side": "server", - "type": "energy_mwh", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "VehicleID", - "code": 50, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "SessionID", "code": 64, @@ -3989,22 +4101,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "SessionEnergyDischarged", - "code": 67, - "mfgCode": null, - "side": "server", - "type": "energy_mwh", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "GeneratedCommandList", "code": 65528, diff --git a/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp b/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp index fe712d92ae1667..fdda913a868a22 100644 --- a/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp +++ b/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp @@ -246,12 +246,17 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::EndRangesRead() return CHIP_NO_ERROR; } +static const Structs::HarmonicMeasurementStruct::Type kHarmonicCurrentMeasurements[] = { + { .order = 1, .measurement = MakeNullable(static_cast(100000)) } +}; + /* @brief This function is called by the cluster server at the start of read cycle * This could take a semaphore to stop a background update of the data */ -CHIP_ERROR ElectricalPowerMeasurementDelegate::StartHarmonicCurrentsRead() +CHIP_ERROR +ElectricalPowerMeasurementDelegate::StartHarmonicCurrentsRead() { - /* Since we don't an implementation here we don't need to do anything here */ + /* Since we have a static array we don't need to do anything here */ return CHIP_NO_ERROR; } CHIP_ERROR @@ -269,34 +274,34 @@ ElectricalPowerMeasurementDelegate::GetHarmonicCurrentsByIndex(uint8_t harmonicC * MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, HarmonicCurrents::Id); */ - /* if (rangeIndex >= ArraySize(mHarmonicCurrentMeasurements)) - * { - * return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; - * } - * - * range = mHarmonicCurrentMeasurements[rangeIndex]; - * - * return CHIP_NO_ERROR; - */ + /* Added to support testing using a static array for now */ + if (harmonicCurrentsIndex >= ArraySize(kHarmonicCurrentMeasurements)) + { + return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + } - /* Return an empty list for now */ - return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + harmonicCurrent = kHarmonicCurrentMeasurements[harmonicCurrentsIndex]; + return CHIP_NO_ERROR; } /* @brief This function is called by the cluster server at the end of read cycle * This could release a semaphore to allow a background update of the data */ CHIP_ERROR ElectricalPowerMeasurementDelegate::EndHarmonicCurrentsRead() { - /* Since we don't an implementation here we don't need to do anything here */ + /* Since we have a static array we don't need to do anything here */ return CHIP_NO_ERROR; } +static const Structs::HarmonicMeasurementStruct::Type kHarmonicPhaseMeasurements[] = { + { .order = 1, .measurement = MakeNullable(static_cast(100000)) } +}; + /* @brief This function is called by the cluster server at the start of read cycle * This could take a semaphore to stop a background update of the data */ CHIP_ERROR ElectricalPowerMeasurementDelegate::StartHarmonicPhasesRead() { - /* Since we don't an implementation here we don't need to do anything here */ + /* Since we have a static array we don't need to do anything here */ return CHIP_NO_ERROR; } @@ -314,25 +319,21 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::GetHarmonicPhasesByIndex(uint8_t * MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, HarmonicPhases::Id); */ - /* if (rangeIndex >= ArraySize(mHarmonicPhaseMeasurements)) - * { - * return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; - * } - * - * range = mHarmonicPhaseMeasurements[rangeIndex]; - * - * return CHIP_NO_ERROR; - */ + /* Added to support testing using a static array for now */ + if (harmonicPhaseIndex >= ArraySize(kHarmonicPhaseMeasurements)) + { + return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + } - /* Return an empty list for now */ - return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + harmonicPhase = kHarmonicPhaseMeasurements[harmonicPhaseIndex]; + return CHIP_NO_ERROR; } /* @brief This function is called by the cluster server at the end of read cycle * This could release a semaphore to allow a background update of the data */ CHIP_ERROR ElectricalPowerMeasurementDelegate::EndHarmonicPhasesRead() { - /* Since we don't an implementation here we don't need to do anything here */ + /* Since we have a static array we don't need to do anything here */ return CHIP_NO_ERROR; } diff --git a/examples/energy-management-app/energy-management-common/src/EnergyEvseMain.cpp b/examples/energy-management-app/energy-management-common/src/EnergyEvseMain.cpp index 92593efe6f8370..9beff80e8dc22a 100644 --- a/examples/energy-management-app/energy-management-common/src/EnergyEvseMain.cpp +++ b/examples/energy-management-app/energy-management-common/src/EnergyEvseMain.cpp @@ -152,9 +152,7 @@ CHIP_ERROR EnergyEvseInit() /* Manufacturer may optionally not support all features, commands & attributes */ gEvseInstance = std::make_unique( EndpointId(ENERGY_EVSE_ENDPOINT), *gEvseDelegate, - BitMask(EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kPlugAndCharge, - EnergyEvse::Feature::kRfid, EnergyEvse::Feature::kSoCReporting, - EnergyEvse::Feature::kV2x), + BitMask(EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kRfid), BitMask(EnergyEvse::OptionalAttributes::kSupportsUserMaximumChargingCurrent, EnergyEvse::OptionalAttributes::kSupportsRandomizationWindow, EnergyEvse::OptionalAttributes::kSupportsApproximateEvEfficiency), @@ -224,13 +222,27 @@ CHIP_ERROR EnergyMeterInit() } /* Manufacturer may optionally not support all features, commands & attributes */ + /* Turning on all optional features and attributes for test certification purposes */ gEPMInstance = std::make_unique( EndpointId(ENERGY_EVSE_ENDPOINT), *gEPMDelegate, - BitMask(ElectricalPowerMeasurement::Feature::kAlternatingCurrent), + BitMask( + ElectricalPowerMeasurement::Feature::kDirectCurrent, ElectricalPowerMeasurement::Feature::kAlternatingCurrent, + ElectricalPowerMeasurement::Feature::kPolyphasePower, ElectricalPowerMeasurement::Feature::kHarmonics, + ElectricalPowerMeasurement::Feature::kPowerQuality), BitMask( ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeRanges, ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeVoltage, - ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeActiveCurrent)); + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeActiveCurrent, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeReactiveCurrent, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeApparentCurrent, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeReactivePower, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeApparentPower, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeRMSVoltage, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeRMSCurrent, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeRMSPower, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeFrequency, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributePowerFactor, + ElectricalPowerMeasurement::OptionalAttributes::kOptionalAttributeNeutralCurrent)); if (!gEPMInstance) { diff --git a/src/python_testing/TC_EPM_2_1.py b/src/python_testing/TC_EPM_2_1.py index fc4347e1ec0a0d..8be16208169de2 100644 --- a/src/python_testing/TC_EPM_2_1.py +++ b/src/python_testing/TC_EPM_2_1.py @@ -23,6 +23,9 @@ logger = logging.getLogger(__name__) +MIN_INT64_ALLOWED = -pow(2, 62) # -(2^62) +MAX_INT64_ALLOWED = pow(2, 62) # (2^62) + class TC_EPM_2_1(MatterBaseTest, EnergyReportingBaseTestHelper): @@ -133,52 +136,52 @@ async def test_TC_EPM_2_1(self): self.step("6") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.Voltage.attribute_id in supported_attributes): - voltage = await self.check_epm_attribute_in_range("Voltage", -2 ^ 62, 2 ^ 62, allow_null=True) + voltage = await self.check_epm_attribute_in_range("Voltage", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd Voltage: {voltage}") self.step("7") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.ActiveCurrent.attribute_id in supported_attributes): - active_current = await self.check_epm_attribute_in_range("ActiveCurrent", -2 ^ 62, 2 ^ 62, allow_null=True) + active_current = await self.check_epm_attribute_in_range("ActiveCurrent", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd ActiveCurrent: {active_current}") self.step("8") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.ReactiveCurrent.attribute_id in supported_attributes): - reactive_current = await self.check_epm_attribute_in_range("ReactiveCurrent", -2 ^ 62, 2 ^ 62, allow_null=True) + reactive_current = await self.check_epm_attribute_in_range("ReactiveCurrent", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd ReactiveCurrent: {reactive_current}") self.step("9") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.ApparentCurrent.attribute_id in supported_attributes): - apparent_current = await self.check_epm_attribute_in_range("ApparentCurrent", 0, 2 ^ 62, allow_null=True) + apparent_current = await self.check_epm_attribute_in_range("ApparentCurrent", 0, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd ApparentCurrent: {apparent_current}") self.step("10") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.ActivePower.attribute_id in supported_attributes): - active_power = await self.check_epm_attribute_in_range("ActivePower", -2 ^ 62, 2 ^ 62, allow_null=True) + active_power = await self.check_epm_attribute_in_range("ActivePower", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd ActivePower: {active_power}") self.step("11") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.ReactivePower.attribute_id in supported_attributes): - reactive_power = await self.check_epm_attribute_in_range("ReactivePower", -2 ^ 62, 2 ^ 62, allow_null=True) + reactive_power = await self.check_epm_attribute_in_range("ReactivePower", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd ReactivePower: {reactive_power}") self.step("12") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.ApparentPower.attribute_id in supported_attributes): - apparent_power = await self.check_epm_attribute_in_range("ApparentPower", -2 ^ 62, 2 ^ 62, allow_null=True) + apparent_power = await self.check_epm_attribute_in_range("ApparentPower", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd ApparentPower: {apparent_power}") self.step("13") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.RMSVoltage.attribute_id in supported_attributes): - rms_voltage = await self.check_epm_attribute_in_range("RMSVoltage", -2 ^ 62, 2 ^ 62, allow_null=True) + rms_voltage = await self.check_epm_attribute_in_range("RMSVoltage", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd RMSVoltage: {rms_voltage}") self.step("14") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.RMSCurrent.attribute_id in supported_attributes): - rms_current = await self.check_epm_attribute_in_range("RMSCurrent", -2 ^ 62, 2 ^ 62, allow_null=True) + rms_current = await self.check_epm_attribute_in_range("RMSCurrent", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd RMSCurrent: {rms_current}") self.step("15") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.RMSPower.attribute_id in supported_attributes): - rms_power = await self.check_epm_attribute_in_range("RMSPower", -2 ^ 62, 2 ^ 62, allow_null=True) + rms_power = await self.check_epm_attribute_in_range("RMSPower", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd RMSPower: {rms_power}") self.step("16") @@ -188,13 +191,23 @@ async def test_TC_EPM_2_1(self): self.step("17") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.HarmonicCurrents.attribute_id in supported_attributes): - harmonic_currents = await self.read_epm_attribute_expect_success("HarmonicCurrents", allow_null=True) + harmonic_currents = await self.read_epm_attribute_expect_success("HarmonicCurrents") logger.info(f"Rx'd HarmonicCurrents: {harmonic_currents}") + asserts.assert_is(type(harmonic_currents), list) + for index, entry in enumerate(harmonic_currents): + logging.info(f" [{index}] order:{entry.order} measurement:{entry.measurement}") + asserts.assert_greater_equal(entry.order, 1) + self.check_value_in_range("Measurement", entry.measurement, MIN_INT64_ALLOWED, MAX_INT64_ALLOWED) self.step("18") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.HarmonicPhases.attribute_id in supported_attributes): - harmonic_phases = await self.read_epm_attribute_expect_success("HarmonicPhases", allow_null=True) + harmonic_phases = await self.read_epm_attribute_expect_success("HarmonicPhases") logger.info(f"Rx'd HarmonicPhases: {harmonic_phases}") + asserts.assert_is(type(harmonic_phases), list) + for index, entry in enumerate(harmonic_phases): + logging.info(f" [{index}] order:{entry.order} measurement:{entry.measurement}") + asserts.assert_greater_equal(entry.order, 1) + self.check_value_in_range("Measurement", entry.measurement, MIN_INT64_ALLOWED, MAX_INT64_ALLOWED) self.step("19") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.PowerFactor.attribute_id in supported_attributes): @@ -203,7 +216,7 @@ async def test_TC_EPM_2_1(self): self.step("20") if self.pics_guard(Clusters.ElectricalPowerMeasurement.Attributes.NeutralCurrent.attribute_id in supported_attributes): - neutral_current = await self.check_epm_attribute_in_range("NeutralCurrent", -2 ^ 62, 2 ^ 62, allow_null=True) + neutral_current = await self.check_epm_attribute_in_range("NeutralCurrent", MIN_INT64_ALLOWED, MAX_INT64_ALLOWED, allow_null=True) logger.info(f"Rx'd NeutralCurrent: {neutral_current}")