Skip to content

fix(home): restore off state on home_undo after set_temperature (#455)#460

Merged
ai-hpc merged 3 commits into
GeniePod:mainfrom
kiannidev:fix/issue-455-home-undo-set-temperature-off
Jun 23, 2026
Merged

fix(home): restore off state on home_undo after set_temperature (#455)#460
ai-hpc merged 3 commits into
GeniePod:mainfrom
kiannidev:fix/issue-455-home-undo-set-temperature-off

Conversation

@kiannidev

Copy link
Copy Markdown
Contributor

Fixes #455

Summary

Mirror the set_brightness off-state handling in undo_restore_from_prior for set_temperature. When the HVAC was off before a setpoint change, home_undo now records turn_off as the restore action instead of leaving undo_restore empty (which skipped the thermostat change and reversed an unrelated earlier action).

Changes

  • undo_restore_from_prior("set_temperature"): prior state == "off"UndoRestore { action: "turn_off" }.
  • Unit test: off vs heating prior states.
  • Dispatch test: off thermostat → set_temperature(72)home_undoturn_off (climate back off).
  • Extend RecordingHomeProvider stub with climate domain for the integration test.

Real Behavior Proof

  • I have built and run the affected code locally (or noted why I could not).
  • I have verified the change end-to-end on Jetson hardware.
  • I have NOT verified on Jetson hardware, and I explain the equivalent verification path or validation gap below.

Tested profile / hardware (check all that apply):

  • jetson
  • raspberry_pi
  • portable_sbc
  • laptop
  • mac
  • CI-only / docs-only
  • Not run locally

What I ran

cd genie-claw
git checkout fix/issue-455-home-undo-set-temperature-off

cargo fmt
cargo test -p genie-core undo_restore_from_prior_set_temperature
cargo test -p genie-core home_undo_restores_off_state_after_set_temperature
cargo test -p genie-core home_undo
cargo clippy -p genie-core -- -D warnings

Environment: x86_64 Linux dev host (laptop profile). Stub provider test + unit tests; optional live HA repro below.

Optional live HA repro:

docker compose -f deploy/homeassistant/docker-compose.yml up -d
# Ensure climate entity is off with no active setpoint exposed
genie-ctl chat "set the thermostat to 72"
genie-ctl chat "undo the last home action"
# Expect: HVAC returns to off, not an unrelated earlier action

What I observed

Before (main):

  • undo_restore_from_prior("set_temperature", prior_off)None.
  • home_undo after heating an off thermostat could skip the temperature change.

After (this PR):

$ cargo test -p genie-core undo_restore_from_prior_set_temperature
test tools::actuation::tests::undo_restore_from_prior_set_temperature_when_off ... ok

$ cargo test -p genie-core home_undo_restores_off_state_after_set_temperature
test tools::dispatch::tests::home_undo_restores_off_state_after_set_temperature ... ok

$ cargo clippy -p genie-core -- -D warnings
(clean)
  • Off prior → undo issues turn_off; heating prior with temperature: 68 → undo restores set_temperature(68).

Repro caveat: Some HA climate entities expose temperature while state is off; this fix targets the state == "off" path aligned with #435 brightness handling.

Test plan

  • cargo test -p genie-core undo_restore_from_prior_set_temperature
  • cargo test -p genie-core home_undo_restores_off_state_after_set_temperature
  • cargo test -p genie-core home_undo
  • cargo clippy -p genie-core -- -D warnings
  • Live HA: off climate → set temp → undo → off (optional)

Notes for reviewers

When HVAC was off before a setpoint change, capture turn_off as undo_restore
(mirror set_brightness off handling). Fixes GeniePod#455.
@github-actions github-actions Bot added community-contribution bug Something isn't working labels Jun 22, 2026
ai-hpc added 2 commits June 22, 2026 19:19
The off->turn_off restore is fully covered by the actuation.rs unit test, and the home_control->ledger->home_undo round-trip is already exercised by GeniePod#435's home_undo_restores_prior_brightness_after_dim (exec_home_control_inner reads prior state identically for any setpoint action). Keeping the diff to the 6-line fix + its unit test and not growing the shared RecordingHomeProvider fixture.
@ai-hpc

ai-hpc commented Jun 23, 2026

Copy link
Copy Markdown
Member

@kiannidev — I trimmed this PR directly: dropped the dispatch.rs changes (the StubClimateState, the climate branches added to the shared RecordingHomeProvider, and the home_undo_restores_off_state_after_set_temperature end-to-end test), keeping your actuation.rs fix and its unit test. It's now the 6-line fix + the focused unit test — which is the whole correct change for #455.

Why I pulled it back: that end-to-end test was ~131 lines of new fixture for coverage we already have — the off→turn_off decision is proven by your unit test, and the home_control → ledger → home_undo round-trip is already exercised by #435's home_undo_restores_prior_brightness_after_dim (exec_home_control_inner reads prior state the same way for any setpoint action). Growing the shared RecordingHomeProvider to also simulate a thermostat couples new state into a fixture the other home tests depend on.

A note for future PRs, please: keep them tight and scoped — the smallest diff that fixes the issue with proof. Favor a focused unit test over a heavy end-to-end one when the logic is already unit-testable, and don't expand shared test fixtures unless several tests genuinely need it. It keeps review fast and the suite lean. This is the same over-scoping that got #457 closed, so worth internalizing.

The fix itself is correct — thanks for catching #455.

@ai-hpc ai-hpc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approve ✅ — with the dispatch.rs noise dropped, this is now the minimal correct fix: undo_restore_from_prior("set_temperature") returns turn_off when the prior state was off (mirroring the set_brightness arm), covered by the focused undo_restore_from_prior_set_temperature_when_off unit test. Verified locally — the unit test passes; the end-to-end ledger/undo path is already covered by #435. Closes #455.

@ai-hpc ai-hpc merged commit 4dd13ea into GeniePod:main Jun 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working community-contribution

Projects

None yet

2 participants