Skip to content

Fix thermostat min-temp regression and clarify setpoint names#1503

Merged
liudger merged 3 commits into
mainfrom
fix/thermostat-min-temp-regression
Jun 2, 2026
Merged

Fix thermostat min-temp regression and clarify setpoint names#1503
liudger merged 3 commits into
mainfrom
fix/thermostat-min-temp-regression

Conversation

@liudger
Copy link
Copy Markdown
Owner

@liudger liudger commented Jun 2, 2026

This pull request refactors the handling of static temperature setpoints and their mapping throughout the codebase, clarifying the distinction between reduced (eco/night), comfort, and protective setpoints. The changes update internal models, API mappings, and tests to use more precise attribute names and logic for determining temperature bounds, improving maintainability and correctness.

Refactoring of static temperature setpoint attributes:

  • Updated the StaticState model to add temp_reduced_setpoint and comfort_setpoint_max attributes, clarifying their meaning and use, while keeping min_temp and max_temp for legacy/PPS support.
  • Changed all API parameter mappings and fixtures to use temp_reduced_setpoint (was min_temp) and comfort_setpoint_max (was max_temp) for both circuits, ensuring consistent naming throughout. [1] [2] [3] [4] [5]

Temperature range calculation logic improvements:

  • Updated logic in _fetch_temperature_range to prefer heating_protective_setpoint as the lower bound and comfort_setpoint_max as the upper bound, falling back to min_temp/max_temp only for PPS circuits.

Test updates for new attribute names and logic:

  • Refactored tests to assert on temp_reduced_setpoint and comfort_setpoint_max instead of min_temp and max_temp, and updated expected values to reflect the new lower bound logic (e.g., using the protective setpoint as min). [1] [2] [3] [4] [5] [6]
  • Enhanced tests to cover cases where neither protective nor PPS min is available, ensuring correct behavior when temperature bounds are missing. [1] [2] [3]

User-facing output updates:

  • Updated print_static_state to display the new setpoint names and pull the temperature unit from the correct attribute. [1] [2]

liudger added 2 commits June 2, 2026 16:43
…bound

Param 712 (Room temp reduced setpoint, ~17 °C) was mapped to 'min_temp'
which Home Assistant uses as the climate slider minimum. The actual lower
bound is param 714 (frost-protection / heating protective setpoint, ~8 °C).

Changes:
- Rename '712' -> 'temp_reduced_setpoint' and '1012' -> 'temp_reduced_setpoint'
  in BASE_STATIC_VALUES_PARAMS / BASE_STATIC_VALUES_CIRCUIT2_PARAMS
- Add temp_reduced_setpoint field to StaticState; keep min_temp for PPS
  circuits that expose 15006 as their only lower bound
- _fetch_temperature_range: prefer heating_protective_setpoint (714/1014)
  as temp_range['min']; fall back to min_temp for PPS buses
- Update tests, fixtures, and control example
Param 716/1016 is the comfort setpoint maximum, not a generic max
temperature. Rename it to comfort_setpoint_max for clarity and source
the circuit max bound from it, falling back to max_temp for PPS
circuits (15007). PPS keeps min_temp/max_temp (15006/15007) unchanged.
Copilot AI review requested due to automatic review settings June 2, 2026 14:49
@liudger liudger added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Jun 2, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (309dbc4) to head (9f19ec4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1503   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files           6        6           
  Lines        1116     1120    +4     
  Branches      152      152           
=======================================
+ Hits         1115     1119    +4     
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors how static heating temperature setpoints are represented and mapped, introducing clearer names for reduced and comfort-max setpoints and updating temperature-range initialization to prefer protective/comfort bounds over legacy min/max fields.

Changes:

  • Renames static setpoint mappings: 712/1012 → temp_reduced_setpoint and 716/1016 → comfort_setpoint_max across config, fixtures, and tests.
  • Updates _fetch_temperature_range to use heating_protective_setpoint as the preferred lower bound and comfort_setpoint_max as the preferred upper bound, with PPS fallbacks.
  • Adjusts tests and example output to reflect the new attribute names and updated min-bound logic.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/bsblan/models.py Adds new StaticState fields for reduced and comfort-max setpoints.
src/bsblan/constants.py Updates parameter→attribute mappings for staticValues (both circuits).
src/bsblan/bsblan.py Refines temperature range derivation to prefer protective/comfort bounds.
examples/control.py Updates printed static-state labels/attributes to new setpoint names.
tests/test_constants.py Updates mapping assertions for renamed static setpoints.
tests/test_static_state.py Updates expectations to new StaticState attribute names.
tests/test_circuit.py Updates temperature-range initialization expectations (min now protective).
tests/test_temperature_validation.py Updates mocks/coverage for missing bound scenarios under new logic.
tests/test_include_parameter.py Updates include-based staticValues fetch to use new attribute name.
tests/test_utility_additional.py Updates APIValidator config fixture for renamed static values.
tests/fixtures/dict_version.json Updates fixture mapping keys for renamed static setpoints.
Comments suppressed due to low confidence (1)

tests/test_temperature_validation.py:162

  • This mock sets max_temp but does not set comfort_setpoint_max. Since the production code now prefers comfort_setpoint_max, an unconfigured AsyncMock may create a truthy comfort_setpoint_max attribute implicitly, causing the test to populate max with a Mock instead of falling back to max_temp. Explicitly set comfort_setpoint_max = None here to keep the test aligned with the new selection logic.
        static_values_mock.return_value.heating_protective_setpoint = None
        static_values_mock.return_value.min_temp = None
        static_values_mock.return_value.max_temp = AsyncMock()
        static_values_mock.return_value.max_temp.value = "30"
        monkeypatch.setattr(client, "static_values", static_values_mock)

Comment thread src/bsblan/models.py
Comment thread src/bsblan/bsblan.py
Comment thread src/bsblan/bsblan.py
Comment thread tests/test_temperature_validation.py
Comment thread examples/control.py Outdated
Comment thread examples/control.py
- Fix StaticState field comments (min_temp/max_temp are PPS-only;
  714/1014 and 716/1016 map to protective/comfort setpoints)
- Make temp-range source selection skip inactive values (value=None)
  so it falls back correctly when a setpoint returns '---'
- Pick example Temperature Unit from first available attribute
- Relabel example 'Max Temperature' to 'Comfort Setpoint Max'
- Set mock setpoint attrs explicitly for deterministic tests
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 2, 2026

@liudger liudger merged commit 26c9ddf into main Jun 2, 2026
16 checks passed
@liudger liudger deleted the fix/thermostat-min-temp-regression branch June 2, 2026 15:03
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants