Fix: Swap sensor IDs in COP calculation due to mislabeled sensors#20
Draft
Copilot wants to merge 4 commits into
Draft
Fix: Swap sensor IDs in COP calculation due to mislabeled sensors#20Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
The sensors were being used in reverse - the sensor labeled as "electrical" was actually measuring thermal energy output, and vice versa. This caused: - Energy consumption bars to show incorrectly high values (showing thermal as electrical) - COP calculations to be inverted (showing < 1 instead of 3-5) The fix swaps which sensor ID is used for electrical vs thermal calculations in useOptimizedCOPData hook. Co-authored-by: intui <15924901+intui@users.noreply.github.com>
Previous commit had the variable names reordered which canceled out the swap. This commit properly swaps which sensor ID is used for which calculation: - thermalSensorId data is now used for electricalEnergy calculation - electricalSensorId data is now used for thermalEnergy calculation This fixes the issue where electrical bars were showing as much higher than thermal bars (should be opposite for a heat pump with COP > 1). Co-authored-by: intui <15924901+intui@users.noreply.github.com>
Co-authored-by: intui <15924901+intui@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix calculation error in COP computation
Fix: Swap sensor IDs in COP calculation due to mislabeled sensors
Oct 8, 2025
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
The Heat Pump dashboard was displaying incorrect energy consumption values with electrical energy showing as much higher than thermal energy, when the opposite should be true for a heat pump with a COP (Coefficient of Performance) of 3-5.
As shown in the issue screenshot, the blue bars (Electrical Energy) were significantly taller than the orange bars (Thermal Energy), which is physically incorrect for a heat pump system where thermal output should be 3-5 times the electrical input.
Root Cause
The sensors passed to the
useOptimizedCOPDatahook had their roles reversed in the actual hardware/database configuration:electricalSensorIdwas actually measuring thermal output (heat produced by the heat pump)thermalSensorIdwas actually measuring electrical input (power consumed by the heat pump)This mismatch between the semantic sensor names and their actual measurements caused:
Solution
Modified
frontend/src/pages/HeatPump/hooks/useOptimizedCOPData.tsxto swap which sensor ID is used for which calculation:This corrects the data flow so that:
Expected Results
After this fix:
Files Changed
frontend/src/pages/HeatPump/hooks/useOptimizedCOPData.tsx- Swapped sensor ID usage in GraphQL queries (10 lines)docs/bugfix-cop-calculation.md- Added comprehensive documentation of the bug and fixFixes issue showing incorrectly high energy consumption in COP calculation.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.