Skip to content

fix: detect movement by currentPosition delta, not stale "operation" field - #26

Open
nrocha22 wants to merge 1 commit into
jhurliman:mainfrom
nrocha22:fix/positionstate-delta-detection
Open

fix: detect movement by currentPosition delta, not stale "operation" field#26
nrocha22 wants to merge 1 commit into
jhurliman:mainfrom
nrocha22:fix/positionstate-delta-detection

Conversation

@nrocha22

Copy link
Copy Markdown

Closes #25.

The gateway's operation field reports the last command sent, not the current motion state. This caused two visible bugs:

  1. Home's individual blind detail showed "Opening…/Closing…" indefinitely after movement completed.
  2. Home's global/room tile showed a perpetual progress animation because the TargetPosition-sync code intended to fix this never fired (its precondition compared two values both derived from the broken operation field).

Changes

  • positionState() now compares currentPosition between the new and previous status. Delta ≠ 0 → movement (direction from sign). Delta = 0 → STOPPED. Honors config.invert.
  • The TargetPosition sync in updateAccessory() is simplified: always sync when the blind is detected as STOPPED. The HoldPosition write was redundant once the blind is already at rest and is removed.

Validation

Tested on 7 RollerBlind devices over ~30 minutes of normal use plus an automation run:

  • Detail view correctly shows progress animation during real movement, returns to clean state when stopped.
  • Global view tile now shows position % instead of perpetual progress.
  • Automations triggering open/close complete cleanly without leaving stale state.
  • 1149-packet capture confirming currentState=4 is invariant during movement is documented in the linked issue.

Behavior change

On the very first poll for a freshly-loaded accessory (no prior status), positionState() returns STOPPED instead of inferring from the stale operation field. More accurate and matches the "at rest until proven otherwise" assumption.

No regression on config.invert

Direction calculation preserved: (this.config.invert ? !increasing : increasing).

The gateway's operation field reports the last command sent, not the
current motion state. Using it for positionState() caused HomeKit to
show "Opening.../Closing..." indefinitely after movement completed.

The natural alternative currentState is unreliable: 1149 captured
packets during real movement all reported currentState=4.

Use delta of currentPosition between consecutive polls instead.
Also simplify the TargetPosition sync in updateAccessory: the previous
transition check (newState !== prevState && newState === STOPPED) never
fired because positionState() always returned the same value, leaving
Home's global tile stuck on a perpetual progress animation.

Closes jhurliman#25
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.

positionState() uses gateway "operation" field which is last-command, not motion state — causes perpetual "Opening.../Closing..." in Home

1 participant