[actuator] Add TimeBasedActuatorBase, migrate TimeBasedCover (cover/valve refactor 3/5)#5
Closed
exciton wants to merge 20 commits into
Closed
[actuator] Add TimeBasedActuatorBase, migrate TimeBasedCover (cover/valve refactor 3/5)#5exciton wants to merge 20 commits into
exciton wants to merge 20 commits into
Conversation
- Phase 8: Add unit tests for TimeBasedActuatorBase (test_time_based_actuator.py) - Phase 9: Fully implement TimeBasedActuatorBase in time_based_actuator.cpp, porting logic from TimeBasedCover using IActuator* interface; export TimeBasedActuatorBase from actuator/__init__.py; mark setup() inline empty - Phase 10: Replace TimeBasedCover with thin wrapper inheriting TimeBasedActuatorBase + Cover; constructor calls set_actuator(this); setup() calls restore_state_(); get_traits() reads assumed_state via get_assumed_state(); dump_config() unchanged; update __init__.py class declaration to reference TimeBasedActuatorBase https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
get_has_built_in_endstop() and get_last_operation() have no callers anywhere in the codebase; derived classes access the fields directly via this-> since they are protected. Confirmed no Python codegen references either. https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
This was referenced May 24, 2026
…latforms Introduces TIME_BASED_ACTUATOR_SCHEMA and apply_time_based_actuator_config in actuator/__init__.py, and moves CONF_HAS_BUILT_IN_ENDSTOP / CONF_MANUAL_CONTROL constants there. Simplifies time_based/cover/__init__.py from ~60 lines to ~20 lines.
… component - Move time_based_actuator.h/.cpp from actuator/ to time_based/ - Change namespace from esphome::actuator to esphome::time_based - Move TIME_BASED_ACTUATOR_SCHEMA, apply_time_based_actuator_config, CONF_HAS_BUILT_IN_ENDSTOP, CONF_MANUAL_CONTROL from actuator/__init__.py to time_based/__init__.py - Update time_based/cover/__init__.py to import from local package - Update time_based/cover/time_based_cover.h to include local header and use unqualified TimeBasedActuatorBase (same namespace) - Strip time-based helpers from actuator/__init__.py; actuator now only contains shared base infrastructure (ActuatorBase, ActuatorCallBase, IActuator, ActuatorOperation, build_apply_lambda_action) https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
IActuator::do_publish_state takes bool save with no default parameter; callers must be explicit. https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
Move cover/__init__.py → cover.py and cover/time_based_cover.{h,cpp} to
the time_based/ root, matching the flat layout used by the endstop component.
https://claude.ai/code/session_01Q3vPAvxZLoVtM7PRo6CdgE
Memory Impact AnalysisComponents:
📊 Component Memory Breakdown
🔍 Symbol-Level Changes (click to expand)Changed Symbols
New Symbols (top 15)
Removed Symbols (top 15)
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
…rface Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Matches the standard ESPHome component layout where each platform lives in its own subdirectory. Renames: cover.py -> cover/__init__.py time_based_cover.h -> cover/time_based_cover.h time_based_cover.cpp -> cover/time_based_cover.cpp Updates the relative include in time_based_cover.h to reach the parent-directory header, and the relative Python import in the moved __init__.py to reach the parent package (from . -> from ..). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After moving the cover platform into time_based/cover/, the parent time_based/ directory's shared source files (time_based_actuator.cpp/.h) were no longer being picked up by the build because the cover subpackage's resource scan is limited to its own directory. Adding AUTO_LOAD = ["time_based"] to the platform __init__.py registers the parent component so its resources flow into the build, fixing the missing-symbol link errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move restore-state logic from TimeBasedCover::setup() into TimeBasedActuatorBase::setup() via do_restore_state(), matching the endstop pattern so TimeBasedValve gets setup for free - Remove now-redundant TimeBasedCover::setup() - Expand unit tests to match the endstop suite (class groups, Component transitively reachable test, is-class-like-object check) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Cover/Valve Actuator Refactor — PR Series
Merge order: #3 → #4 and #5 (parallel) → #6 and #7 (parallel)
This PR: Step 3/5
What does this implement/fix?
Extracts the time-based cover logic into a new reusable
TimeBasedActuatorBasein theactuatorcomponent, then migratesTimeBasedCoverto use it. This enables thetime_based_valveplatform (step 5/5) to reuse the same logic without duplication.New
actuator::TimeBasedActuatorBase(Component):loop(),control(), position recompute, open/close/stop triggershas_built_in_endstop,manual_control, andassumed_stateconfigurationIActuator*pointer — works with any entity implementingIActuator(cover or valve)ComponentTimeBasedCovermigrated:TimeBasedActuatorBase + Cover(thin wrapper, constructor callsset_actuator(this))get_traits()usesget_assumed_state()from the basecontrol()bridges toTimeBasedActuatorBase::control()via safestatic_castTypes of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): N/A — no user-facing changes
Test Environment
Example entry for
config.yaml:No new YAML keys. Existing time_based cover configs continue to work unchanged.
Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed:
Generated by Claude Code