[pulse_counter] Fix build failure when use_pcnt is false#14111
Merged
swoboda1337 merged 1 commit intoesphome:devfrom Feb 19, 2026
Merged
[pulse_counter] Fix build failure when use_pcnt is false#14111swoboda1337 merged 1 commit intoesphome:devfrom
swoboda1337 merged 1 commit intoesphome:devfrom
Conversation
Contributor
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#14111
components: [pulse_counter]
refresh: 1h(Added by the PR bot) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #14111 +/- ##
==========================================
- Coverage 74.11% 74.08% -0.03%
==========================================
Files 55 55
Lines 11590 11590
Branches 1578 1578
==========================================
- Hits 8590 8587 -3
- Misses 2598 2600 +2
- Partials 402 403 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an ESP32 ESP-IDF build failure in pulse_counter when use_pcnt: false by preventing an unconditional include of the PCNT driver header when that header isn’t available in the build.
Changes:
- Gate inclusion of
<driver/pulse_cnt.h>behind__has_include(...)soHAS_PCNTis only defined when the header is actually present. - Ensure the software pulse counting storage path is used when the PCNT driver isn’t available.
Member
|
Maybe an esp32 test with |
66296b8 to
1cb0954
Compare
The pulse_counter header unconditionally includes <driver/pulse_cnt.h> when SOC_PCNT_SUPPORTED is defined by the hardware capabilities. But when use_pcnt: false, the esp_driver_pcnt IDF component is not included in the build (it's excluded by default), so the header is missing. Add a __has_include guard so the header is only included when the PCNT driver is actually available. This makes HAS_PCNT correctly undefined when use_pcnt: false, falling back to BasicPulseCounterStorage. Fixes esphome#14110 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1cb0954 to
d0468d6
Compare
bdraco
approved these changes
Feb 19, 2026
Member
Author
Was already adding it :) |
Member
Author
|
Thanks |
swoboda1337
added a commit
that referenced
this pull request
Feb 20, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What does this implement/fix?
Fix a compilation error when using
pulse_counterwithuse_pcnt: falseon ESP32 with ESP-IDF framework:Root cause: The header
pulse_counter_sensor.hunconditionally includes<driver/pulse_cnt.h>wheneverSOC_PCNT_SUPPORTEDis defined (a hardware capability check fromsoc/soc_caps.h). But whenuse_pcnt: false, the Python codegen doesn't callinclude_builtin_idf_component("esp_driver_pcnt"), and this IDF component is excluded by default — so the header file doesn't exist in the build.Fix: Add a
__has_include(<driver/pulse_cnt.h>)guard so the include only happens when the PCNT driver is actually available. When it's not,HAS_PCNTstays undefined andBasicPulseCounterStorage(software pulse counting) is used instead.This also fixes the same latent issue for
hlw8012, which includespulse_counter_sensor.h.Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: