fix(sensor): 🐛 correct double /10 scaling on energy input sensors#667
Merged
Conversation
- 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>
Contributor
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.
🐞 Problem
HEAT_ENERGY_INPUT,DHW_ENERGY_INPUTandCOOLING_ENERGY_INPUTstarted reporting values 10x too low (e.g.2699.38 kWh→269.94 kWh), triggering "new cycle" resets in the recorder fortotal_increasingenergy sensors.🔍 Root cause
461875cregistered parameters 1136/1137/1139 with theluxtroniklibrary'sEnergydatatype, whosefrom_heatpump()already divides the raw register value by 10. The matching sensor descriptions still carriedfactor=0.01— originally calibrated for the oldUnknown(raw passthrough) datatype these parameters used before that commit. CombiningEnergy's/10with the sensor'sfactor=0.01(/100) gave a net/1000instead of the intended/100, an extra 10x division.🔧 Fix
factorfrom0.01to0.1on the three affected sensor descriptions insensor_entities_predefined.py, restoring the previously-correct scaling while keeping the more semantically correctEnergydatatype.lux_overrides.pythat stated the wrong factor.TestEnergyInputScaling, which runs a raw register value through the realEnergydatatype 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 previousfactor=0.01.🧪 Testing
pytest -q— 744 passedruff check/ruff format --check— cleanbasedpyright— 0 errors✅ Test plan
sensor.luxtronik2_heat_energy_input,..._dhw_energy_input,..._cooling_energy_inputreport values consistent with pre-461875creadings after upgrading🤖 Generated with Claude Code