fan_control: add FindClusterOnEndpoint wrapper - #1817
Open
dietolive-tw wants to merge 1 commit into
Open
Conversation
shubhamdp
approved these changes
Aug 14, 2026
Collaborator
|
@dietolive-tw could you please sign the CLA. |
The flow_measurement and relative_humidity_measurement integration.cpp files provide a namespace-level FindClusterOnEndpoint() wrapper so application code can access the codegen FanControl cluster instance and call methods like SetPercentCurrent() directly. fan_control was missing this wrapper. The upstream CodegenIntegration.h declares FindClusterOnEndpoint(), but the matching CodegenIntegration.cpp is excluded from the esp-matter build by CMakeLists.txt (EXCLUDE_SRCS_LIST for Codegen*.cpp). Without this wrapper in integration.cpp (the file actually compiled), app code that calls FindClusterOnEndpoint gets a link error. Add it following the flow_measurement pattern. Refs: pattern from clusters/flow_measurement/integration.cpp
dietolive-tw
force-pushed
the
add-fan-find-cluster
branch
from
August 14, 2026 12:03
761f33e to
60da870
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fan_control: add FindClusterOnEndpoint wrapper
The flow_measurement and relative_humidity_measurement integration.cpp files provide a namespace-level FindClusterOnEndpoint() wrapper so application code can access the codegen cluster instance and call methods like SetPercentCurrent() directly. fan_control was missing this wrapper.
The upstream CodegenIntegration.h declares FindClusterOnEndpoint(), but the matching CodegenIntegration.cpp is excluded from the esp-matter build by CMakeLists.txt (EXCLUDE_SRCS_LIST for Codegen*.cpp). Without this wrapper in integration.cpp (the file actually compiled), app code that calls FindClusterOnEndpoint gets a link error.
Add it following the flow_measurement pattern.
Refs: pattern from clusters/flow_measurement/integration.cpp
Description
fan_controlwas missing the namespace-levelFindClusterOnEndpoint()wrapper that
flow_measurementandrelative_humidity_measurementalready provide in their
integration.cppfiles.The upstream
CodegenIntegration.hdeclaresFindClusterOnEndpoint(),but the matching
CodegenIntegration.cppis excluded from the esp-matterbuild by
CMakeLists.txt(EXCLUDE_SRCS_LISTforCodegen*.cpp).Without this wrapper in
integration.cpp(the file actually compiled),application code that calls
FanControl::FindClusterOnEndpoint()getsa link error.
This matters for
FanControlspecifically because of thePercentCurrentattribute.FanControlCluster::ApplyFanModeSideEffects()(inconnectedhomeip)updates
mFanModeandmPercentSettingfor all modes but only updatesmPercentCurrentforkOff. For non-Off modes the spec leavesPercentCurrentto the application, which must callSetPercentCurrent()on the cluster instance — and that requiresFindClusterOnEndpoint().PercentCurrentis non-writable, so writing it viaesp_matter::attribute::update()desyncs the two stores: it writesthe esp-matter storage, but
ReadAttributereads from the codegenmPercentCurrent. The codegenSetPercentCurrent()is the onlycorrect path, and this wrapper is what makes it reachable from
application code.
Changes
components/esp_matter/data_model_provider/clusters/fan_control/integration.cppFindClusterOnEndpoint(EndpointId)(matchesflow_measurementpattern)Note:
fan_controlusesit->second.server.IsConstructed()/it->second.server.Cluster()(theservermember), whereas themeasurement clusters use
it->second.IsConstructed()/it->second.Cluster()directly. The wrapper matches the existing accesspattern already used by
SetDefaultDelegate()in the same file.Related
components/esp_matter/data_model_provider/clusters/flow_measurement/integration.cppcomponents/esp_matter/data_model_provider/clusters/relative_humidity_measurement/integration.cppcomponents/esp_matter/data_model_provider/CMakeLists.txt(EXCLUDE_SRCS_LISTforCodegen*.cpp)connectedhomeip/src/app/clusters/fan-control-server/FanControlCluster.cpp(ApplyFanModeSideEffects)Testing
flow_measurement/integration.cppandrelative_humidity_measurement/integration.cpp— no behavior change forapps that do not call the new wrapper.
it->second.server.*) matches the existingSetDefaultDelegate()in the same file, so the existinggServersmaplayout is respected.
calls
FanControl::SetPercentCurrent(); without this wrapper the linkstep fails with an undefined reference to
FindClusterOnEndpoint(EndpointId), with it the link succeeds and thePercentCurrentattribute reads back the value set via the codegen path(verified against Apple Home's fan speed UI).
Checklist
Before submitting a Pull Request, please ensure the following: