Claude
|
bcb3ab5dd8
|
[gpio_expander] Add interrupt pin support for efficient event-driven operation
This commit adds interrupt-based GPIO expander support to eliminate continuous
polling and significantly reduce I2C/SPI traffic and CPU usage.
## Key Changes
### Core Infrastructure (gpio_expander/cached_gpio.h)
- Extended CachedGpioExpander base class with interrupt pin support
- Added setup_interrupt_pin() method to attach native GPIO interrupt handlers
- Implemented interrupt-driven cache management:
- ISR sets flag and enables component loop when interrupt fires
- process_interrupt_() reads chip-specific interrupt status registers
- Cache remains valid between interrupts (no polling)
- Component loop automatically disabled until next interrupt
- Added virtual read_interrupt_status_() for chip-specific implementations
- Maintains backward compatibility: interrupt_pin is optional, defaults to polling
### MCP23xxx Family Support
- MCP23x17 (16-pin): Added INTF/INTCAP register reading
- MCP23x08 (8-pin): Added INTF/INTCAP register reading
- Configured IOCON register for interrupt mirroring (INTA=INTB)
- Combined with existing open_drain_ints support
- Chips: MCP23017, MCP23008, MCP23S17, MCP23S08
### PI4IOE5V6408 Support
- Implemented interrupt status register (0x13) reading
- Reads input state register (0x0F) to capture values and clear interrupt
- Single 8-pin bank design
### Python Configuration
- Added CONF_INTERRUPT_PIN to component schemas
- Uses pins.internal_gpio_input_pin_schema for validation
- Optional configuration maintains full backward compatibility
- Example:
```yaml
mcp23017:
id: my_expander
interrupt_pin: GPIO5 # Connect to INTA/INTB
binary_sensor:
- platform: gpio
pin:
mcp23xxx: my_expander
number: 0
interrupt: CHANGE # Existing config, now uses hardware interrupt
```
### Testing
- Updated component test configurations
- Added interrupt_pin test cases for both MCP23017 and PI4IOE5V6408
- Tests both polling mode (no interrupt_pin) and interrupt mode
## Benefits
| Aspect | Before (Polling) | After (Interrupts) |
|----------------|------------------|-------------------|
| I2C Reads | 60-120/sec | 2 per state change|
| CPU Usage | Continuous loop | ISR + event-driven|
| Latency | ~16ms (loop) | <1ms (ISR) |
| Power | Higher | Lower (sleep) |
## Implementation Details
**Interrupt Flow:**
1. Setup: Native GPIO interrupt attached to INTA/INTB pin (FALLING edge)
2. ISR: Sets pending flag, calls enable_loop_soon_any_context()
3. Loop: Reads interrupt status register to identify changed pins
4. Cache: Updates only changed pins, keeps cache valid
5. Optimization: Calls disable_loop() until next interrupt
**Safety:**
- Uses volatile bool for interrupt_pending_ flag
- IRAM_ATTR on ISR for fast execution
- Gracefully falls back to polling if interrupt_pin not configured
- No changes required to binary_sensor platform code
## Backward Compatibility
✅ Existing configurations work unchanged (polling mode)
✅ interrupt_pin is optional - add when ready
✅ No breaking changes to any APIs
✅ Binary sensors automatically benefit from interrupt efficiency
Addresses the need for efficient GPIO expander operation by eliminating
unnecessary continuous polling when hardware interrupts are available.
|
2025-11-17 21:45:47 +00:00 |
|
Jonathan Swoboda
|
3d6c361037
|
[core] Add support for setting environment variables (#11953)
|
2025-11-17 12:32:08 -05:00 |
|
Javier Peletier
|
9e1f8d83f8
|
[config] Support !remove and !extend with LVGL-style configs (#11534)
|
2025-11-17 18:03:11 +11:00 |
|
Jesse Hills
|
fa0aa6defc
|
Merge branch 'beta' into dev
|
2025-11-17 17:41:46 +13:00 |
|
Jesse Hills
|
70366d2124
|
Merge pull request #11944 from esphome/bump-2025.11.0b3
2025.11.0b3
2025.11.0b3
|
2025-11-17 17:41:11 +13:00 |
|
J. Nick Koston
|
10bdb47eae
|
[cover] Modernize to C++17 nested namespaces (#11935)
|
2025-11-16 20:37:06 -06:00 |
|
Jesse Hills
|
a38c4e0c6e
|
Bump version to 2025.11.0b3
|
2025-11-17 15:32:09 +13:00 |
|
Anton Sergunov
|
6c6b03bda0
|
[uart] Setup uart pins only if flags are set (#11914)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
9e02e31917
|
[web_server_idf] Fix lwIP assertion crash by shutting down sockets on connection close (#11937)
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
3fd58f1a91
|
[web_server.ota] Merge multiple instances to prevent undefined behavior (#11905)
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
9151489481
|
[sntp] Merge multiple instances to fix crash and undefined behavior (#11904)
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
f19296ac7f
|
[analyze-memory] Show all core symbols > 100 B instead of top 15 (#11909)
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
36868ee7b1
|
[scheduler] Fix timing breakage after 49 days of uptime on ESP8266/RP2040 (#11924)
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
d559f9f52e
|
[ld2410] Add timeout filter to prevent stuck targets (#11920)
|
2025-11-17 15:32:09 +13:00 |
|
J. Nick Koston
|
6440b5fbf5
|
[ld2412] Fix stuck targets by adding timeout filter (#11919)
|
2025-11-17 15:32:09 +13:00 |
|
Jonathan Swoboda
|
97c4914573
|
[uart] Improve error handling and validate buffer size (#11895)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
|
2025-11-17 15:32:09 +13:00 |
|
Edward Firmo
|
7ce94c27fe
|
[wifi] Allow use_psram with Arduino (#11902)
|
2025-11-17 15:32:09 +13:00 |
|
Edward Firmo
|
eb54c0026d
|
[light] Fix missing ColorMode::BRIGHTNESS case in logging (#11836)
|
2025-11-17 15:32:09 +13:00 |
|
Clyde Stubbs
|
fe00e209ff
|
[esp32] Add sdkconfig flag to make OTA work for 32MB flash (#11883)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
|
2025-11-17 15:32:08 +13:00 |
|
Clyde Stubbs
|
aed80732f9
|
[esp32] Make esp-idf default framework for P4 (#11884)
|
2025-11-17 15:32:08 +13:00 |
|
Anton Sergunov
|
aa097a2fe6
|
[uart] Setup uart pins only if flags are set (#11914)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
|
2025-11-17 14:25:00 +13:00 |
|
J. Nick Koston
|
3b860e784c
|
[web_server_idf] Fix lwIP assertion crash by shutting down sockets on connection close (#11937)
|
2025-11-17 13:39:01 +13:00 |
|
J. Nick Koston
|
96ee38759d
|
[web_server.ota] Merge multiple instances to prevent undefined behavior (#11905)
|
2025-11-17 13:38:52 +13:00 |
|
J. Nick Koston
|
986d3c8f13
|
[sntp] Merge multiple instances to fix crash and undefined behavior (#11904)
|
2025-11-17 13:38:38 +13:00 |
|
Clyde Stubbs
|
320120883c
|
[lvgl] Migrate lv_font creation into Font class and optimise (#11915)
|
2025-11-17 08:47:54 +11:00 |
|
J. Nick Koston
|
4fc4da6ed2
|
[analyze-memory] Show all core symbols > 100 B instead of top 15 (#11909)
|
2025-11-16 07:35:31 -06:00 |
|
J. Nick Koston
|
6f4042f401
|
Add tests for sensor timeout filters (#11923)
|
2025-11-15 22:21:38 -06:00 |
|
J. Nick Koston
|
ea2b4c3e25
|
[binary_sensor] Modernize to C++17 nested namespaces and remove redundant qualifications (#11929)
|
2025-11-16 04:21:06 +00:00 |
|
J. Nick Koston
|
fc546ca3f6
|
[scheduler] Fix timing breakage after 49 days of uptime on ESP8266/RP2040 (#11924)
|
2025-11-15 22:20:57 -06:00 |
|
J. Nick Koston
|
6b158e760d
|
[ld2410] Add timeout filter to prevent stuck targets (#11920)
|
2025-11-15 22:04:25 -06:00 |
|
J. Nick Koston
|
5710cab972
|
[ld2412] Fix stuck targets by adding timeout filter (#11919)
|
2025-11-15 22:03:43 -06:00 |
|
Clyde Stubbs
|
eb759efb3d
|
[font] Store glyph data in flash only (#11926)
|
2025-11-16 12:48:02 +11:00 |
|
dependabot[bot]
|
1df996601d
|
Bump ruff from 0.14.4 to 0.14.5 (#11910)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
|
2025-11-14 19:14:07 +00:00 |
|
dependabot[bot]
|
c32891ec02
|
Bump github/codeql-action from 4.31.2 to 4.31.3 (#11911)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
2025-11-14 13:09:59 -06:00 |
|
Jonathan Swoboda
|
2bf6d48fcf
|
[uart] Improve error handling and validate buffer size (#11895)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
|
2025-11-14 14:06:08 -05:00 |
|
Edward Firmo
|
e49a943cf7
|
[wifi] Allow use_psram with Arduino (#11902)
|
2025-11-14 09:13:48 -05:00 |
|
dependabot[bot]
|
67524e14ee
|
Bump pylint from 4.0.2 to 4.0.3 (#11894)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
2025-11-13 19:05:02 +00:00 |
|
Edward Firmo
|
2290eb0dd2
|
[light] Fix missing ColorMode::BRIGHTNESS case in logging (#11836)
|
2025-11-13 12:08:06 -06:00 |
|
Clyde Stubbs
|
0afcf67c32
|
[esp32] Add sdkconfig flag to make OTA work for 32MB flash (#11883)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
|
2025-11-13 10:52:08 -05:00 |
|
Clyde Stubbs
|
952bdfaac2
|
[esp32] Make esp-idf default framework for P4 (#11884)
|
2025-11-13 09:55:48 -05:00 |
|
Jesse Hills
|
ed7e5cd325
|
Bump version to 2025.12.0-dev
|
2025-11-13 17:00:47 +13:00 |
|
Jonathan Swoboda
|
a15f46e741
|
Merge branch 'beta' into dev
|
2025-11-12 22:46:34 -05:00 |
|
Jonathan Swoboda
|
050a27a409
|
Merge pull request #11880 from esphome/bump-2025.11.0b2
2025.11.0b2
2025.11.0b2
|
2025-11-12 22:46:23 -05:00 |
|
Jonathan Swoboda
|
382483b063
|
Bump version to 2025.11.0b2
|
2025-11-12 21:56:11 -05:00 |
|
J. Nick Koston
|
1675408161
|
[wifi] Fix slow reconnection after connection loss for all network types (#11873)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
2025-11-12 21:56:11 -05:00 |
|
J. Nick Koston
|
1d8b08dcce
|
[wifi][ethernet] Fix spurious warnings and unclear status after PR #9823 (#11871)
|
2025-11-12 21:56:11 -05:00 |
|
J. Nick Koston
|
afed581079
|
[light] Fix dangling reference in compute_color_mode causing memory corruption (#11868)
|
2025-11-12 21:56:11 -05:00 |
|
J. Nick Koston
|
ff107a0674
|
[mqtt] Fix crash with empty broker during upload/logs (#11866)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
2025-11-12 21:56:11 -05:00 |
|
J. Nick Koston
|
72da3d0f1e
|
[thermostat] Replace std::map with FixedVector, reduce flash usage (#11875)
|
2025-11-12 21:56:11 -05:00 |
|
J. Nick Koston
|
5a2e6697e0
|
[api][event] Send events immediately to prevent loss during rapid triggers (#11777)
|
2025-11-12 21:56:11 -05:00 |
|