Skip to content

arch(light,cover): default to native light transitions and extract bus-truthful cover kinematics strategies #730

Closed

Description

@GreenGrassBlueOcean

Architectural Assessment & Severity


Problem Statement

1. Software Fade Engine (custom_components/myhome/light_fade.py, light.py, const.py)

  • DEFAULT_TRANSITION_MODE is currently set to TRANSITION_MODE_SOFTWARE ("software_stepped") at custom_components/myhome/const.py:175 (and TRANSITION_MODE_AUTO also resolves to TRANSITION_MODE_SOFTWARE at custom_components/myhome/light.py:603-604).
  • Consequently, every light.turn_on(..., transition=T) call by default spawns a software loop sending up to 25 instant-brightness frames (*#1*WHERE*#1*level*0##) at 0.3s intervals (SOFTWARE_TRANSITION_STEP_INTERVAL = 0.3, light_fade.py:159-188) at Tier-0 command priority.
  • On a shared, low-bandwidth SCS bus, this floods the gateway during multi-light scenes or adaptive_lighting updates, fights actuators that natively support hardware transition speeds (*#1*WHERE*#1*level*speed##), can reorder steps when command_worker_count > 1 (light_fade.py:132-141), and requires an optimistic echo-suppression rule (abs(reported - current_opt) >= 10 at light.py:1100-1108) that ignores real bus state during active fades.

2. Virtual Travel-Time Covers (custom_components/myhome/cover.py, cover_motion.py, cover_calibration.py)


Proposed Solution (PR Scope)

Part A — Lights (const.py, light.py, light_fade.py)

  1. Default to Native Hardware Transitions:
    • Change DEFAULT_TRANSITION_MODE in custom_components/myhome/const.py:175 from TRANSITION_MODE_SOFTWARE to TRANSITION_MODE_NATIVE ("native").
    • Map TRANSITION_MODE_AUTO in custom_components/myhome/light.py:603-604 to TRANSITION_MODE_NATIVE.
  2. Demote & Isolate Opt-In Software Fades:
    • Keep TRANSITION_MODE_SOFTWARE strictly opt-in for legacy dimmers that ignore hardware speed parameters.
    • Enqueue intermediate software fade steps at a lower priority tier (_TIER_FADE_STEPS = 1, below interactive Tier-0 commands) so fades never delay wall-switch or cover STOP commands.
    • Remove the <10% optimistic echo suppression during native transitions, and immediately cancel an opt-in software fade if an external physical switch event arrives.

Part B — Covers (cover.py, cover_strategies/)

  1. Extract Pluggable CoverKinematicsStrategy Classes (custom_components/myhome/cover_strategies/):
  2. Slim MyHOMECover (cover.py):
    • Reduce MyHOMECover to a thin Home Assistant CoverEntity adapter (~350 lines) that delegates kinematics to self._strategy.

Verification Plan

  • Unit tests in tests/test_cover_strategies.py covering SimpleUpDownStopStrategy (uncalibrated default, no fake 50%), NativePositionStrategy, TimedCurtainStrategy, VenetianTiltStrategy, and ImpulseDoorStrategy.
  • Unit tests in tests/test_light.py verifying DEFAULT_TRANSITION_MODE == "native" sends a single native transition command instead of stepped frames.
  • Full WSL test suite (pytest tests -q --cov=custom_components/myhome), ruff check, and scripts/verify_ha_standards.py.

Activity

  1. GreenGrassBlueOcean commented on Oct 21, 2026

    @GreenGrassBlueOcean
    ContributorAuthor

    Resolved in PR #739 (10405032), PR #760 (8acea4f9), and PR #762 (43bdc070):

    • Extracted the pluggable CoverKinematicsStrategy hierarchy into custom_components/myhome/cover_strategies/ (SimpleUpDownStopStrategy, NativePositionStrategy, TimedCurtainStrategy, VenetianTiltStrategy, ImpulseDoorStrategy).
    • Defaulted light transitions to native hardware transitions and routed opt-in software fade steps through _TIER_FADE_STEPS = 1 on FrameScheduler.
    • Added strategy contract and full test suites (tests/test_cover_strategies.py, tests/test_cover_strategy_contract.py).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions