Skip to content

fix: keep Nuos operation mode cache in sync with mode getter - #181

Closed
dpmworld wants to merge 7 commits into
fustom:mainfrom
dpmworld:fix/nuos-operation-mode-cache-desync
Closed

dpmworld wants to merge 7 commits into
fustom:mainfrom
dpmworld:fix/nuos-operation-mode-cache-desync

Conversation

@dpmworld

@dpmworld dpmworld commented May 6, 2026

Copy link
Copy Markdown
Contributor

AristonNuosSplitDevice.set_water_heater_operation_mode (and its async counterpart) wrote the new operative mode into NuosSplitProperties.MODE (the generic Velis mode field), but water_heater_mode_value reads from NuosSplitProperties.OP_MODE (the Nuos-specific opMode field).

The Nuos cloud payload exposes both fields with distinct semantics: mode is the plant mode shared with other Velis devices, while opMode is the Nuos operative mode (GREEN / COMFORT / FAST / IMEMORY). The set_nuos_mode API call posts to /operativeMode, so the server only updates opMode. Mirroring mode in the local cache therefore had two unwanted effects:

  • water_heater_mode_value continued to return the stale opMode value until the next update_state() round-trip.
  • The unrelated mode field was clobbered with an opMode value, briefly corrupting any caller reading the plant mode from the cache before the next refresh.

This is the same class of bug that #180 fixes for the temperature setter; the operation mode setter just slipped through the same review.

`AristonNuosSplitDevice.set_water_heater_operation_mode` (and its
async counterpart) wrote the new operative mode into
`NuosSplitProperties.MODE` (the generic Velis `mode` field), but
`water_heater_mode_value` reads from `NuosSplitProperties.OP_MODE`
(the Nuos-specific `opMode` field).

The Nuos cloud payload exposes both fields with distinct semantics:
`mode` is the plant mode shared with other Velis devices, while
`opMode` is the Nuos operative mode (GREEN / COMFORT / FAST /
IMEMORY). The `set_nuos_mode` API call posts to `/operativeMode`, so
the server only updates `opMode`. Mirroring `mode` in the local cache
therefore had two unwanted effects:

* `water_heater_mode_value` continued to return the stale `opMode`
  value until the next `update_state()` round-trip.
* The unrelated `mode` field was clobbered with an `opMode` value,
  briefly corrupting any caller reading the plant mode from the cache
  before the next refresh.

This is the same class of bug that fustom#180 fixes for the temperature
setter; the operation mode setter just slipped through the same
review.
# `opMode`. The `water_heater_mode_value` getter also reads `opMode`,
# so the optimistic cache update has to mirror that field, not the
# generic `mode`.
self.data[NuosSplitProperties.OP_MODE] = NuosSplitOperativeMode[

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please update test_nuos_split_properties_sync_async_and_missing_state_defaults with this cache-key correction. Its fixture has no MODE entry, but the sync and async assertions still read device.data[NuosSplitProperties.MODE]; this change writes OP_MODE, so the existing test raises KeyError and does not verify the getter-backed field. Assert OP_MODE/water_heater_mode_value for both paths.

dpmworld and others added 3 commits November 13, 2026 10:08
Assert water_heater_mode_value reflects the requested mode right after the sync and async setters, and that the generic mode key is not written. Update the existing test to read opMode instead of mode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The GREEN_PLUS test merged from main still read the generic `mode` key.
The setter now writes `opMode`, which is what water_heater_mode_value reads.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dpmworld
dpmworld requested a review from astrinh0 November 13, 2026 11:00
@dpmworld

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Updated test_nuos_split_properties_sync_async_and_missing_state_defaults in caa739f: it now asserts OP_MODE and water_heater_mode_value for both the sync and async paths, and that the generic mode key is not written. I also merged the current main and fixed test_nuos_split_green_plus_mode_is_exposed_and_settable in 19d7273, which still read mode. I verified the assertions fail with the old behavior and pass with the fix. CI is green. Ready for another look.
Thank you very much for spending your time in reviewing the codebase.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dpmworld

Copy link
Copy Markdown
Contributor Author

Sry, should be fixed now.

@dpmworld

Copy link
Copy Markdown
Contributor Author

Superseded: upstream main already contains the OP_MODE cache fix, with GREEN via R2. Closing.

@dpmworld dpmworld closed this Nov 15, 2026
@dpmworld
dpmworld deleted the fix/nuos-operation-mode-cache-desync branch November 15, 2026 12:41
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.

2 participants