Skip to content

[valve] Add endstop_valve platform (cover/valve refactor 4/5)#6

Closed
exciton wants to merge 15 commits into
pr2/endstop-actuator-basefrom
pr4/endstop-valve
Closed

[valve] Add endstop_valve platform (cover/valve refactor 4/5)#6
exciton wants to merge 15 commits into
pr2/endstop-actuator-basefrom
pr4/endstop-valve

Conversation

@exciton

@exciton exciton commented May 24, 2026

Copy link
Copy Markdown
Owner

Cover/Valve Actuator Refactor — PR Series

Step PR Title Depends on
1/5 #3 [actuator] Add shared actuator base component
2/5 #4 [actuator] Add EndstopActuatorBase, migrate EndstopCover Step 1 (#3)
3/5 #5 [actuator] Add TimeBasedActuatorBase, migrate TimeBasedCover Step 1 (#3)
4/5 #6 [valve] Add endstop_valve platform Step 2 (#4)
5/5 #7 [valve] Add time_based_valve platform Step 3 (#5)

Merge order: #3#4 and #5 (parallel) → #6 and #7 (parallel)

This PR: Step 4/5


What does this implement/fix?

Adds a new endstop_valve platform for the valve component, providing the same endstop-based position control that endstop cover has, reusing EndstopActuatorBase from step 2/5 with no logic duplication.

New esphome/components/endstop_valve/:

  • EndstopValve inherits EndstopActuatorBase + Valve
  • Supports open/close endstop binary sensors, open/close/stop triggers, position tracking, and optional max duration
  • Full YAML schema mirroring the endstop cover platform
  • dump_config() logging

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

valve:
  - platform: endstop_valve
    name: "My Valve"
    open_action:
      - switch.turn_on: open_switch
    close_action:
      - switch.turn_on: close_switch
    stop_action:
      - switch.turn_off: open_switch
    open_endstop: open_binary_sensor
    close_endstop: close_binary_sensor
    open_duration: 25s
    close_duration: 23s

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:


Generated by Claude Code

claude added 3 commits May 24, 2026 19:14
Implements the endstop_valve component as a thin wrapper over
EndstopActuatorBase, mirroring endstop/cover exactly but for valves.
Adds config tests for esp32-idf, esp8266-ard, and rp2040-ard.

https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
Remove get_has_built_in_endstop() and get_last_operation() from
TimeBasedActuatorBase, and get_last_operation() from TimeBasedCover.
None have any callers in the codebase or in Python codegen.

https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
…onent

Replaces the inline schema and to_code body with the helpers introduced
in actuator/__init__.py, reducing valve.py from ~65 lines to ~22 lines.
@exciton exciton force-pushed the pr4/endstop-valve branch from 9631be7 to 4920132 Compare May 24, 2026 19:15
claude and others added 9 commits May 25, 2026 14:14
EndstopActuatorBase moved from actuator/ to endstop/ in PR2.
Update EndstopValve to include from endstop/ and inherit endstop::,
and update valve.py to import schema helpers from esphome.components.endstop.

https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
- Move endstop_valve.h/cpp into endstop/, namespace esphome::endstop
- Add endstop/valve.py (valve: platform: endstop)
- Merge endstop_valve tests into tests/components/endstop/common.yaml
- Delete esphome/components/endstop_valve/ and tests/components/endstop_valve/

https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
- Remove actuator/time_based_actuator.h/.cpp stubs (belong to PR3)
- Restore get_last_operation() in time_based/cover/time_based_cover.h
  (that removal belonged to PR3 as well)

https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown

Memory Impact Analysis

Components: endstop
Platform: esp8266-ard

Metric Target Branch This PR Change
RAM 29,064 bytes 29,328 bytes 📈 🔸 +264 bytes (+0.91%)
Flash 272,047 bytes 273,711 bytes 📈 🔸 +1,664 bytes (+0.61%)
📊 Component Memory Breakdown
Component Target Flash PR Flash Change
[esphome]valve 0 bytes 661 bytes 📈 🔸 +661 bytes (0.00%)
[esphome]core 8,070 bytes 8,420 bytes 📈 🚨 +350 bytes (+4.34%)
[esphome]endstop 1,825 bytes 2,172 bytes 📈 🚨 +347 bytes (+19.01%)
[esphome]template 761 bytes 816 bytes 📈 🚨 +55 bytes (+7.23%)
app_framework 1,406 bytes 1,446 bytes 📈 +40 bytes (+2.84%)
🔍 Symbol-Level Changes (click to expand)

Changed Symbols

Symbol Target Size PR Size Change
setup 742 bytes 1,074 bytes 📈 +332 bytes (+44.74%)
esphome::App 152 bytes 172 bytes 📈 +20 bytes (+13.16%)
esphome::COMP_SRC_TABLE 20 bytes 24 bytes 📈 +4 bytes (+20.00%)

New Symbols (top 15)

Symbol Size
esphome::valve::Valve::publish_state(bool) 283 bytes
esphome::valve::Valve::do_restore_state() 223 bytes
esphome::endstop::EndstopValve::dump_config() 192 bytes
endstop__endstop_valve_test__pstorage 104 bytes
vtable for esphome::endstop::EndstopValve 100 bytes
esphome::template_::TemplateBinarySensor::TemplateBinarySensor() 55 bytes
esphome::valve::ValveRestoreState::apply(esphome::valve::Valve*) 44 bytes
template__bin2__pstorage 44 bytes
vtable for esphome::valve::Valve 44 bytes
setup::{lambda()#2}::_FUN() 40 bytes
esphome::valve::Valve::Valve() 36 bytes
switch__switch__turnonaction_id_5__pstorage 16 bytes
switch__switch__turnonaction_id_4__pstorage 16 bytes
switch__switch__turnonaction_id_6__pstorage 16 bytes
non-virtual thunk to esphome::endstop::EndstopValve::get_traits() 15 bytes
14 more new symbols... Total: 1,325 bytes

Note: This analysis measures static RAM and Flash usage only (compile-time allocation).
Dynamic memory (heap) cannot be measured automatically.
⚠️ You must test this PR on a real device to measure free heap and ensure no runtime memory issues.

This analysis runs automatically when components change. Memory usage is measured from a representative test configuration.

exciton and others added 3 commits May 29, 2026 05:30
…tests

- Move endstop/valve.py → endstop/valve/__init__.py (matching cover/
  subpackage pattern from PR2)
- Move endstop/endstop_valve.h/.cpp → endstop/valve/ subdirectory
- Fix include path: "endstop_actuator.h" → "../endstop_actuator.h"
- Fix import: from . → from ..
- Add AUTO_LOAD = ["endstop"] (needed for subpackage source discovery)
- Add TestEndstopValveInheritance class to test_endstop_actuator.py
  (3 tests: inherits base, inherits Valve, Component reachable transitively)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@exciton exciton closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants