Fix optimistic fan state for consecutive AC setting updates - #118
Open
esolm wants to merge 2 commits into
Open
Conversation
Add Optimistic for fan_speed and fan_level
Implement fan_level and fan_speed correction
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Reviewer's GuideExtends optimistic state handling for Tado V3 AC controls so that fan_speed and fan_level use the latest user-requested values between consecutive commands, consistent with swing settings, by threading fan-related optimistic values through the action provider and optimistic manager. Sequence diagram for optimistic fan state across consecutive AC setting updatessequenceDiagram
actor User
participant ActionProvider
participant OptimisticManager
User->>ActionProvider: async_set_ac_setting(zone_id, fan_speed, AUTO)
ActionProvider->>OptimisticManager: apply_zone_state(zone_id, overlay=True, fan_speed=AUTO)
OptimisticManager->>OptimisticManager: set_optimistic(zone, zone_id, fan_speed)
User->>ActionProvider: async_set_ac_setting(zone_id, vertical_swing, HIGH)
ActionProvider->>OptimisticManager: get_optimistic(zone, zone_id, fan_speed)
OptimisticManager-->>ActionProvider: AUTO
ActionProvider->>ActionProvider: _build_ac_fan_settings(..., fan_speed=AUTO)
ActionProvider->>OptimisticManager: apply_zone_state(zone_id, overlay=True, vertical_swing=HIGH)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The nested ternary plus
get_optimistic(... ) or getattr(...)inside_build_ac_fan_settingsis a bit hard to read; consider splitting it into explicit conditional branches to make the fan speed selection logic clearer. - You've added optimistic tracking for
fan_levelinapply_zone_state, but onlyfan_speedis consulted in_build_ac_fan_settings; consider wiringfan_levelinto the command-building path as well so its optimistic state is actually used.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The nested ternary plus `get_optimistic(... ) or getattr(...)` inside `_build_ac_fan_settings` is a bit hard to read; consider splitting it into explicit conditional branches to make the fan speed selection logic clearer.
- You've added optimistic tracking for `fan_level` in `apply_zone_state`, but only `fan_speed` is consulted in `_build_ac_fan_settings`; consider wiring `fan_level` into the command-building path as well so its optimistic state is actually used.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
What does this PR do?
Fixes an issue where consecutive AC setting changes (e.g. changing fan speed and then vertical swing) could reuse a stale cached fan state before Home Assistant had received the updated state from Tado.
This PR extends the optimistic state handling to fan_speed and fan_level, making it consistent with the existing optimistic handling for swing settings. As a result, consecutive commands use the latest user-requested values instead of outdated cached values.
Related Issue
Fixes #
Type of Change
Affected Generation(s)
Testing
Tested on a real air conditioner:
Steps:
Repeated the test multiple times without reproducing the original issue.
Checklist
ruff,mypy,hassfest,HACS)