Skip to content

fix(sensor): 🐛 correct double /10 scaling on energy input sensors#667

Merged
rhammen merged 1 commit into
mainfrom
fix/energy-input-double-scaling
Jul 4, 2026
Merged

fix(sensor): 🐛 correct double /10 scaling on energy input sensors#667
rhammen merged 1 commit into
mainfrom
fix/energy-input-double-scaling

Conversation

@rhammen

@rhammen rhammen commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

🐞 Problem

HEAT_ENERGY_INPUT, DHW_ENERGY_INPUT and COOLING_ENERGY_INPUT started reporting values 10x too low (e.g. 2699.38 kWh269.94 kWh), triggering "new cycle" resets in the recorder for total_increasing energy sensors.

🔍 Root cause

461875c registered parameters 1136/1137/1139 with the luxtronik library's Energy datatype, whose from_heatpump() already divides the raw register value by 10. The matching sensor descriptions still carried factor=0.01 — originally calibrated for the old Unknown (raw passthrough) datatype these parameters used before that commit. Combining Energy's /10 with the sensor's factor=0.01 (/100) gave a net /1000 instead of the intended /100, an extra 10x division.

🔧 Fix

  • Change factor from 0.01 to 0.1 on the three affected sensor descriptions in sensor_entities_predefined.py, restoring the previously-correct scaling while keeping the more semantically correct Energy datatype.
  • Correct the stale comment in lux_overrides.py that stated the wrong factor.
  • Add TestEnergyInputScaling, which runs a raw register value through the real Energy datatype and the real production sensor description end-to-end, so a regression in either the datatype or the description factor is caught. Verified these tests fail (reproducing the reported 10x-low values) against the previous factor=0.01.

🧪 Testing

  • pytest -q — 744 passed
  • ruff check / ruff format --check — clean
  • basedpyright — 0 errors

✅ Test plan

  • Confirm sensor.luxtronik2_heat_energy_input, ..._dhw_energy_input, ..._cooling_energy_input report values consistent with pre-461875c readings after upgrading
  • Confirm no further "new cycle" resets appear in the recorder for these sensors

🤖 Generated with Claude Code

- change factor from 0.01 to 0.1 on HEAT_ENERGY_INPUT, DHW_ENERGY_INPUT
  and COOLING_ENERGY_INPUT sensor descriptions
- 461875c registered parameters 1136/1137/1139 with the library's
  Energy datatype, whose from_heatpump() already divides the raw value
  by 10; the sensor factor of 0.01 applied an extra /100 on top instead
  of the intended additional /10, producing values 10x too low
  (e.g. 2699.38 kWh reporting as 269.94 kWh)
- correct the matching comment in lux_overrides.py, which stated the
  wrong factor
- add TestEnergyInputScaling, which drives a raw register value through
  the real Energy datatype and the real sensor description to catch
  regressions in this scaling chain

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
custom_components.luxtronik2 100%
Summary 100% (2880 / 2880)

@rhammen rhammen merged commit 8ea9a30 into main Jul 4, 2026
9 checks passed
@rhammen rhammen deleted the fix/energy-input-double-scaling branch July 4, 2026 16:18
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