Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

energy-management-app: Split WH and EVSE into 2 endpoints #36201

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

soares-sergio
Copy link
Contributor

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"'
  1. 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"'
  1. 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

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`.
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
```
@soares-sergio soares-sergio requested review from a team as code owners October 22, 2024 20:04
Copy link

Review changes with SemanticDiff.

Comment on lines +28 to +31
constexpr EndpointId kEvseEndpoint = 1;
constexpr EndpointId kWaterHeaterEndpoint = 2;

EndpointId GetMainAppEndpointId();
Copy link
Contributor

@tcarmelveilleux tcarmelveilleux Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This likely don't belong in a file called examples/energy-management-app/energy-management-common/common/include/EnergyManagementAppCmdLineOptions.h when they don't relate to command line options. Suggest moving these elsewhere, or rename file to EnergyManagementAppConfig.*

Comment on lines +26 to +27
chip::app::Clusters::PowerTopology::PowerTopologyInstance * GetPTInstance();
chip::app::Clusters::ElectricalPowerMeasurement::ElectricalPowerMeasurementInstance * GetEPMInstance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are not widely used it would be good to leave inside the the place that inits everything and injects it down from the places that need it, rather than having to go through these global getters that init more globals in their guts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may even be worthwhile to introduce a class to hold this state.

Copy link

github-actions bot commented Oct 22, 2024

PR #36201: Size comparison from 0b93b0d to ea06d89

Full report (7 builds for cc32xx, qpg, stm32, tizen)
platform target config section 0b93b0d ea06d89 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617162 617162 0 0.0
RAM 205908 205908 0 0.0
lock CC3235SF_LAUNCHXL FLASH 657210 657210 0 0.0
RAM 206060 206060 0 0.0
qpg lighting-app qpg6105+debug FLASH 660600 660600 0 0.0
RAM 105396 105396 0 0.0
lock-app qpg6105+debug FLASH 618612 618612 0 0.0
RAM 99864 99864 0 0.0
stm32 light STM32WB5MM-DK FLASH 481936 481936 0 0.0
RAM 144844 144844 0 0.0
tizen all-clusters-app arm unknown 4912 4912 0 0.0
FLASH 1729756 1729756 0 0.0
RAM 90108 90108 0 0.0
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18237078 18237102 24 0.0
RAM 7945732 7945732 0 0.0

Copy link

github-actions bot commented Oct 22, 2024

PR #36201: Size comparison from 0b93b0d to f05afff

Full report (14 builds for cc13x4_26x4, cc32xx, nrfconnect, qpg, stm32, tizen)
platform target config section 0b93b0d f05afff change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 829564 829564 0 0.0
RAM 123452 123452 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 814872 814872 0 0.0
RAM 125332 125332 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 761460 761460 0 0.0
RAM 113824 113824 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 745704 745704 0 0.0
RAM 114016 114016 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617162 617162 0 0.0
RAM 205908 205908 0 0.0
lock CC3235SF_LAUNCHXL FLASH 657210 657210 0 0.0
RAM 206060 206060 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915528 915528 0 0.0
RAM 143357 143357 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 885992 885992 0 0.0
RAM 141496 141496 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 848936 848936 0 0.0
RAM 142265 142265 0 0.0
qpg lighting-app qpg6105+debug FLASH 660600 660600 0 0.0
RAM 105396 105396 0 0.0
lock-app qpg6105+debug FLASH 618612 618612 0 0.0
RAM 99864 99864 0 0.0
stm32 light STM32WB5MM-DK FLASH 481936 481936 0 0.0
RAM 144844 144844 0 0.0
tizen all-clusters-app arm unknown 4912 4912 0 0.0
FLASH 1729756 1729756 0 0.0
RAM 90108 90108 0 0.0
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18237078 18237102 24 0.0
RAM 7945732 7945732 0 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants