From 7e192aeff921d42b7102e2c91c3b591be955d2cd Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 17 Oct 2024 15:48:06 +0000 Subject: [PATCH 01/23] Add missing Water Heater device to matter-devices.xml This PR adds the missing Water Heater device to matter-devices.xml. The description was generated using the Alchemy tool (https://github.com/project-chip/alchemy) with the following command: `alchemy zap --attribute="in-progress" --sdkRoot=./connectedhomeip/ --specRoot=./connectedhomeip-spec/ ./connectedhomeip-spec/src/device_types/WaterHeater.adoc` I manually fixed the device nae from `Matter Water Heater` to `Water Heater`. --- .../zcl/data-model/chip/matter-devices.xml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml index f7f5699ef8fccf..ff485bbf6bba81 100644 --- a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +++ b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml @@ -2698,4 +2698,47 @@ limitations under the License. + + MA-waterheater + CHIP + Water Heater + 0x0103 + 0x050F + Simple + Endpoint + + + CLIENT_LIST + DEVICE_TYPE_LIST + PARTS_LIST + SERVER_LIST + + + IDENTIFY_TIME + IDENTIFY_TYPE + Identify + + + CONTROL_SEQUENCE_OF_OPERATION + LOCAL_TEMPERATURE + SYSTEM_MODE + SetpointRaiseLower + + + BOOST_STATE + HEATER_TYPES + HEAT_DEMAND + BoostEnded + BoostStarted + Boost + CancelBoost + + + CURRENT_MODE + SUPPORTED_MODES + ChangeToMode + ChangeToModeResponse + + + From e43ff673644d5d3dd59d275c1e409e1aa7a862f9 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 17 Oct 2024 17:26:52 +0000 Subject: [PATCH 02/23] zap regen --- src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h | 1 + .../Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm | 1 + .../chip-tool/zap-generated/cluster/logging/EntryToText.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 76d6ab35d3724a..f58c7bf4d93c3c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -7755,6 +7755,7 @@ typedef NS_ENUM(uint32_t, MTRDeviceTypeIDType) { MTRDeviceTypeIDTypeHumiditySensorID MTR_NEWLY_AVAILABLE = 0x00000307, MTRDeviceTypeIDTypeEVSEID MTR_NEWLY_AVAILABLE = 0x0000050C, MTRDeviceTypeIDTypeDeviceEnergyManagementID MTR_NEWLY_AVAILABLE = 0x0000050D, + MTRDeviceTypeIDTypeWaterHeaterID MTR_PROVISIONALLY_AVAILABLE = 0x0000050F, MTRDeviceTypeIDTypeElectricalSensorID MTR_NEWLY_AVAILABLE = 0x00000510, MTRDeviceTypeIDTypeControlBridgeID MTR_NEWLY_AVAILABLE = 0x00000840, MTRDeviceTypeIDTypeOnOffSensorID MTR_NEWLY_AVAILABLE = 0x00000850, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm index f0530c41a54f00..b4ea67c2ed66fe 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm @@ -85,6 +85,7 @@ { 0x00000307, MTRDeviceTypeClass::Simple, "Humidity Sensor" }, { 0x0000050C, MTRDeviceTypeClass::Simple, "EVSE" }, { 0x0000050D, MTRDeviceTypeClass::Simple, "Device Energy Management" }, + { 0x0000050F, MTRDeviceTypeClass::Simple, "Water Heater" }, { 0x00000510, MTRDeviceTypeClass::Utility, "Electrical Sensor" }, { 0x00000840, MTRDeviceTypeClass::Simple, "Control Bridge" }, { 0x00000850, MTRDeviceTypeClass::Simple, "On/Off Sensor" }, diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/EntryToText.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/EntryToText.cpp index 5aa0a783f8bfac..d90c2500e1dd5c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/EntryToText.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/EntryToText.cpp @@ -6761,6 +6761,8 @@ char const * DeviceTypeIdToText(chip::DeviceTypeId id) return "EVSE"; case 0x0000050D: return "Device Energy Management"; + case 0x0000050F: + return "Water Heater"; case 0x00000510: return "Electrical Sensor"; case 0x00000840: From ea06d89f42a66653cb5e0cedd7116d86e503792b Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 22 Oct 2024 19:53:29 +0000 Subject: [PATCH 03/23] energy-management-app: Split WH and EVSE into 2 endpoints This PR refactors the energy-management-app into 2 separate endpoints (one for EVSE and another for WaterHeater). This is the first step in making this app spec-conformant. `TC_DeviceBasicComposition.py` failed on this app before this PR and now passes. Changes: * Split Water Heater and EVSE into two separate endpoints (1 and 2). Updated zap and code. * Dinamically disable unused endpoint at runtime. Based on the app choice (command line argument on linux or #define in ESP32 or SIlabs), initialize the clusters in the correct endpoint and disable the other endpoint. For example, for Water Heater, initialize clusters on endpoint 2 and disable endpoint 1 (EVSE). * Refactor/move the init code related to ElectricalSensor (PowerTopology, EPM and EEM) from inside EVSE into ElectricalSensorInit.h/.cpp so they can be easier to reuse by both WaterHeater and EVSE. * Refactor/move DEM cluster init code into its own file so it can be better reused outside EVSE. Test performed: 1. Check basic composition for EVSE: ``` scripts/run_in_python_env.sh out/python_env './scripts/tests/run_python_test.py --app ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --app-args "--application evse --trace-to json:log" --script src/python_testing/TC_DeviceBasicComposition.py --script-args "--qr-code MT:-24J0AFN00KA0648G00"' ``` 2. Check basic composition for WaterHeater: ``` scripts/run_in_python_env.sh out/python_env './scripts/tests/run_python_test.py --app ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --app-args "--application water-heater --trace-to json:log" --script src/python_testing/TC_DeviceBasicComposition.py --script-args "--qr-code MT:-24J0AFN00KA0648G00"' ``` 3. Check app against `TC_EEVSE_2_6.py`: ``` rm -f evse.bin; ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --enable-key 000102030405060708090a0b0c0d0e0f --KVS evse.bin --featureSet 0x3d python src/python_testing/TC_EEVSE_2_6.py --endpoint 1 -m on-network -n 1234 -p 20202021 -d 3840 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f ``` --- .../EnergyManagementAppCmdLineOptions.h | 3 + .../include/{DEMDelegate.h => DEMInit.h} | 6 + .../device-energy-management/src/DEMInit.cpp | 126 + .../src/DEMTestEventTriggers.cpp | 2 +- .../src/device-energy-management-mode.cpp | 20 +- .../energy-evse/include/EnergyEvseMain.h | 11 +- .../energy-evse/src/EnergyEvseMain.cpp | 324 +-- .../energy-management-app.zap | 2131 +++++++++++++++-- .../include/ElectricalSensorInit.h | 33 + .../src/ElectricalSensorInit.cpp | 269 +++ .../energy-reporting/src/FakeReadings.cpp | 2 +- .../water-heater/include/WaterHeaterMain.h | 2 +- .../water-heater/include/WhmMain.h | 2 +- .../water-heater/src/WaterHeaterMain.cpp | 21 +- .../water-heater/src/WhmMain.cpp | 12 +- .../esp32/main/CMakeLists.txt | 1 + .../energy-management-app/esp32/main/main.cpp | 16 +- examples/energy-management-app/linux/BUILD.gn | 2 + examples/energy-management-app/linux/main.cpp | 27 +- .../energy-management-app/silabs/BUILD.gn | 2 + .../silabs/src/AppTask.cpp | 14 +- 21 files changed, 2421 insertions(+), 605 deletions(-) rename examples/energy-management-app/energy-management-common/device-energy-management/include/{DEMDelegate.h => DEMInit.h} (76%) create mode 100644 examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp create mode 100644 examples/energy-management-app/energy-management-common/energy-reporting/include/ElectricalSensorInit.h create mode 100644 examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp diff --git a/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h b/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h index a44140b94c762b..378a30adc453b8 100644 --- a/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h +++ b/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h @@ -25,7 +25,10 @@ namespace chip { namespace app { namespace Clusters { namespace DeviceEnergyManagement { +constexpr EndpointId kEvseEndpoint = 1; +constexpr EndpointId kWaterHeaterEndpoint = 2; +EndpointId GetMainAppEndpointId(); chip::BitMask GetFeatureMapFromCmdLine(); } // namespace DeviceEnergyManagement diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/include/DEMDelegate.h b/examples/energy-management-app/energy-management-common/device-energy-management/include/DEMInit.h similarity index 76% rename from examples/energy-management-app/energy-management-common/device-energy-management/include/DEMDelegate.h rename to examples/energy-management-app/energy-management-common/device-energy-management/include/DEMInit.h index ac5cc5000e71b9..8662ec9f6fcae4 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/include/DEMDelegate.h +++ b/examples/energy-management-app/energy-management-common/device-energy-management/include/DEMInit.h @@ -19,5 +19,11 @@ #pragma once #include +#include +#include + +CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId); +CHIP_ERROR DeviceEnergyManagementShutdown(); chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate(); +chip::app::Clusters::DeviceEnergyManagementManager * GetDEMInstance(); diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp new file mode 100644 index 00000000000000..b44a98810c6906 --- /dev/null +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp @@ -0,0 +1,126 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "EnergyManagementAppCmdLineOptions.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::DeviceEnergyManagement; + +static std::unique_ptr gDEMDelegate; +static std::unique_ptr gDEMInstance; + +DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate() +{ + VerifyOrDieWithMsg(gDEMDelegate.get() != nullptr, AppServer, "DEM Delegate is null"); + + return gDEMDelegate.get(); +} + +DeviceEnergyManagementManager * GetDEMInstance() +{ + VerifyOrDieWithMsg(gDEMInstance.get() != nullptr, AppServer, "DEM Instance is null"); + + return gDEMInstance.get(); +} + +/* + * @brief Creates a Delegate and Instance for DEM + * + * The Instance is a container around the Delegate, so + * create the Delegate first, then wrap it in the Instance + * Then call the Instance->Init() to register the attribute and command handlers + */ +CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId) +{ + // TODO: support both EVSE and WaterHeater endpoints + if (gDEMDelegate || gDEMInstance) + { + ChipLogError(AppServer, "DEM Instance or Delegate already exist."); + return CHIP_ERROR_INCORRECT_STATE; + } + + gDEMDelegate = std::make_unique(); + if (!gDEMDelegate) + { + ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementDelegate"); + return CHIP_ERROR_NO_MEMORY; + } + + chip::BitMask featureMap = GetFeatureMapFromCmdLine(); + + /* Manufacturer may optionally not support all features, commands & attributes */ + gDEMInstance = std::make_unique(EndpointId(endpointId), *gDEMDelegate, featureMap); + + if (!gDEMInstance) + { + ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementManager"); + gDEMDelegate.reset(); + return CHIP_ERROR_NO_MEMORY; + } + + gDEMDelegate->SetDeviceEnergyManagementInstance(*gDEMInstance); + + CHIP_ERROR err = gDEMInstance->Init(); /* Register Attribute & Command handlers */ + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Init failed on gDEMInstance"); + gDEMInstance.reset(); + gDEMDelegate.reset(); + return err; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DeviceEnergyManagementShutdown() +{ + // TODO: support both EVSE and WaterHeater endpoints + /* Do this in the order Instance first, then delegate + * Ensure we call the Instance->Shutdown to free attribute & command handlers first + */ + if (gDEMInstance) + { + /* deregister attribute & command handlers */ + gDEMInstance->Shutdown(); + gDEMInstance.reset(); + } + if (gDEMDelegate) + { + gDEMDelegate.reset(); + } + return CHIP_NO_ERROR; +} diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp index 58258b73cd50e8..11a02c097d4f47 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp index d993e5c163ada1..21113a1b33f9a4 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp @@ -16,11 +16,14 @@ * limitations under the License. */ +#include #include #include using namespace chip::app::Clusters; using namespace chip::app::Clusters::DeviceEnergyManagementMode; +using namespace chip::app::Clusters::DeviceEnergyManagement; + using chip::Protocols::InteractionModel::Status; template using List = chip::app::DataModel::List; @@ -77,11 +80,6 @@ CHIP_ERROR DeviceEnergyManagementModeDelegate::GetModeTagsByIndex(uint8_t modeIn return CHIP_NO_ERROR; } -ModeBase::Instance * DeviceEnergyManagementMode::Instance() -{ - return gDeviceEnergyManagementModeInstance.get(); -} - void DeviceEnergyManagementMode::Shutdown() { gDeviceEnergyManagementModeInstance.reset(); @@ -90,6 +88,18 @@ void DeviceEnergyManagementMode::Shutdown() void emberAfDeviceEnergyManagementModeClusterInitCallback(chip::EndpointId endpointId) { + VerifyOrDie(endpointId == kEvseEndpoint || endpointId == kWaterHeaterEndpoint); + + /* emberAfDeviceEnergyManagementModeClusterInitCallback() is called for all endpoints + that include this endpoint (even the one we disable dynamically). So here, we only + proceed when it's called for the right endpoint determined by GetMainAppEndpointId() + (a cmd line argument or #define). + */ + if (endpointId != GetMainAppEndpointId()) + { + return; + } + VerifyOrDie(!gDeviceEnergyManagementModeDelegate && !gDeviceEnergyManagementModeInstance); gDeviceEnergyManagementModeDelegate = std::make_unique(); gDeviceEnergyManagementModeInstance = std::make_unique(gDeviceEnergyManagementModeDelegate.get(), diff --git a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h index 07dce510e9b38c..f7ee56fc2c5f8c 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h +++ b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h @@ -20,14 +20,5 @@ #include -void EvseApplicationInit(); +void EvseApplicationInit(chip::EndpointId endpointId); void EvseApplicationShutdown(); - -CHIP_ERROR DeviceEnergyManagementInit(); -CHIP_ERROR DeviceEnergyManagementShutdown(); - -CHIP_ERROR EnergyMeterInit(); -CHIP_ERROR EnergyMeterShutdown(); - -CHIP_ERROR PowerTopologyInit(); -CHIP_ERROR PowerTopologyShutdown(); diff --git a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp index 8e900c0948008a..f2e7748ba76f82 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp +++ b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp @@ -18,9 +18,11 @@ #include "EnergyManagementAppCmdLineOptions.h" +#include #include #include #include +#include #include #include #include @@ -31,115 +33,26 @@ #include #include #include -#include #include #include #include -#define ENERGY_EVSE_ENDPOINT 1 - using namespace chip; using namespace chip::app; using namespace chip::app::DataModel; using namespace chip::app::Clusters; using namespace chip::app::Clusters::EnergyEvse; -using namespace chip::app::Clusters::DeviceEnergyManagement; -using namespace chip::app::Clusters::ElectricalPowerMeasurement; -using namespace chip::app::Clusters::ElectricalEnergyMeasurement; -using namespace chip::app::Clusters::PowerTopology; static std::unique_ptr gEvseDelegate; static std::unique_ptr gEvseTargetsDelegate; static std::unique_ptr gEvseInstance; -static std::unique_ptr gDEMDelegate; -static std::unique_ptr gDEMInstance; static std::unique_ptr gEvseManufacturer; -static std::unique_ptr gEPMDelegate; -static std::unique_ptr gEPMInstance; -// Electrical Energy Measurement cluster uses ember to initialise -static std::unique_ptr gEEMAttrAccess; - -static std::unique_ptr gPTDelegate; -static std::unique_ptr gPTInstance; EVSEManufacturer * EnergyEvse::GetEvseManufacturer() { return gEvseManufacturer.get(); } -DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate() -{ - VerifyOrDieWithMsg(gDEMDelegate.get() != nullptr, AppServer, "DEM Delegate is null"); - - return gDEMDelegate.get(); -} - -/* - * @brief Creates a Delegate and Instance for DEM - * - * The Instance is a container around the Delegate, so - * create the Delegate first, then wrap it in the Instance - * Then call the Instance->Init() to register the attribute and command handlers - */ -CHIP_ERROR DeviceEnergyManagementInit() -{ - if (gDEMDelegate || gDEMInstance) - { - ChipLogError(AppServer, "DEM Instance or Delegate already exist."); - return CHIP_ERROR_INCORRECT_STATE; - } - - gDEMDelegate = std::make_unique(); - if (!gDEMDelegate) - { - ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementDelegate"); - return CHIP_ERROR_NO_MEMORY; - } - - BitMask featureMap = GetFeatureMapFromCmdLine(); - - /* Manufacturer may optionally not support all features, commands & attributes */ - gDEMInstance = std::make_unique(EndpointId(ENERGY_EVSE_ENDPOINT), *gDEMDelegate, featureMap); - - if (!gDEMInstance) - { - ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementManager"); - gDEMDelegate.reset(); - return CHIP_ERROR_NO_MEMORY; - } - - gDEMDelegate->SetDeviceEnergyManagementInstance(*gDEMInstance); - - CHIP_ERROR err = gDEMInstance->Init(); /* Register Attribute & Command handlers */ - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Init failed on gDEMInstance"); - gDEMInstance.reset(); - gDEMDelegate.reset(); - return err; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR DeviceEnergyManagementShutdown() -{ - /* Do this in the order Instance first, then delegate - * Ensure we call the Instance->Shutdown to free attribute & command handlers first - */ - if (gDEMInstance) - { - /* deregister attribute & command handlers */ - gDEMInstance->Shutdown(); - gDEMInstance.reset(); - } - if (gDEMDelegate) - { - gDEMDelegate.reset(); - } - return CHIP_NO_ERROR; -} - /* * @brief Creates a Delegate and Instance for EVSE cluster * @@ -147,7 +60,7 @@ CHIP_ERROR DeviceEnergyManagementShutdown() * create the Delegate first, then wrap it in the Instance * Then call the Instance->Init() to register the attribute and command handlers */ -CHIP_ERROR EnergyEvseInit() +CHIP_ERROR EnergyEvseInit(chip::EndpointId endpointId) { CHIP_ERROR err; @@ -174,7 +87,7 @@ CHIP_ERROR EnergyEvseInit() /* Manufacturer may optionally not support all features, commands & attributes */ gEvseInstance = std::make_unique( - EndpointId(ENERGY_EVSE_ENDPOINT), *gEvseDelegate, + EndpointId(endpointId), *gEvseDelegate, BitMask(EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kRfid), BitMask(EnergyEvse::OptionalAttributes::kSupportsUserMaximumChargingCurrent, EnergyEvse::OptionalAttributes::kSupportsRandomizationWindow, @@ -232,160 +145,6 @@ CHIP_ERROR EnergyEvseShutdown() return CHIP_NO_ERROR; } -/* - * @brief Creates a Delegate and Instance for PowerTopology clusters - * - * The Instance is a container around the Delegate, so - * create the Delegate first, then wrap it in the Instance - * Then call the Instance->Init() to register the attribute and command handlers - */ -CHIP_ERROR PowerTopologyInit() -{ - CHIP_ERROR err; - - if (gPTDelegate || gPTInstance) - { - ChipLogError(AppServer, "PowerTopology Instance or Delegate already exist."); - return CHIP_ERROR_INCORRECT_STATE; - } - - gPTDelegate = std::make_unique(); - if (!gPTDelegate) - { - ChipLogError(AppServer, "Failed to allocate memory for PowerTopology Delegate"); - return CHIP_ERROR_NO_MEMORY; - } - - gPTInstance = - std::make_unique(EndpointId(ENERGY_EVSE_ENDPOINT), *gPTDelegate, - BitMask(PowerTopology::Feature::kNodeTopology), - BitMask(0)); - - if (!gPTInstance) - { - ChipLogError(AppServer, "Failed to allocate memory for PowerTopology Instance"); - gPTDelegate.reset(); - return CHIP_ERROR_NO_MEMORY; - } - - err = gPTInstance->Init(); /* Register Attribute & Command handlers */ - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Init failed on gPTInstance"); - gPTInstance.reset(); - gPTDelegate.reset(); - return err; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR PowerTopologyShutdown() -{ - /* Do this in the order Instance first, then delegate - * Ensure we call the Instance->Shutdown to free attribute & command handlers first - */ - if (gPTInstance) - { - /* deregister attribute & command handlers */ - gPTInstance->Shutdown(); - gPTInstance.reset(); - } - - if (gPTDelegate) - { - gPTDelegate.reset(); - } - - return CHIP_NO_ERROR; -} - -/* - * @brief Creates a Delegate and Instance for Electrical Power/Energy Measurement clusters - * - * The Instance is a container around the Delegate, so - * create the Delegate first, then wrap it in the Instance - * Then call the Instance->Init() to register the attribute and command handlers - */ -CHIP_ERROR EnergyMeterInit() -{ - CHIP_ERROR err; - - if (gEPMDelegate || gEPMInstance) - { - ChipLogError(AppServer, "EPM Instance or Delegate already exist."); - return CHIP_ERROR_INCORRECT_STATE; - } - - gEPMDelegate = std::make_unique(); - if (!gEPMDelegate) - { - ChipLogError(AppServer, "Failed to allocate memory for EPM Delegate"); - return CHIP_ERROR_NO_MEMORY; - } - - /* 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::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::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) - { - ChipLogError(AppServer, "Failed to allocate memory for EPM Instance"); - gEPMDelegate.reset(); - return CHIP_ERROR_NO_MEMORY; - } - - err = gEPMInstance->Init(); /* Register Attribute & Command handlers */ - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Init failed on gEPMInstance"); - gEPMInstance.reset(); - gEPMDelegate.reset(); - return err; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR EnergyMeterShutdown() -{ - /* Do this in the order Instance first, then delegate - * Ensure we call the Instance->Shutdown to free attribute & command handlers first - */ - if (gEPMInstance) - { - /* deregister attribute & command handlers */ - gEPMInstance->Shutdown(); - gEPMInstance.reset(); - } - - if (gEPMDelegate) - { - gEPMDelegate.reset(); - } - - return CHIP_NO_ERROR; -} - /* * @brief Creates a EVSEManufacturer class to hold the EVSE & DEM clusters * @@ -405,14 +164,14 @@ CHIP_ERROR EVSEManufacturerInit() /* Now create EVSEManufacturer */ gEvseManufacturer = - std::make_unique(gEvseInstance.get(), gEPMInstance.get(), gPTInstance.get(), gDEMInstance.get()); + std::make_unique(gEvseInstance.get(), GetEPMInstance(), GetPTInstance(), GetDEMInstance()); if (!gEvseManufacturer) { ChipLogError(AppServer, "Failed to allocate memory for EvseManufacturer"); return CHIP_ERROR_NO_MEMORY; } - gDEMDelegate.get()->SetDEMManufacturerDelegate(*gEvseManufacturer.get()); + GetDEMDelegate()->SetDEMManufacturerDelegate(*gEvseManufacturer.get()); /* Call Manufacturer specific init */ err = gEvseManufacturer->Init(); @@ -438,32 +197,32 @@ CHIP_ERROR EVSEManufacturerShutdown() return CHIP_NO_ERROR; } -void EvseApplicationInit() +void EvseApplicationInit(chip::EndpointId endpointId) { - if (DeviceEnergyManagementInit() != CHIP_NO_ERROR) + if (DeviceEnergyManagementInit(endpointId) != CHIP_NO_ERROR) { return; } - if (EnergyEvseInit() != CHIP_NO_ERROR) + if (EnergyEvseInit(endpointId) != CHIP_NO_ERROR) { DeviceEnergyManagementShutdown(); return; } - if (EnergyMeterInit() != CHIP_NO_ERROR) + if (ElectricalPowerMeasurementInit(endpointId) != CHIP_NO_ERROR) { DeviceEnergyManagementShutdown(); EnergyEvseShutdown(); return; } - if (PowerTopologyInit() != CHIP_NO_ERROR) + if (PowerTopologyInit(endpointId) != CHIP_NO_ERROR) { EVSEManufacturerShutdown(); DeviceEnergyManagementShutdown(); EnergyEvseShutdown(); - EnergyMeterShutdown(); + ElectricalPowerMeasurementShutdown(); return; } @@ -472,7 +231,7 @@ void EvseApplicationInit() { DeviceEnergyManagementShutdown(); EnergyEvseShutdown(); - EnergyMeterShutdown(); + ElectricalPowerMeasurementShutdown(); return; } } @@ -482,59 +241,12 @@ void EvseApplicationShutdown() ChipLogDetail(AppServer, "Energy Management App (EVSE): ApplicationShutdown()"); /* Shutdown in reverse order that they were created */ - EVSEManufacturerShutdown(); /* Free the EVSEManufacturer */ - PowerTopologyShutdown(); /* Free the PowerTopology */ - EnergyMeterShutdown(); /* Free the Energy Meter */ - EnergyEvseShutdown(); /* Free the EnergyEvse */ - DeviceEnergyManagementShutdown(); /* Free the DEM */ + EVSEManufacturerShutdown(); /* Free the EVSEManufacturer */ + PowerTopologyShutdown(); /* Free the PowerTopology */ + ElectricalPowerMeasurementShutdown(); /* Free the Electrical Power Measurement */ + EnergyEvseShutdown(); /* Free the EnergyEvse */ + DeviceEnergyManagementShutdown(); /* Free the DEM */ Clusters::DeviceEnergyManagementMode::Shutdown(); Clusters::EnergyEvseMode::Shutdown(); } - -void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endpointId) -{ - VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. - VerifyOrDie(!gEEMAttrAccess); - - gEEMAttrAccess = std::make_unique( - BitMask( - ElectricalEnergyMeasurement::Feature::kImportedEnergy, ElectricalEnergyMeasurement::Feature::kExportedEnergy, - ElectricalEnergyMeasurement::Feature::kCumulativeEnergy, ElectricalEnergyMeasurement::Feature::kPeriodicEnergy), - BitMask( - ElectricalEnergyMeasurement::OptionalAttributes::kOptionalAttributeCumulativeEnergyReset)); - - // Create an accuracy entry which is between +/-0.5 and +/- 5% across the range of all possible energy readings - ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type energyAccuracyRanges[] = { - { .rangeMin = 0, - .rangeMax = 1'000'000'000'000'000, // 1 million Mwh - .percentMax = MakeOptional(static_cast(500)), - .percentMin = MakeOptional(static_cast(50)) } - }; - - ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type accuracy = { - .measurementType = MeasurementTypeEnum::kElectricalEnergy, - .measured = true, - .minMeasuredValue = 0, - .maxMeasuredValue = 1'000'000'000'000'000, // 1 million Mwh - .accuracyRanges = - DataModel::List(energyAccuracyRanges) - }; - - // Example of setting CumulativeEnergyReset structure - for now set these to 0 - // but the manufacturer may want to store these in non volatile storage for timestamp (based on epoch_s) - ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type resetStruct = { - .importedResetTimestamp = MakeOptional(MakeNullable(static_cast(0))), - .exportedResetTimestamp = MakeOptional(MakeNullable(static_cast(0))), - .importedResetSystime = MakeOptional(MakeNullable(static_cast(0))), - .exportedResetSystime = MakeOptional(MakeNullable(static_cast(0))), - }; - - if (gEEMAttrAccess) - { - gEEMAttrAccess->Init(); - - SetMeasurementAccuracy(endpointId, accuracy); - SetCumulativeReset(endpointId, MakeOptional(resetStruct)); - } -} 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 17a539dbf13348..56b87970e7fc9f 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 @@ -1,6 +1,6 @@ { "fileFormat": 2, - "featureLevel": 103, + "featureLevel": 104, "creator": "zap", "keyValuePairs": [ { @@ -41,14 +41,16 @@ "code": 22, "profileId": 259, "label": "MA-rootdevice", - "name": "MA-rootdevice" + "name": "MA-rootdevice", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 22, "profileId": 259, "label": "MA-rootdevice", - "name": "MA-rootdevice" + "name": "MA-rootdevice", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -2714,20 +2716,23 @@ "code": 1292, "profileId": 259, "label": "Energy EVSE", - "name": "Energy EVSE" + "name": "Energy EVSE", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 1292, "profileId": 259, "label": "Energy EVSE", - "name": "Energy EVSE" + "name": "Energy EVSE", + "deviceTypeOrder": 0 }, { "code": 1296, "profileId": 259, "label": "MA-electricalsensor", - "name": "MA-electricalsensor" + "name": "MA-electricalsensor", + "deviceTypeOrder": 1 } ], "deviceVersions": [ @@ -3696,227 +3701,6 @@ } ] }, - { - "name": "Water Heater Management", - "code": 148, - "mfgCode": null, - "define": "WATER_HEATER_MANAGEMENT_CLUSTER", - "side": "server", - "enabled": 1, - "apiMaturity": "provisional", - "commands": [ - { - "name": "Boost", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "CancelBoost", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], - "attributes": [ - { - "name": "HeaterTypes", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "WaterHeaterHeatSourceBitmap", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "HeatDemand", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "WaterHeaterHeatSourceBitmap", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "TankVolume", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EstimatedHeatRequired", - "code": 3, - "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": "TankPercentage", - "code": 4, - "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": "BoostState", - "code": 5, - "mfgCode": null, - "side": "server", - "type": "BoostStateEnum", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "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": "AcceptedCommandList", - "code": 65529, - "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": "EventList", - "code": 65530, - "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": "AttributeList", - "code": 65531, - "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": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, { "name": "Device Energy Management", "code": 152, @@ -4999,12 +4783,13 @@ ] }, { - "name": "Water Heater Mode", - "code": 158, + "name": "Device Energy Management Mode", + "code": 159, "mfgCode": null, - "define": "WATER_HEATER_MODE_CLUSTER", + "define": "DEVICE_ENERGY_MANAGEMENT_MODE_CLUSTER", "side": "server", "enabled": 1, + "apiMaturity": "provisional", "commands": [ { "name": "ChangeToMode", @@ -5153,33 +4938,1703 @@ "reportableChange": 0 } ] + } + ] + }, + { + "id": 3, + "name": "Anonymous Endpoint Type", + "deviceTypeRef": { + "code": 1295, + "profileId": 259, + "label": "MA-waterheater", + "name": "MA-waterheater", + "deviceTypeOrder": 0 + }, + "deviceTypes": [ + { + "code": 1295, + "profileId": 259, + "label": "MA-waterheater", + "name": "MA-waterheater", + "deviceTypeOrder": 0 }, { - "name": "Device Energy Management Mode", - "code": 159, - "mfgCode": null, - "define": "DEVICE_ENERGY_MANAGEMENT_MODE_CLUSTER", - "side": "server", - "enabled": 1, - "apiMaturity": "provisional", - "commands": [ - { - "name": "ChangeToMode", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, + "code": 1296, + "profileId": 259, + "label": "MA-electricalsensor", + "name": "MA-electricalsensor", + "deviceTypeOrder": 1 + } + ], + "deviceVersions": [ + 1, + 1 + ], + "deviceIdentifiers": [ + 1295, + 1296 + ], + "deviceTypeName": "MA-waterheater", + "deviceTypeCode": 1295, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "IdentifyTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "IdentifyTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "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": "ServerList", + "code": 1, + "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": "ClientList", + "code": 2, + "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": "PartsList", + "code": 3, + "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": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Electrical Power Measurement", + "code": 144, + "mfgCode": null, + "define": "ELECTRICAL_POWER_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "PowerMode", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PowerModeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NumberOfMeasurementTypes", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Accuracy", + "code": 2, + "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": "Ranges", + "code": 3, + "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": "Voltage", + "code": 4, + "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": "ActiveCurrent", + "code": 5, + "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": "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, + "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": "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, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Electrical Energy Measurement", + "code": 145, + "mfgCode": null, + "define": "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "Accuracy", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "MeasurementAccuracyStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CumulativeEnergyImported", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CumulativeEnergyExported", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PeriodicEnergyImported", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PeriodicEnergyExported", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CumulativeEnergyReset", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "CumulativeEnergyResetStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Water Heater Management", + "code": 148, + "mfgCode": null, + "define": "WATER_HEATER_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", + "commands": [ + { + "name": "Boost", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CancelBoost", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "HeaterTypes", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "WaterHeaterHeatSourceBitmap", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "HeatDemand", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "WaterHeaterHeatSourceBitmap", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TankVolume", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EstimatedHeatRequired", + "code": 3, + "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": "TankPercentage", + "code": 4, + "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": "BoostState", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "BoostStateEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Device Energy Management", + "code": 152, + "mfgCode": null, + "define": "DEVICE_ENERGY_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", + "attributes": [ + { + "name": "ESAType", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "ESATypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ESACanGenerate", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ESAState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "ESAStateEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AbsMinPower", + "code": 3, + "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": "AbsMaxPower", + "code": 4, + "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": "PowerAdjustmentCapability", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "PowerAdjustCapabilityStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Forecast", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "ForecastStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OptOutState", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "OptOutStateEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Power Topology", + "code": 156, + "mfgCode": null, + "define": "POWER_TOPOLOGY_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Water Heater Mode", + "code": 158, + "mfgCode": null, + "define": "WATER_HEATER_MODE_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ChangeToMode", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ChangeToModeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "SupportedModes", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentMode", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "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": "ChangeToModeResponse", - "code": 1, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, - "source": "server", - "isIncoming": 0, - "isEnabled": 1 + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 } - ], + ] + }, + { + "name": "Device Energy Management Mode", + "code": 159, + "mfgCode": null, + "define": "DEVICE_ENERGY_MANAGEMENT_MODE_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", "attributes": [ { "name": "SupportedModes", @@ -5310,6 +6765,170 @@ "reportableChange": 0 } ] + }, + { + "name": "Thermostat", + "code": 513, + "mfgCode": null, + "define": "THERMOSTAT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "SetpointRaiseLower", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "LocalTemperature", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "temperature", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ControlSequenceOfOperation", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "ControlSequenceOfOperationEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SystemMode", + "code": 28, + "mfgCode": null, + "side": "server", + "type": "SystemModeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "7", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] } ] } @@ -5330,6 +6949,14 @@ "endpointId": 1, "networkId": 0, "parentEndpointIdentifier": null + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 2, + "profileId": 259, + "endpointId": 2, + "networkId": 0, + "parentEndpointIdentifier": 0 } ] } \ No newline at end of file diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/include/ElectricalSensorInit.h b/examples/energy-management-app/energy-management-common/energy-reporting/include/ElectricalSensorInit.h new file mode 100644 index 00000000000000..6e0c38bb7d85bb --- /dev/null +++ b/examples/energy-management-app/energy-management-common/energy-reporting/include/ElectricalSensorInit.h @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +chip::app::Clusters::PowerTopology::PowerTopologyInstance * GetPTInstance(); +chip::app::Clusters::ElectricalPowerMeasurement::ElectricalPowerMeasurementInstance * GetEPMInstance(); + +CHIP_ERROR PowerTopologyInit(chip::EndpointId endpointId); +CHIP_ERROR PowerTopologyShutdown(); + +CHIP_ERROR ElectricalPowerMeasurementInit(chip::EndpointId endpointId); +CHIP_ERROR ElectricalPowerMeasurementShutdown(); diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp b/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp new file mode 100644 index 00000000000000..0b568c80597045 --- /dev/null +++ b/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp @@ -0,0 +1,269 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::DataModel; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::DeviceEnergyManagement; +using namespace chip::app::Clusters::ElectricalPowerMeasurement; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement; +using namespace chip::app::Clusters::PowerTopology; + +static std::unique_ptr gEPMDelegate; +static std::unique_ptr gEPMInstance; + +// Electrical Energy Measurement cluster uses ember to initialise +static std::unique_ptr gEEMAttrAccess; + +static std::unique_ptr gPTDelegate; +static std::unique_ptr gPTInstance; + +PowerTopologyInstance * GetPTInstance() +{ + VerifyOrDieWithMsg(gPTInstance.get() != nullptr, AppServer, "PowerTopology instance is null"); + + return gPTInstance.get(); +} + +ElectricalPowerMeasurementInstance * GetEPMInstance() +{ + VerifyOrDieWithMsg(gEPMInstance.get() != nullptr, AppServer, "ElectricalPowerMeasurement instance is null"); + + return gEPMInstance.get(); +} + +/* + * @brief Creates a Delegate and Instance for PowerTopology clusters + * + * The Instance is a container around the Delegate, so + * create the Delegate first, then wrap it in the Instance + * Then call the Instance->Init() to register the attribute and command handlers + */ +CHIP_ERROR PowerTopologyInit(chip::EndpointId endpointId) +{ + CHIP_ERROR err; + + if (gPTDelegate || gPTInstance) + { + ChipLogError(AppServer, "PowerTopology Instance or Delegate already exist."); + return CHIP_ERROR_INCORRECT_STATE; + } + + gPTDelegate = std::make_unique(); + if (!gPTDelegate) + { + ChipLogError(AppServer, "Failed to allocate memory for PowerTopology Delegate"); + return CHIP_ERROR_NO_MEMORY; + } + + gPTInstance = std::make_unique( + EndpointId(endpointId), *gPTDelegate, BitMask(PowerTopology::Feature::kNodeTopology), + BitMask(0)); + + if (!gPTInstance) + { + ChipLogError(AppServer, "Failed to allocate memory for PowerTopology Instance"); + gPTDelegate.reset(); + return CHIP_ERROR_NO_MEMORY; + } + + err = gPTInstance->Init(); /* Register Attribute & Command handlers */ + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Init failed on gPTInstance"); + gPTInstance.reset(); + gPTDelegate.reset(); + return err; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR PowerTopologyShutdown() +{ + /* Do this in the order Instance first, then delegate + * Ensure we call the Instance->Shutdown to free attribute & command handlers first + */ + if (gPTInstance) + { + /* deregister attribute & command handlers */ + gPTInstance->Shutdown(); + gPTInstance.reset(); + } + + if (gPTDelegate) + { + gPTDelegate.reset(); + } + + return CHIP_NO_ERROR; +} + +/* + * @brief Creates a Delegate and Instance for Electrical Power Measurement cluster + * + * The Instance is a container around the Delegate, so + * create the Delegate first, then wrap it in the Instance + * Then call the Instance->Init() to register the attribute and command handlers + */ +CHIP_ERROR ElectricalPowerMeasurementInit(chip::EndpointId endpointId) +{ + CHIP_ERROR err; + + if (gEPMDelegate || gEPMInstance) + { + ChipLogError(AppServer, "EPM Instance or Delegate already exist."); + return CHIP_ERROR_INCORRECT_STATE; + } + + gEPMDelegate = std::make_unique(); + if (!gEPMDelegate) + { + ChipLogError(AppServer, "Failed to allocate memory for EPM Delegate"); + return CHIP_ERROR_NO_MEMORY; + } + + /* 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(endpointId), *gEPMDelegate, + 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::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) + { + ChipLogError(AppServer, "Failed to allocate memory for EPM Instance"); + gEPMDelegate.reset(); + return CHIP_ERROR_NO_MEMORY; + } + + err = gEPMInstance->Init(); /* Register Attribute & Command handlers */ + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Init failed on gEPMInstance"); + gEPMInstance.reset(); + gEPMDelegate.reset(); + return err; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR ElectricalPowerMeasurementShutdown() +{ + /* Do this in the order Instance first, then delegate + * Ensure we call the Instance->Shutdown to free attribute & command handlers first + */ + if (gEPMInstance) + { + /* deregister attribute & command handlers */ + gEPMInstance->Shutdown(); + gEPMInstance.reset(); + } + + if (gEPMDelegate) + { + gEPMDelegate.reset(); + } + + return CHIP_NO_ERROR; +} + +void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endpointId) +{ + VerifyOrDie(endpointId == kEvseEndpoint || endpointId == kWaterHeaterEndpoint); + + /* emberAfElectricalEnergyMeasurementClusterInitCallback() is called for all endpoints + that include the EEM endpoint (even the one we disable dynamically). So here, we only + proceed when it's called for the right endpoint determined by GetMainAppEndpointId() + (a cmd line argument or #define). + */ + if (endpointId != GetMainAppEndpointId()) + { + return; + } + + gEEMAttrAccess = std::make_unique( + BitMask( + ElectricalEnergyMeasurement::Feature::kImportedEnergy, ElectricalEnergyMeasurement::Feature::kExportedEnergy, + ElectricalEnergyMeasurement::Feature::kCumulativeEnergy, ElectricalEnergyMeasurement::Feature::kPeriodicEnergy), + BitMask( + ElectricalEnergyMeasurement::OptionalAttributes::kOptionalAttributeCumulativeEnergyReset)); + + // Create an accuracy entry which is between +/-0.5 and +/- 5% across the range of all possible energy readings + ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type energyAccuracyRanges[] = { + { .rangeMin = 0, + .rangeMax = 1'000'000'000'000'000, // 1 million Mwh + .percentMax = MakeOptional(static_cast(500)), + .percentMin = MakeOptional(static_cast(50)) } + }; + + ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type accuracy = { + .measurementType = MeasurementTypeEnum::kElectricalEnergy, + .measured = true, + .minMeasuredValue = 0, + .maxMeasuredValue = 1'000'000'000'000'000, // 1 million Mwh + .accuracyRanges = + DataModel::List(energyAccuracyRanges) + }; + + // Example of setting CumulativeEnergyReset structure - for now set these to 0 + // but the manufacturer may want to store these in non volatile storage for timestamp (based on epoch_s) + ElectricalEnergyMeasurement::Structs::CumulativeEnergyResetStruct::Type resetStruct = { + .importedResetTimestamp = MakeOptional(MakeNullable(static_cast(0))), + .exportedResetTimestamp = MakeOptional(MakeNullable(static_cast(0))), + .importedResetSystime = MakeOptional(MakeNullable(static_cast(0))), + .exportedResetSystime = MakeOptional(MakeNullable(static_cast(0))), + }; + + if (gEEMAttrAccess) + { + gEEMAttrAccess->Init(); + + SetMeasurementAccuracy(endpointId, accuracy); + SetCumulativeReset(endpointId, MakeOptional(resetStruct)); + } +} diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp b/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp index bffe3c900d29af..cbe0a4f51bb1d6 100644 --- a/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp +++ b/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h b/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h index 819ff9e4d160ca..65c226d843b785 100644 --- a/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h +++ b/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h @@ -23,7 +23,7 @@ namespace app { namespace Clusters { namespace WaterHeaterManagement { -void FullWhmApplicationInit(); +void FullWhmApplicationInit(EndpointId endpointId); void FullWhmApplicationShutdown(); } // namespace WaterHeaterManagement diff --git a/examples/energy-management-app/energy-management-common/water-heater/include/WhmMain.h b/examples/energy-management-app/energy-management-common/water-heater/include/WhmMain.h index 34f04d8cbb6b8f..d0fa8d97f5cc14 100644 --- a/examples/energy-management-app/energy-management-common/water-heater/include/WhmMain.h +++ b/examples/energy-management-app/energy-management-common/water-heater/include/WhmMain.h @@ -25,7 +25,7 @@ namespace app { namespace Clusters { namespace WaterHeaterManagement { -CHIP_ERROR WhmApplicationInit(); +CHIP_ERROR WhmApplicationInit(EndpointId endpointId); CHIP_ERROR WhmApplicationShutdown(); } // namespace WaterHeaterManagement diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp index 0c8e44ac7cb248..fac3068e933806 100644 --- a/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp +++ b/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ #include #include -#include +#include #include #include @@ -45,26 +46,26 @@ namespace app { namespace Clusters { namespace WaterHeaterManagement { -void FullWhmApplicationInit() +void FullWhmApplicationInit(EndpointId endpointId) { - ReturnOnFailure(WhmApplicationInit()); + ReturnOnFailure(WhmApplicationInit(endpointId)); - if (DeviceEnergyManagementInit() != CHIP_NO_ERROR) + if (DeviceEnergyManagementInit(endpointId) != CHIP_NO_ERROR) { WhmApplicationShutdown(); return; } - if (EnergyMeterInit() != CHIP_NO_ERROR) + if (ElectricalPowerMeasurementInit(endpointId) != CHIP_NO_ERROR) { DeviceEnergyManagementShutdown(); WhmApplicationShutdown(); return; } - if (PowerTopologyInit() != CHIP_NO_ERROR) + if (PowerTopologyInit(endpointId) != CHIP_NO_ERROR) { - EnergyMeterShutdown(); + ElectricalPowerMeasurementShutdown(); DeviceEnergyManagementShutdown(); WhmApplicationShutdown(); return; @@ -86,9 +87,9 @@ void FullWhmApplicationShutdown() ChipLogDetail(AppServer, "Energy Management App (WaterHeater): ApplicationShutdown()"); /* Shutdown in reverse order that they were created */ - PowerTopologyShutdown(); /* Free the PowerTopology */ - EnergyMeterShutdown(); /* Free the Energy Meter */ - DeviceEnergyManagementShutdown(); /* Free the DEM */ + PowerTopologyShutdown(); /* Free the PowerTopology */ + ElectricalPowerMeasurementShutdown(); /* Free the Energy Meter */ + DeviceEnergyManagementShutdown(); /* Free the DEM */ WhmApplicationShutdown(); Clusters::DeviceEnergyManagementMode::Shutdown(); diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp index 038e332bd31aff..b53da3c7d69251 100644 --- a/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp +++ b/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp @@ -24,8 +24,6 @@ #include #include -static constexpr int WHM_ENDPOINT = 1; - using namespace chip; using namespace chip::app; using namespace chip::app::DataModel; @@ -53,7 +51,7 @@ WhmManufacturer * GetWhmManufacturer() * create the Delegate first, then wrap it in the Instance * Then call the Instance->Init() to register the attribute and command handlers */ -CHIP_ERROR WhmInit() +CHIP_ERROR WhmInit(EndpointId endpointId) { CHIP_ERROR err; @@ -63,7 +61,7 @@ CHIP_ERROR WhmInit() return CHIP_ERROR_INCORRECT_STATE; } - gWhmDelegate = std::make_unique(WHM_ENDPOINT); + gWhmDelegate = std::make_unique(endpointId); if (!gWhmDelegate) { ChipLogError(AppServer, "Failed to allocate memory for WaterHeaterManagementDelegate"); @@ -72,7 +70,7 @@ CHIP_ERROR WhmInit() /* Manufacturer may optionally not support all features, commands & attributes */ gWhmInstance = std::make_unique( - EndpointId(WHM_ENDPOINT), *gWhmDelegate, BitMask(Feature::kEnergyManagement, Feature::kTankPercent)); + EndpointId(endpointId), *gWhmDelegate, BitMask(Feature::kEnergyManagement, Feature::kTankPercent)); if (!gWhmInstance) { ChipLogError(AppServer, "Failed to allocate memory for WaterHeaterManagementInstance"); @@ -167,9 +165,9 @@ CHIP_ERROR WhmManufacturerShutdown() return CHIP_NO_ERROR; } -CHIP_ERROR WhmApplicationInit() +CHIP_ERROR WhmApplicationInit(EndpointId endpointId) { - ReturnErrorOnFailure(WhmInit()); + ReturnErrorOnFailure(WhmInit(endpointId)); /* Do this last so that the instances for other clusters can be wrapped inside */ ReturnErrorOnFailure(WhmManufacturerInit()); diff --git a/examples/energy-management-app/esp32/main/CMakeLists.txt b/examples/energy-management-app/esp32/main/CMakeLists.txt index e5459616238d3d..f1b73211ccab2e 100644 --- a/examples/energy-management-app/esp32/main/CMakeLists.txt +++ b/examples/energy-management-app/esp32/main/CMakeLists.txt @@ -58,6 +58,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/device-energy-management-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index d235fa4291ac98..b14139e3b7cb22 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -43,6 +43,7 @@ #include "nvs_flash.h" #include "shell_extension/launch.h" #include "shell_extension/openthread_cli_register.h" +#include #include #include #include @@ -80,6 +81,7 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace chip::app::Clusters::WaterHeaterManagement; +using namespace chip::app::Clusters::DeviceEnergyManagement; #if CONFIG_ENABLE_ESP_INSIGHTS_TRACE extern const char insights_auth_key_start[] asm("_binary_insights_auth_key_txt_start"); @@ -146,6 +148,15 @@ chip::BitMask GetFeatureMapFromCmdLine() return sFeatureMap; } +EndpointId GetMainAppEndpointId() +{ +#if defined(CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) + return kWaterHeaterEndpoint; +#else + return kEvseEndpoint; +#endif +} + } // namespace DeviceEnergyManagement } // namespace Clusters } // namespace app @@ -160,11 +171,12 @@ void ApplicationInit() { ESP_LOGD(TAG, "Energy Management App: ApplicationInit()"); #if CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE - EvseApplicationInit(); + + EvseApplicationInit(kEvseEndpoint); #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE - FullWhmApplicationInit(); + FullWhmApplicationInit(kWaterHeaterEndpoint); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE } diff --git a/examples/energy-management-app/linux/BUILD.gn b/examples/energy-management-app/linux/BUILD.gn index a9d41a1e76d033..5ebb66f395dc37 100644 --- a/examples/energy-management-app/linux/BUILD.gn +++ b/examples/energy-management-app/linux/BUILD.gn @@ -35,6 +35,7 @@ config("includes") { executable("chip-energy-management-app") { sources = [ "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp", + "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementManager.cpp", @@ -48,6 +49,7 @@ executable("chip-energy-management-app") { "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseTargetsStore.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp", + "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/EnergyReportingEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/PowerTopologyDelegate.cpp", diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index 7a6312538ada45..55c472cf62f82f 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -18,8 +18,10 @@ #include #include +#include #include #include +#include #include using namespace chip; @@ -39,10 +41,10 @@ static bool EnergyAppOptionHandler(const char * aProgram, chip::ArgParser::Optio constexpr uint16_t kOptionApplication = 0xffd0; constexpr uint16_t kOptionFeatureMap = 0xffd1; -constexpr const char * kEvseApp = "evse"; -constexpr const char * kWhmApp = "water-heater"; - -constexpr const char * kValidApps[] = { kEvseApp, kWhmApp }; +constexpr const char * kEvseApp = "evse"; +constexpr const char * kWhmApp = "water-heater"; +constexpr const char * kValidApps[] = { kEvseApp, kWhmApp }; +constexpr EndpointId kValidEEMEndpoints[] = { kEvseEndpoint, kWaterHeaterEndpoint }; // Define the chip::ArgParser command line structures for extending the command line to support the // energy apps @@ -70,12 +72,18 @@ static chip::BitMask sFeatureMap(Feature::kPowerAdjustment, Feature::kP // Make EVSE the default app static const char * spApp = kEvseApp; +EndpointId eemEndpoint = kEvseEndpoint; chip::BitMask GetFeatureMapFromCmdLine() { return sFeatureMap; } +EndpointId GetMainAppEndpointId() +{ + return eemEndpoint; +} + } // namespace DeviceEnergyManagement } // namespace Clusters } // namespace app @@ -101,11 +109,15 @@ void ApplicationInit() ChipLogDetail(AppServer, "Energy Management App: ApplicationInit()"); if (strcmp(spApp, kEvseApp) == 0) { - EvseApplicationInit(); + EvseApplicationInit(kEvseEndpoint); + // Disable Water Heater Endpoint + emberAfEndpointEnableDisable(kWaterHeaterEndpoint, false); } else if (strcmp(spApp, kWhmApp) == 0) { - FullWhmApplicationInit(); + FullWhmApplicationInit(kWaterHeaterEndpoint); + // Disable EVSE Endpoint + emberAfEndpointEnableDisable(kEvseEndpoint, false); } else { @@ -134,7 +146,8 @@ static bool EnergyAppOptionHandler(const char * aProgram, chip::ArgParser::Optio { if (strcmp(kValidApps[idx], aValue) == 0) { - spApp = kValidApps[idx]; + spApp = kValidApps[idx]; + eemEndpoint = kValidEEMEndpoints[idx]; break; } } diff --git a/examples/energy-management-app/silabs/BUILD.gn b/examples/energy-management-app/silabs/BUILD.gn index 624cfff6250a85..01f9872bf64c9d 100644 --- a/examples/energy-management-app/silabs/BUILD.gn +++ b/examples/energy-management-app/silabs/BUILD.gn @@ -167,6 +167,7 @@ silabs_executable("energy-management-app") { sources = [ "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp", + "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementManager.cpp", @@ -180,6 +181,7 @@ silabs_executable("energy-management-app") { "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseTargetsStore.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp", + "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/EnergyReportingEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/PowerTopologyDelegate.cpp", diff --git a/examples/energy-management-app/silabs/src/AppTask.cpp b/examples/energy-management-app/silabs/src/AppTask.cpp index 42069a85b5de84..2f7b89b19fdda7 100644 --- a/examples/energy-management-app/silabs/src/AppTask.cpp +++ b/examples/energy-management-app/silabs/src/AppTask.cpp @@ -46,6 +46,7 @@ #include +#include #include #ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED @@ -123,6 +124,15 @@ chip::BitMask GetFeatureMapFromCmdLine() return sFeatureMap; } +EndpointId GetMainAppEndpointId() +{ +#if defined(SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) + return kWaterHeaterEndpoint; +#else + return kEvseEndpoint; +#endif +} + } // namespace DeviceEnergyManagement } // namespace Clusters } // namespace app @@ -137,13 +147,13 @@ void ApplicationInit() #if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE SILABS_LOG("energy-management-example EVSE starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); - EvseApplicationInit(); + EvseApplicationInit(kEvseEndpoint); #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE SILABS_LOG("energy-management-example WaterHeater starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); - FullWhmApplicationInit(); + FullWhmApplicationInit(kWaterHeaterEndpoint); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE SILABS_LOG("=================================================="); From ac115599beb3cc34237a05b7654b03e5fbfa09f1 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 22 Oct 2024 20:44:05 +0000 Subject: [PATCH 04/23] Use anon namespace instead of static. --- .../device-energy-management/src/DEMInit.cpp | 8 ++++++-- .../src/DEMTestEventTriggers.cpp | 19 +++++++++++-------- .../src/device-energy-management-mode.cpp | 4 ++++ .../src/ElectricalSensorInit.cpp | 14 +++++++++----- .../water-heater/src/water-heater-mode.cpp | 7 +++++-- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp index b44a98810c6906..c555af7d1d78cd 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp @@ -40,8 +40,12 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::DeviceEnergyManagement; -static std::unique_ptr gDEMDelegate; -static std::unique_ptr gDEMInstance; +namespace { + +std::unique_ptr gDEMDelegate; +std::unique_ptr gDEMInstance; + +} // namespace DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate() { diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp index 11a02c097d4f47..bc64f301ccf9fb 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp @@ -28,19 +28,22 @@ using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::DeviceEnergyManagement; +namespace { -static constexpr uint16_t MAX_SLOTS = 10; -static constexpr uint16_t MAX_POWER_ADJUSTMENTS = 5; +constexpr uint16_t MAX_SLOTS = 10; +constexpr uint16_t MAX_POWER_ADJUSTMENTS = 5; -static chip::app::Clusters::DeviceEnergyManagement::Structs::SlotStruct::Type sSlots[MAX_SLOTS]; -static chip::app::Clusters::DeviceEnergyManagement::Structs::ForecastStruct::Type sForecastStruct; -static chip::app::DataModel::Nullable sForecast; +chip::app::Clusters::DeviceEnergyManagement::Structs::SlotStruct::Type sSlots[MAX_SLOTS]; +chip::app::Clusters::DeviceEnergyManagement::Structs::ForecastStruct::Type sForecastStruct; +chip::app::DataModel::Nullable sForecast; -static chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustStruct::Type sPowerAdjustments[MAX_POWER_ADJUSTMENTS]; -static chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::Type sPowerAdjustCapabilityStruct; -static chip::app::DataModel::Nullable +chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustStruct::Type sPowerAdjustments[MAX_POWER_ADJUSTMENTS]; +chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::Type sPowerAdjustCapabilityStruct; +chip::app::DataModel::Nullable sPowerAdjustmentCapability; +} // namespace + CHIP_ERROR ConfigureForecast(uint16_t numSlots) { uint32_t chipEpoch = 0; diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp index 21113a1b33f9a4..ba959dd029f8c2 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp @@ -29,9 +29,13 @@ template using List = chip::app::DataModel::List; using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type; +namespace { + static std::unique_ptr gDeviceEnergyManagementModeDelegate; static std::unique_ptr gDeviceEnergyManagementModeInstance; +} // namespace + CHIP_ERROR DeviceEnergyManagementModeDelegate::Init() { return CHIP_NO_ERROR; diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp b/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp index 0b568c80597045..c2b9b0944e8ac0 100644 --- a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp +++ b/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp @@ -36,14 +36,18 @@ using namespace chip::app::Clusters::ElectricalPowerMeasurement; using namespace chip::app::Clusters::ElectricalEnergyMeasurement; using namespace chip::app::Clusters::PowerTopology; -static std::unique_ptr gEPMDelegate; -static std::unique_ptr gEPMInstance; +namespace { + +std::unique_ptr gEPMDelegate; +std::unique_ptr gEPMInstance; // Electrical Energy Measurement cluster uses ember to initialise -static std::unique_ptr gEEMAttrAccess; +std::unique_ptr gEEMAttrAccess; + +std::unique_ptr gPTDelegate; +std::unique_ptr gPTInstance; -static std::unique_ptr gPTDelegate; -static std::unique_ptr gPTInstance; +} // namespace PowerTopologyInstance * GetPTInstance() { diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp index 9c4121fb70d668..a22ee7254c3b8e 100755 --- a/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp +++ b/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp @@ -24,9 +24,12 @@ using chip::Protocols::InteractionModel::Status; template using List = chip::app::DataModel::List; using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type; +namespace { -static ExampleWaterHeaterModeDelegate * gWaterHeaterModeDelegate = nullptr; -static ModeBase::Instance * gWaterHeaterModeInstance = nullptr; +ExampleWaterHeaterModeDelegate * gWaterHeaterModeDelegate = nullptr; +ModeBase::Instance * gWaterHeaterModeInstance = nullptr; + +} // namespace CHIP_ERROR ExampleWaterHeaterModeDelegate::Init() { From f05afffc450c74073c779dc0214144da79ded618 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 22 Oct 2024 20:55:19 +0000 Subject: [PATCH 05/23] disable enpoint on esp32 and silabs --- examples/energy-management-app/esp32/main/main.cpp | 5 +++++ examples/energy-management-app/silabs/src/AppTask.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index b14139e3b7cb22..92b77f0801b717 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -173,10 +174,14 @@ void ApplicationInit() #if CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE EvseApplicationInit(kEvseEndpoint); + // Disable Water Heater Endpoint + emberAfEndpointEnableDisable(kWaterHeaterEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE FullWhmApplicationInit(kWaterHeaterEndpoint); + // Disable EVSE Endpoint + emberAfEndpointEnableDisable(kEvseEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE } diff --git a/examples/energy-management-app/silabs/src/AppTask.cpp b/examples/energy-management-app/silabs/src/AppTask.cpp index 2f7b89b19fdda7..1303e3bc016347 100644 --- a/examples/energy-management-app/silabs/src/AppTask.cpp +++ b/examples/energy-management-app/silabs/src/AppTask.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -148,12 +149,16 @@ void ApplicationInit() SILABS_LOG("energy-management-example EVSE starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); EvseApplicationInit(kEvseEndpoint); + // Disable Water Heater Endpoint + emberAfEndpointEnableDisable(kWaterHeaterEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE SILABS_LOG("energy-management-example WaterHeater starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); FullWhmApplicationInit(kWaterHeaterEndpoint); + // Disable EVSE Endpoint + emberAfEndpointEnableDisable(kEvseEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE SILABS_LOG("=================================================="); From f827e4ab26b48a7e45e63294184cdf0ee06c1066 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 24 Oct 2024 18:27:23 +0000 Subject: [PATCH 06/23] address Tennessee's PR feedback --- .../DEMInit.h => common/include/CommonMain.h} | 12 +- .../src/CommonMain.cpp} | 158 ++++++++++++++++-- .../device-energy-management/src/DEMInit.cpp | 130 -------------- .../src/DEMTestEventTriggers.cpp | 3 +- .../energy-evse/include/EnergyEvseMain.h | 17 +- .../energy-evse/src/EnergyEvseMain.cpp | 68 +------- .../energy-reporting/src/FakeReadings.cpp | 2 +- .../water-heater/include/WaterHeaterMain.h | 32 ---- .../water-heater/src/WaterHeaterMain.cpp | 102 ----------- .../energy-management-app/esp32/main/main.cpp | 13 +- examples/energy-management-app/linux/BUILD.gn | 4 +- examples/energy-management-app/linux/main.cpp | 6 +- .../energy-management-app/silabs/BUILD.gn | 4 +- .../silabs/src/AppTask.cpp | 9 +- 14 files changed, 187 insertions(+), 373 deletions(-) rename examples/energy-management-app/energy-management-common/{device-energy-management/include/DEMInit.h => common/include/CommonMain.h} (66%) rename examples/energy-management-app/energy-management-common/{energy-reporting/src/ElectricalSensorInit.cpp => common/src/CommonMain.cpp} (66%) delete mode 100644 examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp delete mode 100644 examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h delete mode 100644 examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/include/DEMInit.h b/examples/energy-management-app/energy-management-common/common/include/CommonMain.h similarity index 66% rename from examples/energy-management-app/energy-management-common/device-energy-management/include/DEMInit.h rename to examples/energy-management-app/energy-management-common/common/include/CommonMain.h index 8662ec9f6fcae4..0cb340cfa570ad 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/include/DEMInit.h +++ b/examples/energy-management-app/energy-management-common/common/include/CommonMain.h @@ -20,10 +20,16 @@ #include #include +#include +#include #include -CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId); -CHIP_ERROR DeviceEnergyManagementShutdown(); +void EvseApplicationInit(chip::EndpointId endpointId); +void EvseApplicationShutdown(); +void WaterHeaterApplicationInit(chip::EndpointId endpointId); +void WaterHeaterApplicationShutdown(); + +// The DEM Delegate is used for the TestEventTriggers which are functions called outside of a class/init context +// thus have no simple way to inject this dependency, so use the Getter here. chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate(); -chip::app::Clusters::DeviceEnergyManagementManager * GetDEMInstance(); diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp b/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp similarity index 66% rename from examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp rename to examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp index c2b9b0944e8ac0..4d8a43ad1da027 100644 --- a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp +++ b/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp @@ -16,16 +16,23 @@ * limitations under the License. */ +#include "EnergyManagementAppCmdLineOptions.h" +#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include using namespace chip; using namespace chip::app; @@ -35,32 +42,85 @@ using namespace chip::app::Clusters::DeviceEnergyManagement; using namespace chip::app::Clusters::ElectricalPowerMeasurement; using namespace chip::app::Clusters::ElectricalEnergyMeasurement; using namespace chip::app::Clusters::PowerTopology; +using namespace chip::app::Clusters::WaterHeaterManagement; namespace { +std::unique_ptr gDEMDelegate; +std::unique_ptr gDEMInstance; std::unique_ptr gEPMDelegate; std::unique_ptr gEPMInstance; - +std::unique_ptr gPTDelegate; +std::unique_ptr gPTInstance; // Electrical Energy Measurement cluster uses ember to initialise std::unique_ptr gEEMAttrAccess; -std::unique_ptr gPTDelegate; -std::unique_ptr gPTInstance; +/* + * @brief Creates a Delegate and Instance for DEM + * + * The Instance is a container around the Delegate, so + * create the Delegate first, then wrap it in the Instance + * Then call the Instance->Init() to register the attribute and command handlers + */ +CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId) +{ + // TODO: support both EVSE and WaterHeater endpoints + if (gDEMDelegate || gDEMInstance) + { + ChipLogError(AppServer, "DEM Instance or Delegate already exist."); + return CHIP_ERROR_INCORRECT_STATE; + } -} // namespace + gDEMDelegate = std::make_unique(); + if (!gDEMDelegate) + { + ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementDelegate"); + return CHIP_ERROR_NO_MEMORY; + } -PowerTopologyInstance * GetPTInstance() -{ - VerifyOrDieWithMsg(gPTInstance.get() != nullptr, AppServer, "PowerTopology instance is null"); + chip::BitMask featureMap = GetFeatureMapFromCmdLine(); - return gPTInstance.get(); + /* Manufacturer may optionally not support all features, commands & attributes */ + gDEMInstance = std::make_unique(EndpointId(endpointId), *gDEMDelegate, featureMap); + + if (!gDEMInstance) + { + ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementManager"); + gDEMDelegate.reset(); + return CHIP_ERROR_NO_MEMORY; + } + + gDEMDelegate->SetDeviceEnergyManagementInstance(*gDEMInstance); + + CHIP_ERROR err = gDEMInstance->Init(); /* Register Attribute & Command handlers */ + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Init failed on gDEMInstance"); + gDEMInstance.reset(); + gDEMDelegate.reset(); + return err; + } + + return CHIP_NO_ERROR; } -ElectricalPowerMeasurementInstance * GetEPMInstance() +CHIP_ERROR DeviceEnergyManagementShutdown() { - VerifyOrDieWithMsg(gEPMInstance.get() != nullptr, AppServer, "ElectricalPowerMeasurement instance is null"); - - return gEPMInstance.get(); + // TODO: support both EVSE and WaterHeater endpoints + /* Do this in the order Instance first, then delegate + * Ensure we call the Instance->Shutdown to free attribute & command handlers first + */ + if (gDEMInstance) + { + /* deregister attribute & command handlers */ + gDEMInstance->Shutdown(); + gDEMInstance.reset(); + } + if (gDEMDelegate) + { + gDEMDelegate.reset(); + } + return CHIP_NO_ERROR; } /* @@ -216,6 +276,8 @@ CHIP_ERROR ElectricalPowerMeasurementShutdown() return CHIP_NO_ERROR; } +} // namespace + void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endpointId) { VerifyOrDie(endpointId == kEvseEndpoint || endpointId == kWaterHeaterEndpoint); @@ -271,3 +333,65 @@ void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endp SetCumulativeReset(endpointId, MakeOptional(resetStruct)); } } + +DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate() +{ + VerifyOrDieWithMsg(gDEMDelegate.get() != nullptr, AppServer, "DEM Delegate is null"); + + return gDEMDelegate.get(); +} + +void EvseApplicationInit(chip::EndpointId endpointId) +{ + // Common Clusters Init + VerifyOrDie(DeviceEnergyManagementInit(endpointId) == CHIP_NO_ERROR); + VerifyOrDie(ElectricalPowerMeasurementInit(endpointId) == CHIP_NO_ERROR); + VerifyOrDie(PowerTopologyInit(endpointId) == CHIP_NO_ERROR); + VerifyOrDie(EnergyEvseInit(endpointId) == CHIP_NO_ERROR); + VerifyOrDie(EVSEManufacturerInit(*gEPMInstance.get(), *gPTInstance.get(), *gDEMInstance.get(), *gDEMDelegate.get()) == + CHIP_NO_ERROR); +} + +void EvseApplicationShutdown() +{ + ChipLogDetail(AppServer, "Energy Management App (EVSE): ApplicationShutdown()"); + + /* Shutdown in reverse order that they were created */ + EVSEManufacturerShutdown(); /* Free the EVSEManufacturer */ + PowerTopologyShutdown(); /* Free the PowerTopology */ + ElectricalPowerMeasurementShutdown(); /* Free the Electrical Power Measurement */ + EnergyEvseShutdown(); /* Free the EnergyEvse */ + DeviceEnergyManagementShutdown(); /* Free the DEM */ + + Clusters::DeviceEnergyManagementMode::Shutdown(); + Clusters::EnergyEvseMode::Shutdown(); +} + +void WaterHeaterApplicationInit(EndpointId endpointId) +{ + VerifyOrDie(WhmApplicationInit(endpointId) == CHIP_NO_ERROR); + + /* For Device Energy Management we need the ESA to be Online and ready to accept commands */ + + gDEMDelegate->SetESAState(ESAStateEnum::kOnline); + gDEMDelegate->SetESAType(ESATypeEnum::kWaterHeating); + gDEMDelegate->SetDEMManufacturerDelegate(*GetWhmManufacturer()); + + // Set the abs min and max power + gDEMDelegate->SetAbsMinPower(1200000); // 1.2KW + gDEMDelegate->SetAbsMaxPower(7600000); // 7.6KW +} + +void WaterHeaterApplicationShutdown() +{ + ChipLogDetail(AppServer, "Energy Management App (WaterHeater): ApplicationShutdown()"); + + /* Shutdown in reverse order that they were created */ + PowerTopologyShutdown(); /* Free the PowerTopology */ + ElectricalPowerMeasurementShutdown(); /* Free the Energy Meter */ + DeviceEnergyManagementShutdown(); /* Free the DEM */ + WhmApplicationShutdown(); + + Clusters::DeviceEnergyManagementMode::Shutdown(); + Clusters::WaterHeaterMode::Shutdown(); +} diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp deleted file mode 100644 index c555af7d1d78cd..00000000000000 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Copyright (c) 2024 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "EnergyManagementAppCmdLineOptions.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::Clusters; -using namespace chip::app::Clusters::DeviceEnergyManagement; - -namespace { - -std::unique_ptr gDEMDelegate; -std::unique_ptr gDEMInstance; - -} // namespace - -DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate() -{ - VerifyOrDieWithMsg(gDEMDelegate.get() != nullptr, AppServer, "DEM Delegate is null"); - - return gDEMDelegate.get(); -} - -DeviceEnergyManagementManager * GetDEMInstance() -{ - VerifyOrDieWithMsg(gDEMInstance.get() != nullptr, AppServer, "DEM Instance is null"); - - return gDEMInstance.get(); -} - -/* - * @brief Creates a Delegate and Instance for DEM - * - * The Instance is a container around the Delegate, so - * create the Delegate first, then wrap it in the Instance - * Then call the Instance->Init() to register the attribute and command handlers - */ -CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId) -{ - // TODO: support both EVSE and WaterHeater endpoints - if (gDEMDelegate || gDEMInstance) - { - ChipLogError(AppServer, "DEM Instance or Delegate already exist."); - return CHIP_ERROR_INCORRECT_STATE; - } - - gDEMDelegate = std::make_unique(); - if (!gDEMDelegate) - { - ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementDelegate"); - return CHIP_ERROR_NO_MEMORY; - } - - chip::BitMask featureMap = GetFeatureMapFromCmdLine(); - - /* Manufacturer may optionally not support all features, commands & attributes */ - gDEMInstance = std::make_unique(EndpointId(endpointId), *gDEMDelegate, featureMap); - - if (!gDEMInstance) - { - ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementManager"); - gDEMDelegate.reset(); - return CHIP_ERROR_NO_MEMORY; - } - - gDEMDelegate->SetDeviceEnergyManagementInstance(*gDEMInstance); - - CHIP_ERROR err = gDEMInstance->Init(); /* Register Attribute & Command handlers */ - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Init failed on gDEMInstance"); - gDEMInstance.reset(); - gDEMDelegate.reset(); - return err; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR DeviceEnergyManagementShutdown() -{ - // TODO: support both EVSE and WaterHeater endpoints - /* Do this in the order Instance first, then delegate - * Ensure we call the Instance->Shutdown to free attribute & command handlers first - */ - if (gDEMInstance) - { - /* deregister attribute & command handlers */ - gDEMInstance->Shutdown(); - gDEMInstance.reset(); - } - if (gDEMDelegate) - { - gDEMDelegate.reset(); - } - return CHIP_NO_ERROR; -} diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp index bc64f301ccf9fb..3636c6f206504a 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp @@ -16,9 +16,10 @@ * limitations under the License. */ -#include +#include #include #include +#include #include diff --git a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h index f7ee56fc2c5f8c..02427aec4dab92 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h +++ b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h @@ -18,7 +18,20 @@ #pragma once +#include +#include +#include +#include #include -void EvseApplicationInit(chip::EndpointId endpointId); -void EvseApplicationShutdown(); +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::ElectricalPowerMeasurement; +using namespace chip::app::Clusters::PowerTopology; +using namespace chip::app::Clusters::DeviceEnergyManagement; + +CHIP_ERROR EnergyEvseInit(chip::EndpointId endpointId); +CHIP_ERROR EnergyEvseShutdown(); + +CHIP_ERROR EVSEManufacturerInit(ElectricalPowerMeasurementInstance & epmInstance, PowerTopologyInstance & ptInstance, + DeviceEnergyManagementManager & demInstance, DeviceEnergyManagementDelegate & demDelegate); +CHIP_ERROR EVSEManufacturerShutdown(); diff --git a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp index f2e7748ba76f82..bf7092bc41b155 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp +++ b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp @@ -18,7 +18,7 @@ #include "EnergyManagementAppCmdLineOptions.h" -#include +#include #include #include #include @@ -41,7 +41,11 @@ using namespace chip; using namespace chip::app; using namespace chip::app::DataModel; using namespace chip::app::Clusters; +using namespace chip::app::Clusters::DeviceEnergyManagement; +using namespace chip::app::Clusters::ElectricalPowerMeasurement; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement; using namespace chip::app::Clusters::EnergyEvse; +using namespace chip::app::Clusters::PowerTopology; static std::unique_ptr gEvseDelegate; static std::unique_ptr gEvseTargetsDelegate; @@ -152,7 +156,8 @@ CHIP_ERROR EnergyEvseShutdown() * create the Delegate first, then wrap it in the Instance * Then call the Instance->Init() to register the attribute and command handlers */ -CHIP_ERROR EVSEManufacturerInit() +CHIP_ERROR EVSEManufacturerInit(ElectricalPowerMeasurementInstance & epmInstance, PowerTopologyInstance & ptInstance, + DeviceEnergyManagementManager & demInstance, DeviceEnergyManagementDelegate & demDelegate) { CHIP_ERROR err; @@ -163,15 +168,14 @@ CHIP_ERROR EVSEManufacturerInit() } /* Now create EVSEManufacturer */ - gEvseManufacturer = - std::make_unique(gEvseInstance.get(), GetEPMInstance(), GetPTInstance(), GetDEMInstance()); + gEvseManufacturer = std::make_unique(gEvseInstance.get(), &epmInstance, &ptInstance, &demInstance); if (!gEvseManufacturer) { ChipLogError(AppServer, "Failed to allocate memory for EvseManufacturer"); return CHIP_ERROR_NO_MEMORY; } - GetDEMDelegate()->SetDEMManufacturerDelegate(*gEvseManufacturer.get()); + demDelegate.SetDEMManufacturerDelegate(*gEvseManufacturer.get()); /* Call Manufacturer specific init */ err = gEvseManufacturer->Init(); @@ -196,57 +200,3 @@ CHIP_ERROR EVSEManufacturerShutdown() return CHIP_NO_ERROR; } - -void EvseApplicationInit(chip::EndpointId endpointId) -{ - if (DeviceEnergyManagementInit(endpointId) != CHIP_NO_ERROR) - { - return; - } - - if (EnergyEvseInit(endpointId) != CHIP_NO_ERROR) - { - DeviceEnergyManagementShutdown(); - return; - } - - if (ElectricalPowerMeasurementInit(endpointId) != CHIP_NO_ERROR) - { - DeviceEnergyManagementShutdown(); - EnergyEvseShutdown(); - return; - } - - if (PowerTopologyInit(endpointId) != CHIP_NO_ERROR) - { - EVSEManufacturerShutdown(); - DeviceEnergyManagementShutdown(); - EnergyEvseShutdown(); - ElectricalPowerMeasurementShutdown(); - return; - } - - /* Do this last so that the instances for other clusters can be wrapped inside */ - if (EVSEManufacturerInit() != CHIP_NO_ERROR) - { - DeviceEnergyManagementShutdown(); - EnergyEvseShutdown(); - ElectricalPowerMeasurementShutdown(); - return; - } -} - -void EvseApplicationShutdown() -{ - ChipLogDetail(AppServer, "Energy Management App (EVSE): ApplicationShutdown()"); - - /* Shutdown in reverse order that they were created */ - EVSEManufacturerShutdown(); /* Free the EVSEManufacturer */ - PowerTopologyShutdown(); /* Free the PowerTopology */ - ElectricalPowerMeasurementShutdown(); /* Free the Electrical Power Measurement */ - EnergyEvseShutdown(); /* Free the EnergyEvse */ - DeviceEnergyManagementShutdown(); /* Free the DEM */ - - Clusters::DeviceEnergyManagementMode::Shutdown(); - Clusters::EnergyEvseMode::Shutdown(); -} diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp b/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp index cbe0a4f51bb1d6..d19688d1da0213 100644 --- a/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp +++ b/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h b/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h deleted file mode 100644 index 65c226d843b785..00000000000000 --- a/examples/energy-management-app/energy-management-common/water-heater/include/WaterHeaterMain.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright (c) 2024 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -namespace chip { -namespace app { -namespace Clusters { -namespace WaterHeaterManagement { - -void FullWhmApplicationInit(EndpointId endpointId); -void FullWhmApplicationShutdown(); - -} // namespace WaterHeaterManagement -} // namespace Clusters -} // namespace app -} // namespace chip diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp deleted file mode 100644 index fac3068e933806..00000000000000 --- a/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * Copyright (c) 2024 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "EnergyManagementAppCmdLineOptions.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace WaterHeaterManagement { - -void FullWhmApplicationInit(EndpointId endpointId) -{ - ReturnOnFailure(WhmApplicationInit(endpointId)); - - if (DeviceEnergyManagementInit(endpointId) != CHIP_NO_ERROR) - { - WhmApplicationShutdown(); - return; - } - - if (ElectricalPowerMeasurementInit(endpointId) != CHIP_NO_ERROR) - { - DeviceEnergyManagementShutdown(); - WhmApplicationShutdown(); - return; - } - - if (PowerTopologyInit(endpointId) != CHIP_NO_ERROR) - { - ElectricalPowerMeasurementShutdown(); - DeviceEnergyManagementShutdown(); - WhmApplicationShutdown(); - return; - } - - /* For Device Energy Management we need the ESA to be Online and ready to accept commands */ - - GetDEMDelegate()->SetESAState(ESAStateEnum::kOnline); - GetDEMDelegate()->SetESAType(ESATypeEnum::kWaterHeating); - GetDEMDelegate()->SetDEMManufacturerDelegate(*GetWhmManufacturer()); - - // Set the abs min and max power - GetDEMDelegate()->SetAbsMinPower(1200000); // 1.2KW - GetDEMDelegate()->SetAbsMaxPower(7600000); // 7.6KW -} - -void FullWhmApplicationShutdown() -{ - ChipLogDetail(AppServer, "Energy Management App (WaterHeater): ApplicationShutdown()"); - - /* Shutdown in reverse order that they were created */ - PowerTopologyShutdown(); /* Free the PowerTopology */ - ElectricalPowerMeasurementShutdown(); /* Free the Energy Meter */ - DeviceEnergyManagementShutdown(); /* Free the DEM */ - WhmApplicationShutdown(); - - Clusters::DeviceEnergyManagementMode::Shutdown(); - Clusters::WaterHeaterMode::Shutdown(); -} - -} // namespace WaterHeaterManagement -} // namespace Clusters -} // namespace app -} // namespace chip diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index 92b77f0801b717..b5318183c104a3 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -17,15 +17,8 @@ #include "DeviceCallbacks.h" -#if CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE -#include -#endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE - -#if CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE -#include -#endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE - #include "esp_log.h" +#include #include #include #include @@ -179,7 +172,7 @@ void ApplicationInit() #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE - FullWhmApplicationInit(kWaterHeaterEndpoint); + WaterHeaterApplicationInit(kWaterHeaterEndpoint); // Disable EVSE Endpoint emberAfEndpointEnableDisable(kEvseEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE @@ -194,7 +187,7 @@ void ApplicationShutdown() #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE - FullWhmApplicationShutdown(); + WaterHeaterApplicationShutdown(); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE } diff --git a/examples/energy-management-app/linux/BUILD.gn b/examples/energy-management-app/linux/BUILD.gn index 5ebb66f395dc37..e2980e541ce165 100644 --- a/examples/energy-management-app/linux/BUILD.gn +++ b/examples/energy-management-app/linux/BUILD.gn @@ -34,8 +34,8 @@ config("includes") { executable("chip-energy-management-app") { sources = [ + "${chip_root}/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp", - "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementManager.cpp", @@ -49,11 +49,9 @@ executable("chip-energy-management-app") { "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseTargetsStore.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp", - "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/EnergyReportingEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/PowerTopologyDelegate.cpp", - "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmInstance.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp", diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index 55c472cf62f82f..5f4aa6d84ed815 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -17,9 +17,9 @@ */ #include +#include #include #include -#include #include #include #include @@ -115,7 +115,7 @@ void ApplicationInit() } else if (strcmp(spApp, kWhmApp) == 0) { - FullWhmApplicationInit(kWaterHeaterEndpoint); + WaterHeaterApplicationInit(kWaterHeaterEndpoint); // Disable EVSE Endpoint emberAfEndpointEnableDisable(kEvseEndpoint, false); } @@ -130,7 +130,7 @@ void ApplicationShutdown() ChipLogDetail(AppServer, "Energy Management App: ApplicationShutdown()"); EvseApplicationShutdown(); - FullWhmApplicationShutdown(); + WaterHeaterApplicationShutdown(); } static bool EnergyAppOptionHandler(const char * aProgram, chip::ArgParser::OptionSet * aOptions, int aIdentifier, diff --git a/examples/energy-management-app/silabs/BUILD.gn b/examples/energy-management-app/silabs/BUILD.gn index 01f9872bf64c9d..012c2d170ba04f 100644 --- a/examples/energy-management-app/silabs/BUILD.gn +++ b/examples/energy-management-app/silabs/BUILD.gn @@ -166,8 +166,8 @@ silabs_executable("energy-management-app") { } sources = [ + "${chip_root}/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp", - "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementManager.cpp", @@ -181,11 +181,9 @@ silabs_executable("energy-management-app") { "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseTargetsStore.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp", - "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalSensorInit.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/EnergyReportingEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/PowerTopologyDelegate.cpp", - "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WaterHeaterMain.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmInstance.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp", diff --git a/examples/energy-management-app/silabs/src/AppTask.cpp b/examples/energy-management-app/silabs/src/AppTask.cpp index 1303e3bc016347..99d8081a6e1f71 100644 --- a/examples/energy-management-app/silabs/src/AppTask.cpp +++ b/examples/energy-management-app/silabs/src/AppTask.cpp @@ -21,12 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" #include "LEDWidget.h" -#if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE -#include -#endif -#if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE -#include -#endif +#include #include #include #include @@ -156,7 +151,7 @@ void ApplicationInit() #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE SILABS_LOG("energy-management-example WaterHeater starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); - FullWhmApplicationInit(kWaterHeaterEndpoint); + WaterHeaterApplicationInit(kWaterHeaterEndpoint); // Disable EVSE Endpoint emberAfEndpointEnableDisable(kEvseEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE From 6f3f6dcc4792effe5dc97718438d24bca76c0165 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 24 Oct 2024 18:54:05 +0000 Subject: [PATCH 07/23] Review suggestion: move GetMainAppEndpointId to another file --- .../common/include/CommonMain.h | 8 ++++++-- .../EnergyManagementAppCmdLineOptions.h | 3 --- .../src/device-energy-management-mode.cpp | 1 + .../energy-management-app/esp32/main/main.cpp | 18 +++++++++--------- examples/energy-management-app/linux/main.cpp | 10 +++++----- .../silabs/src/AppTask.cpp | 16 ++++++++-------- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/examples/energy-management-app/energy-management-common/common/include/CommonMain.h b/examples/energy-management-app/energy-management-common/common/include/CommonMain.h index 0cb340cfa570ad..6e29ea6e4dbfd9 100644 --- a/examples/energy-management-app/energy-management-common/common/include/CommonMain.h +++ b/examples/energy-management-app/energy-management-common/common/include/CommonMain.h @@ -24,12 +24,16 @@ #include #include +constexpr chip::EndpointId kEvseEndpoint = 1; +constexpr chip::EndpointId kWaterHeaterEndpoint = 2; + +chip::EndpointId GetMainAppEndpointId(); + void EvseApplicationInit(chip::EndpointId endpointId); void EvseApplicationShutdown(); void WaterHeaterApplicationInit(chip::EndpointId endpointId); void WaterHeaterApplicationShutdown(); -// The DEM Delegate is used for the TestEventTriggers which are functions called outside of a class/init context -// thus have no simple way to inject this dependency, so use the Getter here. +// The DEM Delegate is used for the TestEventTriggers chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate(); diff --git a/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h b/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h index 378a30adc453b8..a44140b94c762b 100644 --- a/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h +++ b/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h @@ -25,10 +25,7 @@ namespace chip { namespace app { namespace Clusters { namespace DeviceEnergyManagement { -constexpr EndpointId kEvseEndpoint = 1; -constexpr EndpointId kWaterHeaterEndpoint = 2; -EndpointId GetMainAppEndpointId(); chip::BitMask GetFeatureMapFromCmdLine(); } // namespace DeviceEnergyManagement diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp index ba959dd029f8c2..5468f8bcff4ae8 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp @@ -16,6 +16,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index b5318183c104a3..48b74336dbeca2 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -142,15 +142,6 @@ chip::BitMask GetFeatureMapFromCmdLine() return sFeatureMap; } -EndpointId GetMainAppEndpointId() -{ -#if defined(CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) - return kWaterHeaterEndpoint; -#else - return kEvseEndpoint; -#endif -} - } // namespace DeviceEnergyManagement } // namespace Clusters } // namespace app @@ -161,6 +152,15 @@ EndpointId GetMainAppEndpointId() #error Cannot define CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE and CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE #endif +EndpointId GetMainAppEndpointId() +{ +#if defined(CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) + return kWaterHeaterEndpoint; +#else + return kEvseEndpoint; +#endif +} + void ApplicationInit() { ESP_LOGD(TAG, "Energy Management App: ApplicationInit()"); diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index 5f4aa6d84ed815..a4df9b0dbb9eb6 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -79,16 +79,16 @@ chip::BitMask GetFeatureMapFromCmdLine() return sFeatureMap; } -EndpointId GetMainAppEndpointId() -{ - return eemEndpoint; -} - } // namespace DeviceEnergyManagement } // namespace Clusters } // namespace app } // namespace chip +EndpointId GetMainAppEndpointId() +{ + return eemEndpoint; +} + static uint32_t ParseNumber(const char * pString) { uint32_t num = 0; diff --git a/examples/energy-management-app/silabs/src/AppTask.cpp b/examples/energy-management-app/silabs/src/AppTask.cpp index 99d8081a6e1f71..d7d61e8340d483 100644 --- a/examples/energy-management-app/silabs/src/AppTask.cpp +++ b/examples/energy-management-app/silabs/src/AppTask.cpp @@ -74,7 +74,7 @@ namespace { LEDWidget sEnergyManagementLED; -} +} // namespace using namespace chip; using namespace chip::app; @@ -120,6 +120,13 @@ chip::BitMask GetFeatureMapFromCmdLine() return sFeatureMap; } +} // namespace DeviceEnergyManagement +} // namespace Clusters +} // namespace app +} // namespace chip + +AppTask AppTask::sAppTask; + EndpointId GetMainAppEndpointId() { #if defined(SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) @@ -129,13 +136,6 @@ EndpointId GetMainAppEndpointId() #endif } -} // namespace DeviceEnergyManagement -} // namespace Clusters -} // namespace app -} // namespace chip - -AppTask AppTask::sAppTask; - void ApplicationInit() { chip::DeviceLayer::PlatformMgr().LockChipStack(); From 9dee3deee4fccec7ff82bf28d9fdaa3394e5c4b0 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 24 Oct 2024 19:07:02 +0000 Subject: [PATCH 08/23] zap regen --- .../energy-management-app.matter | 510 +++++++++++++++++- 1 file changed, 491 insertions(+), 19 deletions(-) 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 a3c2b9f58b5485..7bd9cb448e0c8b 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 @@ -2398,6 +2398,361 @@ provisional cluster DeviceEnergyManagementMode = 159 { command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0; } +/** An interface for configuring and controlling the functionality of a thermostat. */ +cluster Thermostat = 513 { + revision 7; + + enum ACCapacityFormatEnum : enum8 { + kBTUh = 0; + } + + enum ACCompressorTypeEnum : enum8 { + kUnknown = 0; + kT1 = 1; + kT2 = 2; + kT3 = 3; + } + + enum ACLouverPositionEnum : enum8 { + kClosed = 1; + kOpen = 2; + kQuarter = 3; + kHalf = 4; + kThreeQuarters = 5; + } + + enum ACRefrigerantTypeEnum : enum8 { + kUnknown = 0; + kR22 = 1; + kR410a = 2; + kR407c = 3; + } + + enum ACTypeEnum : enum8 { + kUnknown = 0; + kCoolingFixed = 1; + kHeatPumpFixed = 2; + kCoolingInverter = 3; + kHeatPumpInverter = 4; + } + + enum ControlSequenceOfOperationEnum : enum8 { + kCoolingOnly = 0; + kCoolingWithReheat = 1; + kHeatingOnly = 2; + kHeatingWithReheat = 3; + kCoolingAndHeating = 4; + kCoolingAndHeatingWithReheat = 5; + } + + enum PresetScenarioEnum : enum8 { + kOccupied = 1; + kUnoccupied = 2; + kSleep = 3; + kWake = 4; + kVacation = 5; + kGoingToSleep = 6; + kUserDefined = 254; + } + + enum SetpointChangeSourceEnum : enum8 { + kManual = 0; + kSchedule = 1; + kExternal = 2; + } + + enum SetpointRaiseLowerModeEnum : enum8 { + kHeat = 0; + kCool = 1; + kBoth = 2; + } + + enum StartOfWeekEnum : enum8 { + kSunday = 0; + kMonday = 1; + kTuesday = 2; + kWednesday = 3; + kThursday = 4; + kFriday = 5; + kSaturday = 6; + } + + enum SystemModeEnum : enum8 { + kOff = 0; + kAuto = 1; + kCool = 3; + kHeat = 4; + kEmergencyHeat = 5; + kPrecooling = 6; + kFanOnly = 7; + kDry = 8; + kSleep = 9; + } + + enum TemperatureSetpointHoldEnum : enum8 { + kSetpointHoldOff = 0; + kSetpointHoldOn = 1; + } + + enum ThermostatRunningModeEnum : enum8 { + kOff = 0; + kCool = 3; + kHeat = 4; + } + + bitmap ACErrorCodeBitmap : bitmap32 { + kCompressorFail = 0x1; + kRoomSensorFail = 0x2; + kOutdoorSensorFail = 0x4; + kCoilSensorFail = 0x8; + kFanFail = 0x10; + } + + bitmap Feature : bitmap32 { + kHeating = 0x1; + kCooling = 0x2; + kOccupancy = 0x4; + kScheduleConfiguration = 0x8; + kSetback = 0x10; + kAutoMode = 0x20; + kLocalTemperatureNotExposed = 0x40; + kMatterScheduleConfiguration = 0x80; + kPresets = 0x100; + } + + bitmap HVACSystemTypeBitmap : bitmap8 { + kCoolingStage = 0x3; + kHeatingStage = 0xC; + kHeatingIsHeatPump = 0x10; + kHeatingUsesFuel = 0x20; + } + + bitmap OccupancyBitmap : bitmap8 { + kOccupied = 0x1; + } + + bitmap PresetTypeFeaturesBitmap : bitmap16 { + kAutomatic = 0x1; + kSupportsNames = 0x2; + } + + bitmap ProgrammingOperationModeBitmap : bitmap8 { + kScheduleActive = 0x1; + kAutoRecovery = 0x2; + kEconomy = 0x4; + } + + bitmap RelayStateBitmap : bitmap16 { + kHeat = 0x1; + kCool = 0x2; + kFan = 0x4; + kHeatStage2 = 0x8; + kCoolStage2 = 0x10; + kFanStage2 = 0x20; + kFanStage3 = 0x40; + } + + bitmap RemoteSensingBitmap : bitmap8 { + kLocalTemperature = 0x1; + kOutdoorTemperature = 0x2; + kOccupancy = 0x4; + } + + bitmap ScheduleDayOfWeekBitmap : bitmap8 { + kSunday = 0x1; + kMonday = 0x2; + kTuesday = 0x4; + kWednesday = 0x8; + kThursday = 0x10; + kFriday = 0x20; + kSaturday = 0x40; + kAway = 0x80; + } + + bitmap ScheduleModeBitmap : bitmap8 { + kHeatSetpointPresent = 0x1; + kCoolSetpointPresent = 0x2; + } + + bitmap ScheduleTypeFeaturesBitmap : bitmap16 { + kSupportsPresets = 0x1; + kSupportsSetpoints = 0x2; + kSupportsNames = 0x4; + kSupportsOff = 0x8; + } + + struct ScheduleTransitionStruct { + ScheduleDayOfWeekBitmap dayOfWeek = 0; + int16u transitionTime = 1; + optional octet_string<16> presetHandle = 2; + optional SystemModeEnum systemMode = 3; + optional temperature coolingSetpoint = 4; + optional temperature heatingSetpoint = 5; + } + + struct ScheduleStruct { + nullable octet_string<16> scheduleHandle = 0; + SystemModeEnum systemMode = 1; + optional char_string<64> name = 2; + optional octet_string<16> presetHandle = 3; + ScheduleTransitionStruct transitions[] = 4; + nullable boolean builtIn = 5; + } + + struct PresetStruct { + nullable octet_string<16> presetHandle = 0; + PresetScenarioEnum presetScenario = 1; + optional nullable char_string<64> name = 2; + optional temperature coolingSetpoint = 3; + optional temperature heatingSetpoint = 4; + nullable boolean builtIn = 5; + } + + struct PresetTypeStruct { + PresetScenarioEnum presetScenario = 0; + int8u numberOfPresets = 1; + PresetTypeFeaturesBitmap presetTypeFeatures = 2; + } + + struct ScheduleTypeStruct { + SystemModeEnum systemMode = 0; + int8u numberOfSchedules = 1; + ScheduleTypeFeaturesBitmap scheduleTypeFeatures = 2; + } + + struct WeeklyScheduleTransitionStruct { + int16u transitionTime = 0; + nullable temperature heatSetpoint = 1; + nullable temperature coolSetpoint = 2; + } + + readonly attribute nullable temperature localTemperature = 0; + readonly attribute optional nullable temperature outdoorTemperature = 1; + readonly attribute optional OccupancyBitmap occupancy = 2; + readonly attribute optional temperature absMinHeatSetpointLimit = 3; + readonly attribute optional temperature absMaxHeatSetpointLimit = 4; + readonly attribute optional temperature absMinCoolSetpointLimit = 5; + readonly attribute optional temperature absMaxCoolSetpointLimit = 6; + readonly attribute optional int8u PICoolingDemand = 7; + readonly attribute optional int8u PIHeatingDemand = 8; + attribute access(write: manage) optional HVACSystemTypeBitmap HVACSystemTypeConfiguration = 9; + attribute access(write: manage) optional int8s localTemperatureCalibration = 16; + attribute optional temperature occupiedCoolingSetpoint = 17; + attribute optional temperature occupiedHeatingSetpoint = 18; + attribute optional temperature unoccupiedCoolingSetpoint = 19; + attribute optional temperature unoccupiedHeatingSetpoint = 20; + attribute access(write: manage) optional temperature minHeatSetpointLimit = 21; + attribute access(write: manage) optional temperature maxHeatSetpointLimit = 22; + attribute access(write: manage) optional temperature minCoolSetpointLimit = 23; + attribute access(write: manage) optional temperature maxCoolSetpointLimit = 24; + attribute access(write: manage) optional int8s minSetpointDeadBand = 25; + attribute access(write: manage) optional RemoteSensingBitmap remoteSensing = 26; + attribute access(write: manage) ControlSequenceOfOperationEnum controlSequenceOfOperation = 27; + attribute access(write: manage) SystemModeEnum systemMode = 28; + readonly attribute optional ThermostatRunningModeEnum thermostatRunningMode = 30; + readonly attribute optional StartOfWeekEnum startOfWeek = 32; + readonly attribute optional int8u numberOfWeeklyTransitions = 33; + readonly attribute optional int8u numberOfDailyTransitions = 34; + attribute access(write: manage) optional TemperatureSetpointHoldEnum temperatureSetpointHold = 35; + attribute access(write: manage) optional nullable int16u temperatureSetpointHoldDuration = 36; + attribute access(write: manage) optional ProgrammingOperationModeBitmap thermostatProgrammingOperationMode = 37; + readonly attribute optional RelayStateBitmap thermostatRunningState = 41; + readonly attribute optional SetpointChangeSourceEnum setpointChangeSource = 48; + readonly attribute optional nullable int16s setpointChangeAmount = 49; + readonly attribute optional epoch_s setpointChangeSourceTimestamp = 50; + attribute access(write: manage) optional nullable int8u occupiedSetback = 52; + readonly attribute optional nullable int8u occupiedSetbackMin = 53; + readonly attribute optional nullable int8u occupiedSetbackMax = 54; + attribute access(write: manage) optional nullable int8u unoccupiedSetback = 55; + readonly attribute optional nullable int8u unoccupiedSetbackMin = 56; + readonly attribute optional nullable int8u unoccupiedSetbackMax = 57; + attribute access(write: manage) optional int8u emergencyHeatDelta = 58; + attribute access(write: manage) optional ACTypeEnum ACType = 64; + attribute access(write: manage) optional int16u ACCapacity = 65; + attribute access(write: manage) optional ACRefrigerantTypeEnum ACRefrigerantType = 66; + attribute access(write: manage) optional ACCompressorTypeEnum ACCompressorType = 67; + attribute access(write: manage) optional ACErrorCodeBitmap ACErrorCode = 68; + attribute access(write: manage) optional ACLouverPositionEnum ACLouverPosition = 69; + readonly attribute optional nullable temperature ACCoilTemperature = 70; + attribute access(write: manage) optional ACCapacityFormatEnum ACCapacityformat = 71; + readonly attribute optional PresetTypeStruct presetTypes[] = 72; + readonly attribute optional ScheduleTypeStruct scheduleTypes[] = 73; + readonly attribute optional int8u numberOfPresets = 74; + readonly attribute optional int8u numberOfSchedules = 75; + readonly attribute optional int8u numberOfScheduleTransitions = 76; + readonly attribute optional nullable int8u numberOfScheduleTransitionPerDay = 77; + readonly attribute optional nullable octet_string<16> activePresetHandle = 78; + readonly attribute optional nullable octet_string<16> activeScheduleHandle = 79; + attribute access(write: manage) optional PresetStruct presets[] = 80; + attribute access(write: manage) optional ScheduleStruct schedules[] = 81; + readonly attribute optional nullable epoch_s setpointHoldExpiryTimestamp = 82; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct SetpointRaiseLowerRequest { + SetpointRaiseLowerModeEnum mode = 0; + int8s amount = 1; + } + + response struct GetWeeklyScheduleResponse = 0 { + int8u numberOfTransitionsForSequence = 0; + ScheduleDayOfWeekBitmap dayOfWeekForSequence = 1; + ScheduleModeBitmap modeForSequence = 2; + WeeklyScheduleTransitionStruct transitions[] = 3; + } + + request struct SetWeeklyScheduleRequest { + int8u numberOfTransitionsForSequence = 0; + ScheduleDayOfWeekBitmap dayOfWeekForSequence = 1; + ScheduleModeBitmap modeForSequence = 2; + WeeklyScheduleTransitionStruct transitions[] = 3; + } + + request struct GetWeeklyScheduleRequest { + ScheduleDayOfWeekBitmap daysToReturn = 0; + ScheduleModeBitmap modeToReturn = 1; + } + + request struct SetActiveScheduleRequestRequest { + octet_string<16> scheduleHandle = 0; + } + + request struct SetActivePresetRequestRequest { + nullable octet_string<16> presetHandle = 0; + } + + response struct AtomicResponse = 253 { + status statusCode = 0; + AtomicAttributeStatusStruct attributeStatus[] = 1; + optional int16u timeout = 2; + } + + request struct AtomicRequestRequest { + AtomicRequestTypeEnum requestType = 0; + attrib_id attributeRequests[] = 1; + optional int16u timeout = 2; + } + + /** Upon receipt, the attributes for the indicated setpoint(s) SHALL have the amount specified in the Amount field added to them. */ + command SetpointRaiseLower(SetpointRaiseLowerRequest): DefaultSuccess = 0; + /** This command is used to update the thermostat weekly setpoint schedule from a management system. */ + command access(invoke: manage) SetWeeklySchedule(SetWeeklyScheduleRequest): DefaultSuccess = 1; + /** The Current Weekly Schedule Command is sent from the server in response to the Get Weekly Schedule Command. */ + command GetWeeklySchedule(GetWeeklyScheduleRequest): GetWeeklyScheduleResponse = 2; + /** This command is used to clear the weekly schedule. */ + command access(invoke: manage) ClearWeeklySchedule(): DefaultSuccess = 3; + /** Upon receipt, if the Schedules attribute contains a ScheduleStruct whose ScheduleHandle field matches the value of the ScheduleHandle field, the server SHALL set the thermostat's ActiveScheduleHandle attribute to the value of the ScheduleHandle field. */ + command SetActiveScheduleRequest(SetActiveScheduleRequestRequest): DefaultSuccess = 5; + /** ID */ + command SetActivePresetRequest(SetActivePresetRequestRequest): DefaultSuccess = 6; + /** Begins, Commits or Cancels an atomic write */ + command access(invoke: manage) AtomicRequest(AtomicRequestRequest): AtomicResponse = 254; +} + endpoint 0 { device type ma_rootdevice = 22, version 1; @@ -2677,23 +3032,6 @@ endpoint 1 { ram attribute clusterRevision default = 1; } - server cluster WaterHeaterManagement { - callback attribute heaterTypes; - callback attribute heatDemand; - callback attribute tankVolume; - callback attribute estimatedHeatRequired; - callback attribute tankPercentage; - callback attribute boostState; - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute attributeList; - callback attribute featureMap; - callback attribute clusterRevision; - - handle command Boost; - handle command CancelBoost; - } - server cluster DeviceEnergyManagement { emits event PowerAdjustStart; emits event PowerAdjustEnd; @@ -2784,7 +3122,7 @@ endpoint 1 { handle command ChangeToModeResponse; } - server cluster WaterHeaterMode { + server cluster DeviceEnergyManagementMode { callback attribute supportedModes; callback attribute currentMode; callback attribute generatedCommandList; @@ -2796,8 +3134,119 @@ endpoint 1 { handle command ChangeToMode; handle command ChangeToModeResponse; } +} +endpoint 2 { + device type ma_electricalsensor = 1296, version 1; + device type ma_waterheater = 1295, version 1; - server cluster DeviceEnergyManagementMode { + + server cluster Identify { + ram attribute identifyTime default = 0x0; + ram attribute identifyType default = 0x00; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command Identify; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster ElectricalPowerMeasurement { + callback attribute powerMode; + callback attribute numberOfMeasurementTypes; + callback attribute accuracy; + 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 attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster ElectricalEnergyMeasurement { + callback attribute accuracy; + callback attribute cumulativeEnergyImported; + callback attribute cumulativeEnergyExported; + callback attribute periodicEnergyImported; + callback attribute periodicEnergyExported; + callback attribute cumulativeEnergyReset; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster WaterHeaterManagement { + callback attribute heaterTypes; + callback attribute heatDemand; + callback attribute tankVolume; + callback attribute estimatedHeatRequired; + callback attribute tankPercentage; + callback attribute boostState; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command Boost; + handle command CancelBoost; + } + + server cluster DeviceEnergyManagement { + callback attribute ESAType; + callback attribute ESACanGenerate; + callback attribute ESAState; + callback attribute absMinPower; + callback attribute absMaxPower; + callback attribute powerAdjustmentCapability; + callback attribute forecast; + callback attribute optOutState; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster PowerTopology { + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster WaterHeaterMode { callback attribute supportedModes; callback attribute currentMode; callback attribute generatedCommandList; @@ -2809,6 +3258,29 @@ endpoint 1 { handle command ChangeToMode; handle command ChangeToModeResponse; } + + server cluster DeviceEnergyManagementMode { + callback attribute supportedModes; + callback attribute currentMode; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster Thermostat { + ram attribute localTemperature; + ram attribute controlSequenceOfOperation default = 4; + ram attribute systemMode default = 1; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 7; + + handle command SetpointRaiseLower; + } } From e2f79904f448b9308a7d8ab873fca44aa35b0863 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Mon, 28 Oct 2024 17:35:14 +0000 Subject: [PATCH 09/23] fix matter-devices white space diffs --- .../zcl/data-model/chip/matter-devices.xml | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml index dd979a3bfb1ee9..bdccfbe39e1582 100644 --- a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +++ b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml @@ -89,12 +89,12 @@ limitations under the License. - - - - - - + + + + + + @@ -266,7 +266,7 @@ limitations under the License. - + ON_OFF @@ -284,10 +284,10 @@ limitations under the License. - + - + CURRENT_LEVEL @@ -367,7 +367,7 @@ limitations under the License. - + ON_OFF @@ -385,10 +385,10 @@ limitations under the License. - + - + CURRENT_LEVEL @@ -465,7 +465,7 @@ limitations under the License. - + ON_OFF @@ -483,10 +483,10 @@ limitations under the License. - + - + CURRENT_LEVEL @@ -507,7 +507,7 @@ limitations under the License. - + COLOR_CONTROL_REMAINING_TIME @@ -582,7 +582,7 @@ limitations under the License. - + ON_OFF @@ -600,10 +600,10 @@ limitations under the License. - + - + CURRENT_LEVEL @@ -624,19 +624,19 @@ limitations under the License. - + - + - + - + - + COLOR_CONTROL_REMAINING_TIME @@ -715,7 +715,7 @@ limitations under the License. - + ON_OFF @@ -733,10 +733,10 @@ limitations under the License. - + - + CURRENT_LEVEL @@ -809,7 +809,7 @@ limitations under the License. - + ON_OFF @@ -827,10 +827,10 @@ limitations under the License. - + - + CURRENT_LEVEL @@ -1491,23 +1491,23 @@ limitations under the License. - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + @@ -1593,9 +1593,9 @@ limitations under the License. - - - + + + @@ -1630,9 +1630,9 @@ limitations under the License. - - - + + + @@ -1826,7 +1826,7 @@ limitations under the License. - + @@ -1987,7 +1987,7 @@ limitations under the License. - + @@ -2040,7 +2040,7 @@ limitations under the License. - + ON_OFF @@ -2145,7 +2145,7 @@ limitations under the License. - + @@ -2154,7 +2154,7 @@ limitations under the License. - + @@ -2162,7 +2162,7 @@ limitations under the License. - + MA-oven CHIP Oven @@ -2189,15 +2189,15 @@ limitations under the License. - + - + - - + + @@ -2212,7 +2212,7 @@ limitations under the License. tree - 0x0071 + 0x0071 @@ -2221,7 +2221,7 @@ limitations under the License. - + @@ -2242,14 +2242,14 @@ limitations under the License. - + - + @@ -2258,7 +2258,7 @@ limitations under the License. - + MA-laundry-dryer CHIP Laundry Dryer @@ -2272,14 +2272,14 @@ limitations under the License. - + - + @@ -2304,13 +2304,13 @@ limitations under the License. - + - + - + @@ -2349,14 +2349,14 @@ limitations under the License. - + - + @@ -2644,7 +2644,7 @@ limitations under the License. - + @@ -2661,7 +2661,7 @@ limitations under the License. - + @@ -2670,7 +2670,7 @@ limitations under the License. - + Energy EVSE CHIP EVSE From 1371752200747f707da0e3b1bc2cf58d7477f33f Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 29 Oct 2024 18:02:58 +0000 Subject: [PATCH 10/23] App now builds on all-clusters app --- .../all-clusters-app/linux/main-common.cpp | 8 +- ...Main.h => EnergyManagementAppCommonMain.h} | 16 +- ....cpp => EnergyManagementAppCommonMain.cpp} | 179 ++++++++++-------- .../src/DEMTestEventTriggers.cpp | 2 +- .../src/device-energy-management-mode.cpp | 12 +- .../energy-evse/src/EnergyEvseMain.cpp | 2 +- .../energy-reporting/src/FakeReadings.cpp | 2 +- .../energy-management-app/esp32/main/main.cpp | 12 +- examples/energy-management-app/linux/BUILD.gn | 2 +- examples/energy-management-app/linux/main.cpp | 28 +-- .../energy-management-app/silabs/BUILD.gn | 2 +- .../silabs/src/AppTask.cpp | 12 +- 12 files changed, 152 insertions(+), 125 deletions(-) rename examples/energy-management-app/energy-management-common/common/include/{CommonMain.h => EnergyManagementAppCommonMain.h} (73%) rename examples/energy-management-app/energy-management-common/common/src/{CommonMain.cpp => EnergyManagementAppCommonMain.cpp} (90%) diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index b62d154f0d58f7..cc51eb9abd5654 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -124,12 +124,18 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp3TagList[] = { { .tag = kTagSwitchesUp } }; const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp4TagList[] = { { .namespaceID = kNamespaceSwitches, .tag = kTagSwitchesDown } }; + } // namespace #ifdef MATTER_DM_PLUGIN_DISHWASHER_ALARM_SERVER extern void MatterDishwasherAlarmServerInit(); #endif +EndpointId GetEnergyDeviceEndpointId() +{ + return chip::EndpointId(1); +} + void OnIdentifyStart(::Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); @@ -256,7 +262,7 @@ void ApplicationInit() Clusters::ValveConfigurationAndControl::SetDefaultDelegate(chip::EndpointId(1), &sValveDelegate); Clusters::TimeSynchronization::SetDefaultDelegate(&sTimeSyncDelegate); - Clusters::WaterHeaterManagement::WhmApplicationInit(); + Clusters::WaterHeaterManagement::WhmApplicationInit(chip::EndpointId(1)); SetTagList(/* endpoint= */ 0, Span(gEp0TagList)); SetTagList(/* endpoint= */ 1, Span(gEp1TagList)); diff --git a/examples/energy-management-app/energy-management-common/common/include/CommonMain.h b/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCommonMain.h similarity index 73% rename from examples/energy-management-app/energy-management-common/common/include/CommonMain.h rename to examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCommonMain.h index 6e29ea6e4dbfd9..1a9ff734b6596f 100644 --- a/examples/energy-management-app/energy-management-common/common/include/CommonMain.h +++ b/examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCommonMain.h @@ -24,16 +24,16 @@ #include #include -constexpr chip::EndpointId kEvseEndpoint = 1; -constexpr chip::EndpointId kWaterHeaterEndpoint = 2; +// This app is configured by default with EP1 for EVSE and EP2 for WaterHeater, with only one endpoint +// enabled. On linux, there's a command line argument (--application) to dynamically enable +// "evse|water-heater", i.e. EP1 or EP2. On other platforms, it's a build time definition (#define). +chip::EndpointId GetEnergyDeviceEndpointId(); -chip::EndpointId GetMainAppEndpointId(); +// The DEM Delegate is used for the TestEventTriggers +chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate(); -void EvseApplicationInit(chip::EndpointId endpointId); +void EvseApplicationInit(); void EvseApplicationShutdown(); -void WaterHeaterApplicationInit(chip::EndpointId endpointId); +void WaterHeaterApplicationInit(); void WaterHeaterApplicationShutdown(); - -// The DEM Delegate is used for the TestEventTriggers -chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate(); diff --git a/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp b/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp similarity index 90% rename from examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp rename to examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp index 4d8a43ad1da027..8d7855a1fb3b93 100644 --- a/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp +++ b/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp @@ -16,8 +16,8 @@ * limitations under the License. */ +#include "EnergyManagementAppCommonMain.h" #include "EnergyManagementAppCmdLineOptions.h" -#include #include #include #include @@ -33,6 +33,7 @@ #include #include #include +#include using namespace chip; using namespace chip::app; @@ -54,74 +55,7 @@ std::unique_ptr gPTDelegate; std::unique_ptr gPTInstance; // Electrical Energy Measurement cluster uses ember to initialise std::unique_ptr gEEMAttrAccess; - -/* - * @brief Creates a Delegate and Instance for DEM - * - * The Instance is a container around the Delegate, so - * create the Delegate first, then wrap it in the Instance - * Then call the Instance->Init() to register the attribute and command handlers - */ -CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId) -{ - // TODO: support both EVSE and WaterHeater endpoints - if (gDEMDelegate || gDEMInstance) - { - ChipLogError(AppServer, "DEM Instance or Delegate already exist."); - return CHIP_ERROR_INCORRECT_STATE; - } - - gDEMDelegate = std::make_unique(); - if (!gDEMDelegate) - { - ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementDelegate"); - return CHIP_ERROR_NO_MEMORY; - } - - chip::BitMask featureMap = GetFeatureMapFromCmdLine(); - - /* Manufacturer may optionally not support all features, commands & attributes */ - gDEMInstance = std::make_unique(EndpointId(endpointId), *gDEMDelegate, featureMap); - - if (!gDEMInstance) - { - ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementManager"); - gDEMDelegate.reset(); - return CHIP_ERROR_NO_MEMORY; - } - - gDEMDelegate->SetDeviceEnergyManagementInstance(*gDEMInstance); - - CHIP_ERROR err = gDEMInstance->Init(); /* Register Attribute & Command handlers */ - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Init failed on gDEMInstance"); - gDEMInstance.reset(); - gDEMDelegate.reset(); - return err; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR DeviceEnergyManagementShutdown() -{ - // TODO: support both EVSE and WaterHeater endpoints - /* Do this in the order Instance first, then delegate - * Ensure we call the Instance->Shutdown to free attribute & command handlers first - */ - if (gDEMInstance) - { - /* deregister attribute & command handlers */ - gDEMInstance->Shutdown(); - gDEMInstance.reset(); - } - if (gDEMDelegate) - { - gDEMDelegate.reset(); - } - return CHIP_NO_ERROR; -} +bool gCommonClustersInitialized = false; /* * @brief Creates a Delegate and Instance for PowerTopology clusters @@ -276,22 +210,102 @@ CHIP_ERROR ElectricalPowerMeasurementShutdown() return CHIP_NO_ERROR; } +/* + * @brief Creates a Delegate and Instance for DEM + * + * The Instance is a container around the Delegate, so + * create the Delegate first, then wrap it in the Instance + * Then call the Instance->Init() to register the attribute and command handlers + */ +CHIP_ERROR DeviceEnergyManagementInit(chip::EndpointId endpointId) +{ + if (gDEMDelegate || gDEMInstance) + { + ChipLogError(AppServer, "DEM Instance or Delegate already exist."); + return CHIP_ERROR_INCORRECT_STATE; + } + + gDEMDelegate = std::make_unique(); + if (!gDEMDelegate) + { + ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementDelegate"); + return CHIP_ERROR_NO_MEMORY; + } + + chip::BitMask featureMap = GetFeatureMapFromCmdLine(); + + /* Manufacturer may optionally not support all features, commands & attributes */ + gDEMInstance = std::make_unique(endpointId, *gDEMDelegate, featureMap); + + if (!gDEMInstance) + { + ChipLogError(AppServer, "Failed to allocate memory for DeviceEnergyManagementManager"); + gDEMDelegate.reset(); + return CHIP_ERROR_NO_MEMORY; + } + + gDEMDelegate->SetDeviceEnergyManagementInstance(*gDEMInstance); + + CHIP_ERROR err = gDEMInstance->Init(); /* Register Attribute & Command handlers */ + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Init failed on gDEMInstance"); + gDEMInstance.reset(); + gDEMDelegate.reset(); + return err; + } + + return CHIP_NO_ERROR; +} + +void DeviceEnergyManagementShutdown() +{ + /* Do this in the order Instance first, then delegate + * Ensure we call the Instance->Shutdown to free attribute & command handlers first + */ + if (gDEMInstance) + { + /* deregister attribute & command handlers */ + gDEMInstance->Shutdown(); + gDEMInstance.reset(); + } + if (gDEMDelegate) + { + gDEMDelegate.reset(); + } +} + +CHIP_ERROR EnergyManagementCommonClustersInit(chip::EndpointId endpointId) +{ + if (!gCommonClustersInitialized) + { + DeviceEnergyManagementInit(endpointId); + ElectricalPowerMeasurementInit(endpointId); + PowerTopologyInit(endpointId); + } + VerifyOrReturnError((!gDEMDelegate && !gDEMInstance), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError((!gEPMDelegate && !gEPMInstance), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError((!gPTDelegate && !gPTInstance), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError((!gEEMAttrAccess), CHIP_ERROR_INCORRECT_STATE); + gCommonClustersInitialized = true; + return CHIP_NO_ERROR; +} + } // namespace void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endpointId) { - VerifyOrDie(endpointId == kEvseEndpoint || endpointId == kWaterHeaterEndpoint); - /* emberAfElectricalEnergyMeasurementClusterInitCallback() is called for all endpoints that include the EEM endpoint (even the one we disable dynamically). So here, we only - proceed when it's called for the right endpoint determined by GetMainAppEndpointId() - (a cmd line argument or #define). + proceed when it's called for the right endpoint determined by GetEnergyDeviceEndpointId(). */ - if (endpointId != GetMainAppEndpointId()) + if (endpointId != GetEnergyDeviceEndpointId()) { return; } + VerifyOrDie(!gEEMAttrAccess); // Ensure it's not initialized yet. + gEEMAttrAccess = std::make_unique( BitMask( ElectricalEnergyMeasurement::Feature::kImportedEnergy, ElectricalEnergyMeasurement::Feature::kExportedEnergy, @@ -341,12 +355,10 @@ DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate() return gDEMDelegate.get(); } -void EvseApplicationInit(chip::EndpointId endpointId) +void EvseApplicationInit() { - // Common Clusters Init - VerifyOrDie(DeviceEnergyManagementInit(endpointId) == CHIP_NO_ERROR); - VerifyOrDie(ElectricalPowerMeasurementInit(endpointId) == CHIP_NO_ERROR); - VerifyOrDie(PowerTopologyInit(endpointId) == CHIP_NO_ERROR); + auto endpointId = GetEnergyDeviceEndpointId(); + VerifyOrDie(EnergyManagementCommonClustersInit(endpointId) == CHIP_NO_ERROR); VerifyOrDie(EnergyEvseInit(endpointId) == CHIP_NO_ERROR); VerifyOrDie(EVSEManufacturerInit(*gEPMInstance.get(), *gPTInstance.get(), *gDEMInstance.get(), *gDEMDelegate.get()) == CHIP_NO_ERROR); @@ -354,7 +366,7 @@ void EvseApplicationInit(chip::EndpointId endpointId) void EvseApplicationShutdown() { - ChipLogDetail(AppServer, "Energy Management App (EVSE): ApplicationShutdown()"); + ChipLogDetail(AppServer, "Energy Management App (EVSE): EvseApplicationShutdown()"); /* Shutdown in reverse order that they were created */ EVSEManufacturerShutdown(); /* Free the EVSEManufacturer */ @@ -367,12 +379,13 @@ void EvseApplicationShutdown() Clusters::EnergyEvseMode::Shutdown(); } -void WaterHeaterApplicationInit(EndpointId endpointId) +void WaterHeaterApplicationInit() { + auto endpointId = GetEnergyDeviceEndpointId(); + VerifyOrDie(EnergyManagementCommonClustersInit(endpointId) == CHIP_NO_ERROR); VerifyOrDie(WhmApplicationInit(endpointId) == CHIP_NO_ERROR); /* For Device Energy Management we need the ESA to be Online and ready to accept commands */ - gDEMDelegate->SetESAState(ESAStateEnum::kOnline); gDEMDelegate->SetESAType(ESATypeEnum::kWaterHeating); gDEMDelegate->SetDEMManufacturerDelegate(*GetWhmManufacturer()); @@ -384,7 +397,7 @@ void WaterHeaterApplicationInit(EndpointId endpointId) void WaterHeaterApplicationShutdown() { - ChipLogDetail(AppServer, "Energy Management App (WaterHeater): ApplicationShutdown()"); + ChipLogDetail(AppServer, "Energy Management App (WaterHeater): WaterHeaterShutdown()"); /* Shutdown in reverse order that they were created */ PowerTopologyShutdown(); /* Free the PowerTopology */ diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp index 3636c6f206504a..23ed2afe1b994d 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp @@ -16,8 +16,8 @@ * limitations under the License. */ -#include #include +#include #include #include diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp index 5468f8bcff4ae8..330c0b0e389512 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp @@ -16,8 +16,8 @@ * limitations under the License. */ -#include #include +#include #include #include @@ -93,14 +93,12 @@ void DeviceEnergyManagementMode::Shutdown() void emberAfDeviceEnergyManagementModeClusterInitCallback(chip::EndpointId endpointId) { - VerifyOrDie(endpointId == kEvseEndpoint || endpointId == kWaterHeaterEndpoint); - /* emberAfDeviceEnergyManagementModeClusterInitCallback() is called for all endpoints - that include this endpoint (even the one we disable dynamically). So here, we only - proceed when it's called for the right endpoint determined by GetMainAppEndpointId() - (a cmd line argument or #define). + that include this cluster (even the one we disable dynamically). So here, we only + proceed when it's called for the right endpoint determined by GetEnergyDeviceEndpointId() + (a cmd line argument on linux or #define on other platforms). */ - if (endpointId != GetMainAppEndpointId()) + if (endpointId != GetEnergyDeviceEndpointId()) { return; } diff --git a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp index bf7092bc41b155..37553144f2f026 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp +++ b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp @@ -18,12 +18,12 @@ #include "EnergyManagementAppCmdLineOptions.h" -#include #include #include #include #include #include +#include #include #include #include diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp b/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp index d19688d1da0213..8fab0e2a7dbe07 100644 --- a/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp +++ b/examples/energy-management-app/energy-management-common/energy-reporting/src/FakeReadings.cpp @@ -16,8 +16,8 @@ * limitations under the License. */ -#include #include +#include #include #include diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index 48b74336dbeca2..9e1dff9b43b745 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -18,7 +18,7 @@ #include "DeviceCallbacks.h" #include "esp_log.h" -#include +#include #include #include #include @@ -88,6 +88,10 @@ static AppDeviceCallbacks EchoCallbacks; static DeviceCallbacksDelegate sAppDeviceCallbacksDelegate; namespace { + +constexpr chip::EndpointId kEvseEndpoint = 1; +constexpr chip::EndpointId kWaterHeaterEndpoint = 2; + #if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider; #endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER @@ -152,7 +156,7 @@ chip::BitMask GetFeatureMapFromCmdLine() #error Cannot define CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE and CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE #endif -EndpointId GetMainAppEndpointId() +EndpointId GetEnergyDeviceEndpointId() { #if defined(CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) return kWaterHeaterEndpoint; @@ -166,13 +170,13 @@ void ApplicationInit() ESP_LOGD(TAG, "Energy Management App: ApplicationInit()"); #if CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE - EvseApplicationInit(kEvseEndpoint); + EvseApplicationInit(); // Disable Water Heater Endpoint emberAfEndpointEnableDisable(kWaterHeaterEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE - WaterHeaterApplicationInit(kWaterHeaterEndpoint); + WaterHeaterApplicationInit(); // Disable EVSE Endpoint emberAfEndpointEnableDisable(kEvseEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE diff --git a/examples/energy-management-app/linux/BUILD.gn b/examples/energy-management-app/linux/BUILD.gn index e2980e541ce165..e742c05d692296 100644 --- a/examples/energy-management-app/linux/BUILD.gn +++ b/examples/energy-management-app/linux/BUILD.gn @@ -34,7 +34,7 @@ config("includes") { executable("chip-energy-management-app") { sources = [ - "${chip_root}/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp", + "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index a4df9b0dbb9eb6..c6fdd2b98a2a91 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -17,9 +17,9 @@ */ #include -#include #include #include +#include #include #include #include @@ -41,10 +41,12 @@ static bool EnergyAppOptionHandler(const char * aProgram, chip::ArgParser::Optio constexpr uint16_t kOptionApplication = 0xffd0; constexpr uint16_t kOptionFeatureMap = 0xffd1; -constexpr const char * kEvseApp = "evse"; -constexpr const char * kWhmApp = "water-heater"; -constexpr const char * kValidApps[] = { kEvseApp, kWhmApp }; -constexpr EndpointId kValidEEMEndpoints[] = { kEvseEndpoint, kWaterHeaterEndpoint }; +constexpr chip::EndpointId kEvseEndpoint = 1; +constexpr chip::EndpointId kWaterHeaterEndpoint = 2; +constexpr const char * kEvseApp = "evse"; +constexpr const char * kWhmApp = "water-heater"; +constexpr const char * kValidApps[] = { kEvseApp, kWhmApp }; +constexpr EndpointId kValidEndpoints[] = { kEvseEndpoint, kWaterHeaterEndpoint }; // Define the chip::ArgParser command line structures for extending the command line to support the // energy apps @@ -71,8 +73,8 @@ static chip::BitMask sFeatureMap(Feature::kPowerAdjustment, Feature::kP Feature::kForecastAdjustment, Feature::kConstraintBasedAdjustment); // Make EVSE the default app -static const char * spApp = kEvseApp; -EndpointId eemEndpoint = kEvseEndpoint; +static const char * spApp = kEvseApp; +static EndpointId sAppEndpointId = kEvseEndpoint; chip::BitMask GetFeatureMapFromCmdLine() { @@ -84,9 +86,9 @@ chip::BitMask GetFeatureMapFromCmdLine() } // namespace app } // namespace chip -EndpointId GetMainAppEndpointId() +chip::EndpointId GetEnergyDeviceEndpointId() { - return eemEndpoint; + return sAppEndpointId; } static uint32_t ParseNumber(const char * pString) @@ -109,15 +111,15 @@ void ApplicationInit() ChipLogDetail(AppServer, "Energy Management App: ApplicationInit()"); if (strcmp(spApp, kEvseApp) == 0) { - EvseApplicationInit(kEvseEndpoint); // Disable Water Heater Endpoint emberAfEndpointEnableDisable(kWaterHeaterEndpoint, false); + EvseApplicationInit(); } else if (strcmp(spApp, kWhmApp) == 0) { - WaterHeaterApplicationInit(kWaterHeaterEndpoint); // Disable EVSE Endpoint emberAfEndpointEnableDisable(kEvseEndpoint, false); + WaterHeaterApplicationInit(); } else { @@ -146,8 +148,8 @@ static bool EnergyAppOptionHandler(const char * aProgram, chip::ArgParser::Optio { if (strcmp(kValidApps[idx], aValue) == 0) { - spApp = kValidApps[idx]; - eemEndpoint = kValidEEMEndpoints[idx]; + spApp = kValidApps[idx]; + sAppEndpointId = kValidEndpoints[idx]; break; } } diff --git a/examples/energy-management-app/silabs/BUILD.gn b/examples/energy-management-app/silabs/BUILD.gn index 012c2d170ba04f..cdf218b5142a98 100644 --- a/examples/energy-management-app/silabs/BUILD.gn +++ b/examples/energy-management-app/silabs/BUILD.gn @@ -166,7 +166,7 @@ silabs_executable("energy-management-app") { } sources = [ - "${chip_root}/examples/energy-management-app/energy-management-common/common/src/CommonMain.cpp", + "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", "${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", diff --git a/examples/energy-management-app/silabs/src/AppTask.cpp b/examples/energy-management-app/silabs/src/AppTask.cpp index d7d61e8340d483..173b14a999bb02 100644 --- a/examples/energy-management-app/silabs/src/AppTask.cpp +++ b/examples/energy-management-app/silabs/src/AppTask.cpp @@ -21,7 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" #include "LEDWidget.h" -#include +#include #include #include #include @@ -73,7 +73,11 @@ #define APP_EVSE_SWITCH 1 namespace { + LEDWidget sEnergyManagementLED; +constexpr chip::EndpointId kEvseEndpoint = 1; +constexpr chip::EndpointId kWaterHeaterEndpoint = 2; + } // namespace using namespace chip; @@ -127,7 +131,7 @@ chip::BitMask GetFeatureMapFromCmdLine() AppTask AppTask::sAppTask; -EndpointId GetMainAppEndpointId() +EndpointId GetEnergyDeviceEndpointId() { #if defined(SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE) return kWaterHeaterEndpoint; @@ -143,7 +147,7 @@ void ApplicationInit() #if SL_MATTER_CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE SILABS_LOG("energy-management-example EVSE starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); - EvseApplicationInit(kEvseEndpoint); + EvseApplicationInit(); // Disable Water Heater Endpoint emberAfEndpointEnableDisable(kWaterHeaterEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE @@ -151,7 +155,7 @@ void ApplicationInit() #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE SILABS_LOG("energy-management-example WaterHeater starting. featureMap 0x%08lx", DeviceEnergyManagement::sFeatureMap.Raw()); - WaterHeaterApplicationInit(kWaterHeaterEndpoint); + WaterHeaterApplicationInit(); // Disable EVSE Endpoint emberAfEndpointEnableDisable(kEvseEndpoint, false); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE From 414309050ffea44b00baf380a75f1fdfd35fd683 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 29 Oct 2024 18:11:45 +0000 Subject: [PATCH 11/23] Fix typo on init --- .../common/src/EnergyManagementAppCommonMain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp b/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp index 8d7855a1fb3b93..a6b8e6747debb7 100644 --- a/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp +++ b/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp @@ -283,10 +283,10 @@ CHIP_ERROR EnergyManagementCommonClustersInit(chip::EndpointId endpointId) ElectricalPowerMeasurementInit(endpointId); PowerTopologyInit(endpointId); } - VerifyOrReturnError((!gDEMDelegate && !gDEMInstance), CHIP_ERROR_INCORRECT_STATE); - VerifyOrReturnError((!gEPMDelegate && !gEPMInstance), CHIP_ERROR_INCORRECT_STATE); - VerifyOrReturnError((!gPTDelegate && !gPTInstance), CHIP_ERROR_INCORRECT_STATE); - VerifyOrReturnError((!gEEMAttrAccess), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(gDEMDelegate && gDEMInstance, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(gEPMDelegate && gEPMInstance, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(gPTDelegate && gPTInstance, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(gEEMAttrAccess, CHIP_ERROR_INCORRECT_STATE); gCommonClustersInitialized = true; return CHIP_NO_ERROR; } From b63a9d0e80e0bcae98216bc6b8c286ce70fe9663 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Wed, 30 Oct 2024 15:20:47 +0000 Subject: [PATCH 12/23] fix all-clusters breakage on esp32 --- .../all-clusters-common/src/energy-evse-stub.cpp | 5 +++++ examples/all-clusters-app/linux/main-common.cpp | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) 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 6acc81ac285b65..efaa19600bb9e9 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 @@ -26,6 +26,11 @@ static std::unique_ptr gDelegate; static std::unique_ptr gEvseTargetsDelegate; static std::unique_ptr gInstance; +EndpointId GetEnergyDeviceEndpointId() +{ + return chip::EndpointId(1); +} + void emberAfEnergyEvseClusterInitCallback(chip::EndpointId endpointId) { VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index cc51eb9abd5654..22170885db1cbe 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -131,11 +131,6 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp4TagList[] = { { extern void MatterDishwasherAlarmServerInit(); #endif -EndpointId GetEnergyDeviceEndpointId() -{ - return chip::EndpointId(1); -} - void OnIdentifyStart(::Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); From 50fb8159c0d9059d9a14f79604fc3903ed4ee35d Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Wed, 30 Oct 2024 20:02:49 +0000 Subject: [PATCH 13/23] fix misuse of namespace in header --- .../energy-evse/include/EnergyEvseMain.h | 11 ++++------- examples/energy-management-app/linux/main.cpp | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h index 02427aec4dab92..bc5e0979536d6b 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h +++ b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h @@ -24,14 +24,11 @@ #include #include -using namespace chip::app::Clusters; -using namespace chip::app::Clusters::ElectricalPowerMeasurement; -using namespace chip::app::Clusters::PowerTopology; -using namespace chip::app::Clusters::DeviceEnergyManagement; - CHIP_ERROR EnergyEvseInit(chip::EndpointId endpointId); CHIP_ERROR EnergyEvseShutdown(); -CHIP_ERROR EVSEManufacturerInit(ElectricalPowerMeasurementInstance & epmInstance, PowerTopologyInstance & ptInstance, - DeviceEnergyManagementManager & demInstance, DeviceEnergyManagementDelegate & demDelegate); +CHIP_ERROR EVSEManufacturerInit(chip::app::Clusters::ElectricalPowerMeasurement::ElectricalPowerMeasurementInstance & epmInstance, + chip::app::Clusters::PowerTopology::PowerTopologyInstance & ptInstance, + chip::app::Clusters::DeviceEnergyManagementManager & demInstance, + chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate & demDelegate); CHIP_ERROR EVSEManufacturerShutdown(); diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index c6fdd2b98a2a91..45cf66aa8fc3b5 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -17,7 +17,6 @@ */ #include -#include #include #include #include From 2f140ea2fd12473963023ca881920115e8f24c01 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 31 Oct 2024 20:51:42 +0000 Subject: [PATCH 14/23] Fix breakage for silabs water heater --- examples/energy-management-app/silabs/src/AppTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/energy-management-app/silabs/src/AppTask.cpp b/examples/energy-management-app/silabs/src/AppTask.cpp index 173b14a999bb02..f90952ea456f65 100644 --- a/examples/energy-management-app/silabs/src/AppTask.cpp +++ b/examples/energy-management-app/silabs/src/AppTask.cpp @@ -172,7 +172,7 @@ void ApplicationShutdown() #endif // CONFIG_ENABLE_EXAMPLE_EVSE_DEVICE #if SL_CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE - FullWhmApplicationShutdown(); + WaterHeaterApplicationShutdown(); #endif // CONFIG_ENABLE_EXAMPLE_WATER_HEATER_DEVICE chip::DeviceLayer::PlatformMgr().UnlockChipStack(); } From 97ced722cc767ed4076ba69db7105d5e7747e239 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Mon, 4 Nov 2024 17:41:21 +0000 Subject: [PATCH 15/23] Update WaterHeater endpoint for CI tests This fixes REPL test CI breakage. --- src/python_testing/TC_EWATERHTR_2_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_EWATERHTR_2_2.py b/src/python_testing/TC_EWATERHTR_2_2.py index 1bd7185b1f6e60..ea5e6701d5d453 100644 --- a/src/python_testing/TC_EWATERHTR_2_2.py +++ b/src/python_testing/TC_EWATERHTR_2_2.py @@ -35,7 +35,7 @@ # --discriminator 1234 # --passcode 20202021 # --hex-arg enableKey:000102030405060708090a0b0c0d0e0f -# --endpoint 1 +# --endpoint 2 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # factory-reset: true From a4936c2d08e159d43a1dd2a4ed2a45753bfc2726 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 5 Nov 2024 16:07:32 +0000 Subject: [PATCH 16/23] Update WaterHeater tests to endpoint 2 --- src/python_testing/TC_EWATERHTR_2_1.py | 2 +- src/python_testing/TC_EWATERHTR_2_3.py | 2 +- src/python_testing/TC_WHM_1_2.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_EWATERHTR_2_1.py b/src/python_testing/TC_EWATERHTR_2_1.py index 82c9e93dad0414..c0eeaaea3d19a2 100644 --- a/src/python_testing/TC_EWATERHTR_2_1.py +++ b/src/python_testing/TC_EWATERHTR_2_1.py @@ -35,7 +35,7 @@ # --discriminator 1234 # --passcode 20202021 # --hex-arg enableKey:000102030405060708090a0b0c0d0e0f -# --endpoint 1 +# --endpoint 2 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # factory-reset: true diff --git a/src/python_testing/TC_EWATERHTR_2_3.py b/src/python_testing/TC_EWATERHTR_2_3.py index 0f1c3deae690f3..8d8cebe63ec278 100644 --- a/src/python_testing/TC_EWATERHTR_2_3.py +++ b/src/python_testing/TC_EWATERHTR_2_3.py @@ -34,7 +34,7 @@ # --discriminator 1234 # --passcode 20202021 # --hex-arg enableKey:000102030405060708090a0b0c0d0e0f -# --endpoint 1 +# --endpoint 2 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # factory-reset: true diff --git a/src/python_testing/TC_WHM_1_2.py b/src/python_testing/TC_WHM_1_2.py index 2bbcdd5108b03f..a0a5918999f9bf 100644 --- a/src/python_testing/TC_WHM_1_2.py +++ b/src/python_testing/TC_WHM_1_2.py @@ -31,7 +31,7 @@ # --discriminator 1234 # --passcode 20202021 # --hex-arg enableKey:000102030405060708090a0b0c0d0e0f -# --endpoint 1 +# --endpoint 2 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # factory-reset: true From d52ca430c79a7da8aadfb7d99e7bcefabaabe7e8 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 5 Nov 2024 18:45:57 +0000 Subject: [PATCH 17/23] Bumped ClusterRevisions Cluster 40 (0x28) BasicInformation - 3 -> 4 Cluster 47 (0x2f) PowerSource - 2 -> 3 Cluster 48 (0x30) GeneralCommissioning 1-> 2 Cluster 3 (0x03) Identify 4 -> 5 Cluster 153 (0x99) EnergyEvse 2 -> 3 Cluster 157 (0x9d) EnergyEvseMode 1-> 2 Cluster 159 (0x9f) DeviceEnergyManagementMode 1-> 2 --- .../energy-management-app.matter | 18 +- .../energy-management-app.zap | 554 +----------------- 2 files changed, 30 insertions(+), 542 deletions(-) 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 7bd9cb448e0c8b..8f2de64615bcdf 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 @@ -2803,7 +2803,7 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 3; + ram attribute clusterRevision default = 4; } server cluster LocalizationConfiguration { @@ -2845,7 +2845,7 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 2; + ram attribute clusterRevision default = 3; } server cluster GeneralCommissioning { @@ -2858,7 +2858,7 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; handle command ArmFailSafe; handle command ArmFailSafeResponse; @@ -2971,7 +2971,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; + ram attribute clusterRevision default = 5; handle command Identify; handle command TriggerEffect; @@ -3089,7 +3089,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; callback attribute featureMap; - ram attribute clusterRevision default = 2; + ram attribute clusterRevision default = 3; handle command GetTargetsResponse; handle command Disable; @@ -3116,7 +3116,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; callback attribute featureMap; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; handle command ChangeToMode; handle command ChangeToModeResponse; @@ -3129,7 +3129,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; callback attribute featureMap; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; handle command ChangeToMode; handle command ChangeToModeResponse; @@ -3147,7 +3147,7 @@ endpoint 2 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; + ram attribute clusterRevision default = 5; handle command Identify; } @@ -3266,7 +3266,7 @@ endpoint 2 { callback attribute acceptedCommandList; callback attribute attributeList; callback attribute featureMap; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; } server cluster Thermostat { 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 56b87970e7fc9f..c8ce89671796d0 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 @@ -167,22 +167,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -353,22 +337,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -715,22 +683,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "AttributeList", "code": 65531, @@ -773,7 +725,7 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -853,22 +805,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -975,22 +911,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -1081,22 +1001,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -1299,22 +1203,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -1357,7 +1245,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1535,22 +1423,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -1593,7 +1465,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1753,22 +1625,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -1949,22 +1805,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -2121,22 +1961,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -2421,22 +2245,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -2641,22 +2449,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -2837,22 +2629,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -2895,7 +2671,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "5", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3007,22 +2783,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -3417,22 +3177,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -3619,22 +3363,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -3936,22 +3664,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -4410,22 +4122,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -4468,7 +4164,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4560,22 +4256,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -4716,22 +4396,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -4774,7 +4438,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4873,22 +4537,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -4931,7 +4579,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5008,7 +4656,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x0", - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -5024,7 +4672,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x00", - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -5061,22 +4709,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -5119,7 +4751,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "5", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5231,22 +4863,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -5641,22 +5257,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -5843,22 +5443,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -5947,7 +5531,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -5963,7 +5547,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -6027,7 +5611,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -6064,22 +5648,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -6299,22 +5867,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -6405,22 +5957,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -6508,7 +6044,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -6524,7 +6060,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -6561,22 +6097,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -6700,22 +6220,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "EventList", - "code": 65530, - "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": "AttributeList", "code": 65531, @@ -6758,7 +6262,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -6811,7 +6315,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "4", - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -6827,7 +6331,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "1", - "reportable": 0, + "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -6842,7 +6346,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -6858,23 +6362,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EventList", - "code": 65530, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -6890,7 +6378,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, From 09476fd53f569c23b1b165b3ed06890f57458b65 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Tue, 5 Nov 2024 20:28:31 +0000 Subject: [PATCH 18/23] Update AccessControl featureMap to enable Extension attribute --- .../energy-management-common/energy-management-app.matter | 2 +- .../energy-management-common/energy-management-app.zap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8f2de64615bcdf..8cfa371f13e5dd 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 @@ -2778,7 +2778,7 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; + ram attribute featureMap default = 1; callback attribute clusterRevision; } 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 c8ce89671796d0..54097bdac270b7 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 @@ -363,7 +363,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, From d8e2764ded05a1d34e7acd54ff1af661d16c6d75 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Wed, 6 Nov 2024 15:26:53 +0000 Subject: [PATCH 19/23] Remove AccessControl extension attribute --- .../energy-management-app.matter | 3 +-- .../energy-management-app.zap | 18 +----------------- 2 files changed, 2 insertions(+), 19 deletions(-) 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 8cfa371f13e5dd..705540330861d6 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 @@ -2771,14 +2771,13 @@ endpoint 0 { server cluster AccessControl { callback attribute acl; - callback attribute extension; callback attribute subjectsPerAccessControlEntry; callback attribute targetsPerAccessControlEntry; callback attribute accessControlEntriesPerFabric; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 1; + ram attribute featureMap default = 0; callback attribute clusterRevision; } 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 54097bdac270b7..4505da454e8722 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 @@ -241,22 +241,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "Extension", - "code": 1, - "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": "SubjectsPerAccessControlEntry", "code": 2, @@ -363,7 +347,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, From 24f6e7d224e2e31ab91c0030f8c0144b1a75c76c Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Wed, 6 Nov 2024 16:35:27 +0000 Subject: [PATCH 20/23] Remove kStateForecastReporting from the default feature map That feature can't be enabled together with kPowerAdjustment. --- examples/energy-management-app/linux/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index 45cf66aa8fc3b5..d4cefde1c14ace 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -68,8 +68,8 @@ namespace DeviceEnergyManagement { // Keep track of the parsed featureMap option static chip::BitMask sFeatureMap(Feature::kPowerAdjustment, Feature::kPowerForecastReporting, - Feature::kStateForecastReporting, Feature::kStartTimeAdjustment, Feature::kPausable, - Feature::kForecastAdjustment, Feature::kConstraintBasedAdjustment); + Feature::kStartTimeAdjustment, Feature::kPausable, Feature::kForecastAdjustment, + Feature::kConstraintBasedAdjustment); // Make EVSE the default app static const char * spApp = kEvseApp; From ffab349dfc7b50e33bf8baaba42aa9dec19b4ca3 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 7 Nov 2024 16:36:54 +0000 Subject: [PATCH 21/23] Update TC_WHM_1_2 endpoint to 2 --- src/python_testing/TC_WHM_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_WHM_2_1.py b/src/python_testing/TC_WHM_2_1.py index b9dcb0257d1b1a..b9757f7b93c24b 100644 --- a/src/python_testing/TC_WHM_2_1.py +++ b/src/python_testing/TC_WHM_2_1.py @@ -32,7 +32,7 @@ # --commissioning-method on-network # --discriminator 1234 # --passcode 20202021 -# --endpoint 1 +# --endpoint 2 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # factory-reset: true From 116435728befc7984d52472bfdb418b6dd506ffe Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Wed, 20 Nov 2024 21:03:00 +0000 Subject: [PATCH 22/23] Fix various conformance issues Remove PowerSource from root node and move to EP1/evse Bump cluster revisions where needed Fix device type descriptions for each EP Remove unused Thermostat cluster and added a TODO. We need to properly implement this cluster for this app for temperature control. --- .../src/EnergyManagementAppCommonMain.cpp | 4 +- .../include/EVSEManufacturerImpl.h | 4 +- .../energy-evse/include/EnergyEvseMain.h | 3 +- .../energy-evse/src/EVSEManufacturerImpl.cpp | 23 +- .../energy-evse/src/EnergyEvseMain.cpp | 7 +- .../energy-management-app.matter | 402 +---------- .../energy-management-app.zap | 651 ++++++++---------- .../water-heater/src/WhmDelegateImpl.cpp | 1 + .../water-heater/src/water-heater-mode.cpp | 3 +- .../esp32/main/CMakeLists.txt | 1 - 10 files changed, 317 insertions(+), 782 deletions(-) diff --git a/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp b/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp index a6b8e6747debb7..e35dbf7b05bd9f 100644 --- a/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp +++ b/examples/energy-management-app/energy-management-common/common/src/EnergyManagementAppCommonMain.cpp @@ -360,8 +360,8 @@ void EvseApplicationInit() auto endpointId = GetEnergyDeviceEndpointId(); VerifyOrDie(EnergyManagementCommonClustersInit(endpointId) == CHIP_NO_ERROR); VerifyOrDie(EnergyEvseInit(endpointId) == CHIP_NO_ERROR); - VerifyOrDie(EVSEManufacturerInit(*gEPMInstance.get(), *gPTInstance.get(), *gDEMInstance.get(), *gDEMDelegate.get()) == - CHIP_NO_ERROR); + VerifyOrDie(EVSEManufacturerInit(endpointId, *gEPMInstance.get(), *gPTInstance.get(), *gDEMInstance.get(), + *gDEMDelegate.get()) == CHIP_NO_ERROR); } void EvseApplicationShutdown() diff --git a/examples/energy-management-app/energy-management-common/energy-evse/include/EVSEManufacturerImpl.h b/examples/energy-management-app/energy-management-common/energy-evse/include/EVSEManufacturerImpl.h index c802cf8e047dcb..4f8c9530caeeb6 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/include/EVSEManufacturerImpl.h +++ b/examples/energy-management-app/energy-management-common/energy-evse/include/EVSEManufacturerImpl.h @@ -117,7 +117,7 @@ class EVSEManufacturer : public DEMManufacturerDelegate /** * @brief Called at start up to apply hardware settings */ - CHIP_ERROR Init(); + CHIP_ERROR Init(chip::EndpointId powerSourceEndpointId); /** * @brief Called at shutdown @@ -143,7 +143,7 @@ class EVSEManufacturer : public DEMManufacturerDelegate /** * @brief Allows a client application to initialise the PowerSource cluster */ - CHIP_ERROR InitializePowerSourceCluster(); + CHIP_ERROR InitializePowerSourceCluster(chip::EndpointId endpointId); /** * @brief Allows a client application to send in power readings into the system diff --git a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h index bc5e0979536d6b..a959267beadfd3 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h +++ b/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseMain.h @@ -27,7 +27,8 @@ CHIP_ERROR EnergyEvseInit(chip::EndpointId endpointId); CHIP_ERROR EnergyEvseShutdown(); -CHIP_ERROR EVSEManufacturerInit(chip::app::Clusters::ElectricalPowerMeasurement::ElectricalPowerMeasurementInstance & epmInstance, +CHIP_ERROR EVSEManufacturerInit(chip::EndpointId powerSourceEndpointId, + chip::app::Clusters::ElectricalPowerMeasurement::ElectricalPowerMeasurementInstance & epmInstance, chip::app::Clusters::PowerTopology::PowerTopologyInstance & ptInstance, chip::app::Clusters::DeviceEnergyManagementManager & demInstance, chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate & demDelegate); diff --git a/examples/energy-management-app/energy-management-common/energy-evse/src/EVSEManufacturerImpl.cpp b/examples/energy-management-app/energy-management-common/energy-evse/src/EVSEManufacturerImpl.cpp index 0cb5a0fe98ce02..372a6472d2c7a5 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/src/EVSEManufacturerImpl.cpp +++ b/examples/energy-management-app/energy-management-common/energy-evse/src/EVSEManufacturerImpl.cpp @@ -47,7 +47,7 @@ using namespace chip::app::Clusters::PowerSource::Attributes; using Protocols::InteractionModel::Status; -CHIP_ERROR EVSEManufacturer::Init() +CHIP_ERROR EVSEManufacturer::Init(chip::EndpointId powerSourceEndpointId) { /* Manufacturers should modify this to do any custom initialisation */ @@ -63,7 +63,7 @@ CHIP_ERROR EVSEManufacturer::Init() ReturnErrorOnFailure(InitializePowerMeasurementCluster()); - ReturnErrorOnFailure(InitializePowerSourceCluster()); + ReturnErrorOnFailure(InitializePowerSourceCluster(powerSourceEndpointId)); DeviceEnergyManagementDelegate * dem = GetEvseManufacturer()->GetDEMDelegate(); VerifyOrReturnLogError(dem != nullptr, CHIP_ERROR_UNINITIALIZED); @@ -352,31 +352,30 @@ CHIP_ERROR EVSEManufacturer::InitializePowerMeasurementCluster() /** * @brief Allows a client application to initialise the PowerSource cluster */ -CHIP_ERROR EVSEManufacturer::InitializePowerSourceCluster() +CHIP_ERROR EVSEManufacturer::InitializePowerSourceCluster(chip::EndpointId endpointId) { Protocols::InteractionModel::Status status; - status = PowerSource::Attributes::Status::Set(EndpointId(0) /*RootNode*/, PowerSourceStatusEnum::kActive); + status = PowerSource::Attributes::Status::Set(endpointId, PowerSourceStatusEnum::kActive); VerifyOrReturnError(status == Protocols::InteractionModel::Status::Success, CHIP_ERROR_INTERNAL); - status = - PowerSource::Attributes::FeatureMap::Set(EndpointId(0 /*RootNode*/), static_cast(PowerSource::Feature::kWired)); + status = PowerSource::Attributes::FeatureMap::Set(endpointId, static_cast(PowerSource::Feature::kWired)); VerifyOrReturnError(status == Protocols::InteractionModel::Status::Success, CHIP_ERROR_INTERNAL); - status = PowerSource::Attributes::WiredNominalVoltage::Set(EndpointId(0 /*RootNode*/), 230'000); // 230V in mv + status = PowerSource::Attributes::WiredNominalVoltage::Set(endpointId, 230'000); // 230V in mv VerifyOrReturnError(status == Protocols::InteractionModel::Status::Success, CHIP_ERROR_INTERNAL); - status = PowerSource::Attributes::WiredMaximumCurrent::Set(EndpointId(0 /*RootNode*/), 32'000); // 32A in mA + status = PowerSource::Attributes::WiredMaximumCurrent::Set(endpointId, 32'000); // 32A in mA VerifyOrReturnError(status == Protocols::InteractionModel::Status::Success, CHIP_ERROR_INTERNAL); - status = PowerSource::Attributes::WiredCurrentType::Set(EndpointId(0 /*RootNode*/), PowerSource::WiredCurrentTypeEnum::kAc); + status = PowerSource::Attributes::WiredCurrentType::Set(endpointId, PowerSource::WiredCurrentTypeEnum::kAc); VerifyOrReturnError(status == Protocols::InteractionModel::Status::Success, CHIP_ERROR_INTERNAL); - status = PowerSource::Attributes::Description::Set(EndpointId(0 /*RootNode*/), CharSpan::fromCharString("Primary Mains Power")); + status = PowerSource::Attributes::Description::Set(endpointId, CharSpan::fromCharString("Primary Mains Power")); VerifyOrReturnError(status == Protocols::InteractionModel::Status::Success, CHIP_ERROR_INTERNAL); - chip::EndpointId endpointArray[] = { 1 /* EVSE Endpoint */ }; + chip::EndpointId endpointArray[] = { endpointId }; Span endpointList = Span(endpointArray); // Note per API - we do not need to maintain the span after the SetEndpointList has been called // since it takes a copy (see power-source-server.cpp) - PowerSourceServer::Instance().SetEndpointList(0 /* Root Node */, endpointList); + PowerSourceServer::Instance().SetEndpointList(endpointId, endpointList); return CHIP_NO_ERROR; } diff --git a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp index 37553144f2f026..8c3383db337113 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp +++ b/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseMain.cpp @@ -156,8 +156,9 @@ CHIP_ERROR EnergyEvseShutdown() * create the Delegate first, then wrap it in the Instance * Then call the Instance->Init() to register the attribute and command handlers */ -CHIP_ERROR EVSEManufacturerInit(ElectricalPowerMeasurementInstance & epmInstance, PowerTopologyInstance & ptInstance, - DeviceEnergyManagementManager & demInstance, DeviceEnergyManagementDelegate & demDelegate) +CHIP_ERROR EVSEManufacturerInit(chip::EndpointId powerSourceEndpointId, ElectricalPowerMeasurementInstance & epmInstance, + PowerTopologyInstance & ptInstance, DeviceEnergyManagementManager & demInstance, + DeviceEnergyManagementDelegate & demDelegate) { CHIP_ERROR err; @@ -178,7 +179,7 @@ CHIP_ERROR EVSEManufacturerInit(ElectricalPowerMeasurementInstance & epmInstance demDelegate.SetDEMManufacturerDelegate(*gEvseManufacturer.get()); /* Call Manufacturer specific init */ - err = gEvseManufacturer->Init(); + err = gEvseManufacturer->Init(powerSourceEndpointId); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "Init failed on gEvseManufacturer"); 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 705540330861d6..bdcbe117c8344b 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 @@ -2398,361 +2398,6 @@ provisional cluster DeviceEnergyManagementMode = 159 { command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0; } -/** An interface for configuring and controlling the functionality of a thermostat. */ -cluster Thermostat = 513 { - revision 7; - - enum ACCapacityFormatEnum : enum8 { - kBTUh = 0; - } - - enum ACCompressorTypeEnum : enum8 { - kUnknown = 0; - kT1 = 1; - kT2 = 2; - kT3 = 3; - } - - enum ACLouverPositionEnum : enum8 { - kClosed = 1; - kOpen = 2; - kQuarter = 3; - kHalf = 4; - kThreeQuarters = 5; - } - - enum ACRefrigerantTypeEnum : enum8 { - kUnknown = 0; - kR22 = 1; - kR410a = 2; - kR407c = 3; - } - - enum ACTypeEnum : enum8 { - kUnknown = 0; - kCoolingFixed = 1; - kHeatPumpFixed = 2; - kCoolingInverter = 3; - kHeatPumpInverter = 4; - } - - enum ControlSequenceOfOperationEnum : enum8 { - kCoolingOnly = 0; - kCoolingWithReheat = 1; - kHeatingOnly = 2; - kHeatingWithReheat = 3; - kCoolingAndHeating = 4; - kCoolingAndHeatingWithReheat = 5; - } - - enum PresetScenarioEnum : enum8 { - kOccupied = 1; - kUnoccupied = 2; - kSleep = 3; - kWake = 4; - kVacation = 5; - kGoingToSleep = 6; - kUserDefined = 254; - } - - enum SetpointChangeSourceEnum : enum8 { - kManual = 0; - kSchedule = 1; - kExternal = 2; - } - - enum SetpointRaiseLowerModeEnum : enum8 { - kHeat = 0; - kCool = 1; - kBoth = 2; - } - - enum StartOfWeekEnum : enum8 { - kSunday = 0; - kMonday = 1; - kTuesday = 2; - kWednesday = 3; - kThursday = 4; - kFriday = 5; - kSaturday = 6; - } - - enum SystemModeEnum : enum8 { - kOff = 0; - kAuto = 1; - kCool = 3; - kHeat = 4; - kEmergencyHeat = 5; - kPrecooling = 6; - kFanOnly = 7; - kDry = 8; - kSleep = 9; - } - - enum TemperatureSetpointHoldEnum : enum8 { - kSetpointHoldOff = 0; - kSetpointHoldOn = 1; - } - - enum ThermostatRunningModeEnum : enum8 { - kOff = 0; - kCool = 3; - kHeat = 4; - } - - bitmap ACErrorCodeBitmap : bitmap32 { - kCompressorFail = 0x1; - kRoomSensorFail = 0x2; - kOutdoorSensorFail = 0x4; - kCoilSensorFail = 0x8; - kFanFail = 0x10; - } - - bitmap Feature : bitmap32 { - kHeating = 0x1; - kCooling = 0x2; - kOccupancy = 0x4; - kScheduleConfiguration = 0x8; - kSetback = 0x10; - kAutoMode = 0x20; - kLocalTemperatureNotExposed = 0x40; - kMatterScheduleConfiguration = 0x80; - kPresets = 0x100; - } - - bitmap HVACSystemTypeBitmap : bitmap8 { - kCoolingStage = 0x3; - kHeatingStage = 0xC; - kHeatingIsHeatPump = 0x10; - kHeatingUsesFuel = 0x20; - } - - bitmap OccupancyBitmap : bitmap8 { - kOccupied = 0x1; - } - - bitmap PresetTypeFeaturesBitmap : bitmap16 { - kAutomatic = 0x1; - kSupportsNames = 0x2; - } - - bitmap ProgrammingOperationModeBitmap : bitmap8 { - kScheduleActive = 0x1; - kAutoRecovery = 0x2; - kEconomy = 0x4; - } - - bitmap RelayStateBitmap : bitmap16 { - kHeat = 0x1; - kCool = 0x2; - kFan = 0x4; - kHeatStage2 = 0x8; - kCoolStage2 = 0x10; - kFanStage2 = 0x20; - kFanStage3 = 0x40; - } - - bitmap RemoteSensingBitmap : bitmap8 { - kLocalTemperature = 0x1; - kOutdoorTemperature = 0x2; - kOccupancy = 0x4; - } - - bitmap ScheduleDayOfWeekBitmap : bitmap8 { - kSunday = 0x1; - kMonday = 0x2; - kTuesday = 0x4; - kWednesday = 0x8; - kThursday = 0x10; - kFriday = 0x20; - kSaturday = 0x40; - kAway = 0x80; - } - - bitmap ScheduleModeBitmap : bitmap8 { - kHeatSetpointPresent = 0x1; - kCoolSetpointPresent = 0x2; - } - - bitmap ScheduleTypeFeaturesBitmap : bitmap16 { - kSupportsPresets = 0x1; - kSupportsSetpoints = 0x2; - kSupportsNames = 0x4; - kSupportsOff = 0x8; - } - - struct ScheduleTransitionStruct { - ScheduleDayOfWeekBitmap dayOfWeek = 0; - int16u transitionTime = 1; - optional octet_string<16> presetHandle = 2; - optional SystemModeEnum systemMode = 3; - optional temperature coolingSetpoint = 4; - optional temperature heatingSetpoint = 5; - } - - struct ScheduleStruct { - nullable octet_string<16> scheduleHandle = 0; - SystemModeEnum systemMode = 1; - optional char_string<64> name = 2; - optional octet_string<16> presetHandle = 3; - ScheduleTransitionStruct transitions[] = 4; - nullable boolean builtIn = 5; - } - - struct PresetStruct { - nullable octet_string<16> presetHandle = 0; - PresetScenarioEnum presetScenario = 1; - optional nullable char_string<64> name = 2; - optional temperature coolingSetpoint = 3; - optional temperature heatingSetpoint = 4; - nullable boolean builtIn = 5; - } - - struct PresetTypeStruct { - PresetScenarioEnum presetScenario = 0; - int8u numberOfPresets = 1; - PresetTypeFeaturesBitmap presetTypeFeatures = 2; - } - - struct ScheduleTypeStruct { - SystemModeEnum systemMode = 0; - int8u numberOfSchedules = 1; - ScheduleTypeFeaturesBitmap scheduleTypeFeatures = 2; - } - - struct WeeklyScheduleTransitionStruct { - int16u transitionTime = 0; - nullable temperature heatSetpoint = 1; - nullable temperature coolSetpoint = 2; - } - - readonly attribute nullable temperature localTemperature = 0; - readonly attribute optional nullable temperature outdoorTemperature = 1; - readonly attribute optional OccupancyBitmap occupancy = 2; - readonly attribute optional temperature absMinHeatSetpointLimit = 3; - readonly attribute optional temperature absMaxHeatSetpointLimit = 4; - readonly attribute optional temperature absMinCoolSetpointLimit = 5; - readonly attribute optional temperature absMaxCoolSetpointLimit = 6; - readonly attribute optional int8u PICoolingDemand = 7; - readonly attribute optional int8u PIHeatingDemand = 8; - attribute access(write: manage) optional HVACSystemTypeBitmap HVACSystemTypeConfiguration = 9; - attribute access(write: manage) optional int8s localTemperatureCalibration = 16; - attribute optional temperature occupiedCoolingSetpoint = 17; - attribute optional temperature occupiedHeatingSetpoint = 18; - attribute optional temperature unoccupiedCoolingSetpoint = 19; - attribute optional temperature unoccupiedHeatingSetpoint = 20; - attribute access(write: manage) optional temperature minHeatSetpointLimit = 21; - attribute access(write: manage) optional temperature maxHeatSetpointLimit = 22; - attribute access(write: manage) optional temperature minCoolSetpointLimit = 23; - attribute access(write: manage) optional temperature maxCoolSetpointLimit = 24; - attribute access(write: manage) optional int8s minSetpointDeadBand = 25; - attribute access(write: manage) optional RemoteSensingBitmap remoteSensing = 26; - attribute access(write: manage) ControlSequenceOfOperationEnum controlSequenceOfOperation = 27; - attribute access(write: manage) SystemModeEnum systemMode = 28; - readonly attribute optional ThermostatRunningModeEnum thermostatRunningMode = 30; - readonly attribute optional StartOfWeekEnum startOfWeek = 32; - readonly attribute optional int8u numberOfWeeklyTransitions = 33; - readonly attribute optional int8u numberOfDailyTransitions = 34; - attribute access(write: manage) optional TemperatureSetpointHoldEnum temperatureSetpointHold = 35; - attribute access(write: manage) optional nullable int16u temperatureSetpointHoldDuration = 36; - attribute access(write: manage) optional ProgrammingOperationModeBitmap thermostatProgrammingOperationMode = 37; - readonly attribute optional RelayStateBitmap thermostatRunningState = 41; - readonly attribute optional SetpointChangeSourceEnum setpointChangeSource = 48; - readonly attribute optional nullable int16s setpointChangeAmount = 49; - readonly attribute optional epoch_s setpointChangeSourceTimestamp = 50; - attribute access(write: manage) optional nullable int8u occupiedSetback = 52; - readonly attribute optional nullable int8u occupiedSetbackMin = 53; - readonly attribute optional nullable int8u occupiedSetbackMax = 54; - attribute access(write: manage) optional nullable int8u unoccupiedSetback = 55; - readonly attribute optional nullable int8u unoccupiedSetbackMin = 56; - readonly attribute optional nullable int8u unoccupiedSetbackMax = 57; - attribute access(write: manage) optional int8u emergencyHeatDelta = 58; - attribute access(write: manage) optional ACTypeEnum ACType = 64; - attribute access(write: manage) optional int16u ACCapacity = 65; - attribute access(write: manage) optional ACRefrigerantTypeEnum ACRefrigerantType = 66; - attribute access(write: manage) optional ACCompressorTypeEnum ACCompressorType = 67; - attribute access(write: manage) optional ACErrorCodeBitmap ACErrorCode = 68; - attribute access(write: manage) optional ACLouverPositionEnum ACLouverPosition = 69; - readonly attribute optional nullable temperature ACCoilTemperature = 70; - attribute access(write: manage) optional ACCapacityFormatEnum ACCapacityformat = 71; - readonly attribute optional PresetTypeStruct presetTypes[] = 72; - readonly attribute optional ScheduleTypeStruct scheduleTypes[] = 73; - readonly attribute optional int8u numberOfPresets = 74; - readonly attribute optional int8u numberOfSchedules = 75; - readonly attribute optional int8u numberOfScheduleTransitions = 76; - readonly attribute optional nullable int8u numberOfScheduleTransitionPerDay = 77; - readonly attribute optional nullable octet_string<16> activePresetHandle = 78; - readonly attribute optional nullable octet_string<16> activeScheduleHandle = 79; - attribute access(write: manage) optional PresetStruct presets[] = 80; - attribute access(write: manage) optional ScheduleStruct schedules[] = 81; - readonly attribute optional nullable epoch_s setpointHoldExpiryTimestamp = 82; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct SetpointRaiseLowerRequest { - SetpointRaiseLowerModeEnum mode = 0; - int8s amount = 1; - } - - response struct GetWeeklyScheduleResponse = 0 { - int8u numberOfTransitionsForSequence = 0; - ScheduleDayOfWeekBitmap dayOfWeekForSequence = 1; - ScheduleModeBitmap modeForSequence = 2; - WeeklyScheduleTransitionStruct transitions[] = 3; - } - - request struct SetWeeklyScheduleRequest { - int8u numberOfTransitionsForSequence = 0; - ScheduleDayOfWeekBitmap dayOfWeekForSequence = 1; - ScheduleModeBitmap modeForSequence = 2; - WeeklyScheduleTransitionStruct transitions[] = 3; - } - - request struct GetWeeklyScheduleRequest { - ScheduleDayOfWeekBitmap daysToReturn = 0; - ScheduleModeBitmap modeToReturn = 1; - } - - request struct SetActiveScheduleRequestRequest { - octet_string<16> scheduleHandle = 0; - } - - request struct SetActivePresetRequestRequest { - nullable octet_string<16> presetHandle = 0; - } - - response struct AtomicResponse = 253 { - status statusCode = 0; - AtomicAttributeStatusStruct attributeStatus[] = 1; - optional int16u timeout = 2; - } - - request struct AtomicRequestRequest { - AtomicRequestTypeEnum requestType = 0; - attrib_id attributeRequests[] = 1; - optional int16u timeout = 2; - } - - /** Upon receipt, the attributes for the indicated setpoint(s) SHALL have the amount specified in the Amount field added to them. */ - command SetpointRaiseLower(SetpointRaiseLowerRequest): DefaultSuccess = 0; - /** This command is used to update the thermostat weekly setpoint schedule from a management system. */ - command access(invoke: manage) SetWeeklySchedule(SetWeeklyScheduleRequest): DefaultSuccess = 1; - /** The Current Weekly Schedule Command is sent from the server in response to the Get Weekly Schedule Command. */ - command GetWeeklySchedule(GetWeeklyScheduleRequest): GetWeeklyScheduleResponse = 2; - /** This command is used to clear the weekly schedule. */ - command access(invoke: manage) ClearWeeklySchedule(): DefaultSuccess = 3; - /** Upon receipt, if the Schedules attribute contains a ScheduleStruct whose ScheduleHandle field matches the value of the ScheduleHandle field, the server SHALL set the thermostat's ActiveScheduleHandle attribute to the value of the ScheduleHandle field. */ - command SetActiveScheduleRequest(SetActiveScheduleRequestRequest): DefaultSuccess = 5; - /** ID */ - command SetActivePresetRequest(SetActivePresetRequestRequest): DefaultSuccess = 6; - /** Begins, Commits or Cancels an atomic write */ - command access(invoke: manage) AtomicRequest(AtomicRequestRequest): AtomicResponse = 254; -} - endpoint 0 { device type ma_rootdevice = 22, version 1; @@ -2832,21 +2477,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; } - server cluster PowerSource { - ram attribute status; - ram attribute order; - ram attribute description; - ram attribute wiredCurrentType; - ram attribute wiredNominalVoltage; - ram attribute wiredMaximumCurrent; - callback attribute endpointList; - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 3; - } - server cluster GeneralCommissioning { ram attribute breadcrumb default = 0x0000000000000000; callback attribute basicCommissioningInfo; @@ -2959,8 +2589,10 @@ endpoint 0 { } } endpoint 1 { + device type ma_powersource = 17, version 1; device type ma_electricalsensor = 1296, version 1; device type energy_evse = 1292, version 1; + device type device_energy_management = 1293, version 1; server cluster Identify { @@ -2988,6 +2620,21 @@ endpoint 1 { callback attribute clusterRevision; } + server cluster PowerSource { + ram attribute status; + ram attribute order; + ram attribute description; + ram attribute wiredCurrentType; + ram attribute wiredNominalVoltage; + ram attribute wiredMaximumCurrent; + callback attribute endpointList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 3; + } + server cluster ElectricalPowerMeasurement { callback attribute powerMode; callback attribute numberOfMeasurementTypes; @@ -3136,6 +2783,7 @@ endpoint 1 { } endpoint 2 { device type ma_electricalsensor = 1296, version 1; + device type device_energy_management = 1293, version 1; device type ma_waterheater = 1295, version 1; @@ -3266,19 +2914,9 @@ endpoint 2 { callback attribute attributeList; callback attribute featureMap; ram attribute clusterRevision default = 2; - } - server cluster Thermostat { - ram attribute localTemperature; - ram attribute controlSequenceOfOperation default = 4; - ram attribute systemMode default = 1; - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 7; - - handle command SetpointRaiseLower; + handle command ChangeToMode; + handle command ChangeToModeResponse; } } 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 4505da454e8722..ee365c7ec5c32e 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 @@ -1035,208 +1035,6 @@ } ] }, - { - "name": "Power Source", - "code": 47, - "mfgCode": null, - "define": "POWER_SOURCE_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "Status", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "PowerSourceStatusEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "Order", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "Description", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredCurrentType", - "code": 5, - "mfgCode": null, - "side": "server", - "type": "WiredCurrentTypeEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredNominalVoltage", - "code": 7, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredMaximumCurrent", - "code": 8, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EndpointList", - "code": 31, - "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": "GeneratedCommandList", - "code": 65528, - "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": "AcceptedCommandList", - "code": 65529, - "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": "AttributeList", - "code": 65531, - "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": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, { "name": "General Commissioning", "code": 48, @@ -2509,15 +2307,33 @@ "label": "MA-electricalsensor", "name": "MA-electricalsensor", "deviceTypeOrder": 1 + }, + { + "code": 1293, + "profileId": 259, + "label": "Device Energy Management", + "name": "Device Energy Management", + "deviceTypeOrder": 2 + }, + { + "code": 17, + "profileId": 259, + "label": "MA-powersource", + "name": "MA-powersource", + "deviceTypeOrder": 3 } ], "deviceVersions": [ + 1, + 1, 1, 1 ], "deviceIdentifiers": [ 1292, - 1296 + 1296, + 1293, + 17 ], "deviceTypeName": "Energy EVSE", "deviceTypeCode": 1292, @@ -2636,10 +2452,164 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "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": "ServerList", + "code": 1, + "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": "ClientList", + "code": 2, + "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": "PartsList", + "code": 3, + "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": "GeneratedCommandList", + "code": 65528, + "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": "AcceptedCommandList", + "code": 65529, + "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": "AttributeList", + "code": 65531, + "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": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2652,10 +2622,10 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2664,64 +2634,112 @@ ] }, { - "name": "Descriptor", - "code": 29, + "name": "Power Source", + "code": 47, "mfgCode": null, - "define": "DESCRIPTOR_CLUSTER", + "define": "POWER_SOURCE_CLUSTER", "side": "server", "enabled": 1, "attributes": [ { - "name": "DeviceTypeList", + "name": "Status", "code": 0, "mfgCode": null, "side": "server", - "type": "array", + "type": "PowerSourceStatusEnum", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ServerList", + "name": "Order", "code": 1, "mfgCode": null, "side": "server", - "type": "array", + "type": "int8u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClientList", + "name": "Description", "code": 2, "mfgCode": null, "side": "server", - "type": "array", + "type": "char_string", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "PartsList", - "code": 3, + "name": "WiredCurrentType", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "WiredCurrentTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "WiredNominalVoltage", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "WiredMaximumCurrent", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EndpointList", + "code": 31, "mfgCode": null, "side": "server", "type": "array", @@ -2790,10 +2808,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2806,10 +2824,10 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4597,15 +4615,24 @@ "label": "MA-electricalsensor", "name": "MA-electricalsensor", "deviceTypeOrder": 1 + }, + { + "code": 1293, + "profileId": 259, + "label": "Device Energy Management", + "name": "Device Energy Management", + "deviceTypeOrder": 2 } ], "deviceVersions": [ + 1, 1, 1 ], "deviceIdentifiers": [ 1295, - 1296 + 1296, + 1293 ], "deviceTypeName": "MA-waterheater", "deviceTypeCode": 1295, @@ -6139,6 +6166,24 @@ "side": "server", "enabled": 1, "apiMaturity": "provisional", + "commands": [ + { + "name": "ChangeToMode", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ChangeToModeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], "attributes": [ { "name": "SupportedModes", @@ -6253,154 +6298,6 @@ "reportableChange": 0 } ] - }, - { - "name": "Thermostat", - "code": 513, - "mfgCode": null, - "define": "THERMOSTAT_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "SetpointRaiseLower", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], - "attributes": [ - { - "name": "LocalTemperature", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "temperature", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ControlSequenceOfOperation", - "code": 27, - "mfgCode": null, - "side": "server", - "type": "ControlSequenceOfOperationEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "SystemMode", - "code": 28, - "mfgCode": null, - "side": "server", - "type": "SystemModeEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "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": "AcceptedCommandList", - "code": 65529, - "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": "AttributeList", - "code": 65531, - "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": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "7", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] } ] } diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp index 79a64d5226f486..edab8b7cd15790 100644 --- a/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp +++ b/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp @@ -307,6 +307,7 @@ int16_t WaterHeaterManagementDelegate::GetActiveTargetWaterTemperature() const // Note, in practise the actual heating is likely to be controlled by the thermostat's occupiedHeatingSetpoint most of the // time, and the TemporarySetpoint (if not null) would be overiding the thermostat's occupiedHeatingSetpoint. // However, this code doesn't rely upon the thermostat cluster. + // TODO: Implement Thermostat Cluster temperature handling. It's mandatory to be spec conformant. int16_t targetTemperature = (mBoostState == BoostStateEnum::kActive && mBoostTemporarySetpoint.HasValue()) ? mBoostTemporarySetpoint.Value() : mTargetWaterTemperature; diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp index a22ee7254c3b8e..76f61b72b97fd8 100755 --- a/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp +++ b/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp @@ -102,7 +102,6 @@ void emberAfWaterHeaterModeClusterInitCallback(chip::EndpointId endpointId) { VerifyOrDie(gWaterHeaterModeDelegate == nullptr && gWaterHeaterModeInstance == nullptr); gWaterHeaterModeDelegate = new WaterHeaterMode::ExampleWaterHeaterModeDelegate; - gWaterHeaterModeInstance = - new ModeBase::Instance(gWaterHeaterModeDelegate, endpointId, WaterHeaterMode::Id, chip::to_underlying(Feature::kOnOff)); + gWaterHeaterModeInstance = new ModeBase::Instance(gWaterHeaterModeDelegate, endpointId, WaterHeaterMode::Id, 0); gWaterHeaterModeInstance->Init(); } diff --git a/examples/energy-management-app/esp32/main/CMakeLists.txt b/examples/energy-management-app/esp32/main/CMakeLists.txt index eec8fadab62328..06623d3faf839d 100644 --- a/examples/energy-management-app/esp32/main/CMakeLists.txt +++ b/examples/energy-management-app/esp32/main/CMakeLists.txt @@ -59,7 +59,6 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/device-energy-management-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" From 2d926545254784ca00d9bdd8a8ce6af6835130b8 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Thu, 21 Nov 2024 06:37:19 +0000 Subject: [PATCH 23/23] TC_WHM_1_2: Use endpoint id passed as argument instead of hardcoded --- src/python_testing/TC_WHM_1_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_WHM_1_2.py b/src/python_testing/TC_WHM_1_2.py index a0a5918999f9bf..15f177e47b239a 100644 --- a/src/python_testing/TC_WHM_1_2.py +++ b/src/python_testing/TC_WHM_1_2.py @@ -71,7 +71,7 @@ def pics_TC_WHM_1_2(self) -> list[str]: @async_test_body async def test_TC_WHM_1_2(self): - endpoint = self.user_params.get("endpoint", 1) + endpoint = self.matter_test_config.endpoint attributes = Clusters.WaterHeaterMode.Attributes