Skip to content

Fix roller shutter calibration with unknown position - #168

Open
klew wants to merge 1 commit into
mainfrom
codex/fix-calibration-issue-in-rollershutter
Open

klew wants to merge 1 commit into
mainfrom
codex/fix-calibration-issue-in-rollershutter

Conversation

@klew

@klew klew commented May 17, 2026

Copy link
Copy Markdown
Member

Motivation

  • A refactor changed the default calibration state so a restored UNKNOWN_POSITION could be treated as calibrated when opening/closing times exist, causing absolute OPEN commands to compute movement against -1 and trigger the wrong motor direction.
  • The intent is to ensure a roller shutter restored with unknown position is considered not calibrated so commands that rely on a known position behave safely.

Description

  • Update RollerShutterInterface::isCalibrated() to return false when getCalibrate() is set or getCurrentPosition() == UNKNOWN_POSITION, and only consider time-based calibration when a known position exists; the change is in src/supla/control/roller_shutter_interface.cpp.
  • Add a regression unit test loadedUnknownPositionIsNotCalibrated to extras/test/RollerShutterTests/roller_shutter_tests.cpp that restores a state with UNKNOWN_POSITION and asserts the device remains uncalibrated and an absolute open target starts opening (checks getCurrentDirection() is UP_DIR).
  • Keep behavior for time-setting vs position-based channels consistent by guarding calibration checks with the unknown-position condition.

Testing

  • Ran git diff --check which reported no issues.
  • Attempted to run the test build via cmake -S extras/test -B /tmp/supla-device-test-build but it failed during FetchContent cloning of https://github.com/nlohmann/json.git (CONNECT tunnel HTTP 403), so the test binary could not be built in this environment.
  • Added the unit test as coverage for the regression; it will run in CI or a developer environment where FetchContent dependencies can be retrieved.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99f14b517b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +568 to +569
if (getCalibrate() || getCurrentPosition() == UNKNOWN_POSITION) {
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle partial targets safely when position is unknown

By forcing isCalibrated() to return false whenever getCurrentPosition()==UNKNOWN_POSITION, restored devices now enter the uncalibrated path in RollerShutter::onTimer; in that path, targets other than fully open/closed (0/100) leave newDirection as STOP but still fall through to startOpening() when currently stopped. This means a valid absolute command like 50% after reboot with unknown position will now always open, which contradicts the existing non-calibrated logic comment and can move in the wrong direction for close-oriented targets.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant