Skip to content

adjust external change tolerance#23

Closed
jianyu-li wants to merge 1 commit intomainfrom
fix/preset-fallback-jitter
Closed

adjust external change tolerance#23
jianyu-li wants to merge 1 commit intomainfrom
fix/preset-fallback-jitter

Conversation

@jianyu-li
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request increases the EXTERNAL_CHANGE_TOLERANCE and replaces the dynamic pending_request_tolerance with a fixed target_tolerance in the realignment logic. Review feedback highlights that the new tolerance of 0.55 is too high for Celsius thermostats with 0.5-degree increments, which could lead to manual changes being ignored. Furthermore, reverting from a dynamic tolerance to a hardcoded one may cause issues with high-precision hardware by incorrectly skipping necessary updates.

MAX_TRACKED_REAL_TARGET_REQUESTS = 5
PENDING_REQUEST_TIMEOUT = 30.0 # Seconds before a pending request expires
EXTERNAL_CHANGE_TOLERANCE = 0.2 # Degrees to ignore as noise/rounding for external detection
EXTERNAL_CHANGE_TOLERANCE = 0.55 # Degrees to ignore as noise/rounding for external detection
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Increasing EXTERNAL_CHANGE_TOLERANCE to 0.55 will cause manual adjustments of 0.5 degrees (common in Celsius thermostats) to be ignored by the proxy's external change detection. This means the proxy will not switch to the "Physical Entity" preset when a user manually adjusts the thermostat by a single step, and it will likely overwrite the user's change during the next realignment cycle. Consider using a value slightly smaller than the minimum expected step (e.g., 0.4) or making this tolerance dynamic based on the device's precision.


pending_tolerance = self._pending_request_tolerance()
if self._has_pending_real_target_request(desired_real_target, pending_tolerance):
if self._has_pending_real_target_request(desired_real_target, target_tolerance):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Replacing the dynamic pending_tolerance with a hardcoded target_tolerance (0.1) may lead to issues with high-precision thermostats (e.g., those with 0.01 or 0.05 precision). A 0.1 tolerance is too loose for such devices and could cause the proxy to incorrectly match different target temperatures as being the same, resulting in skipped updates. The previous use of self._pending_request_tolerance() (which scales as precision / 2) is more robust for varying hardware.

Suggested change
if self._has_pending_real_target_request(desired_real_target, target_tolerance):
pending_tolerance = self._pending_request_tolerance()
if self._has_pending_real_target_request(desired_real_target, pending_tolerance):

@jianyu-li jianyu-li closed this Apr 19, 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.

1 participant