[web_server] Fix water_heater JSON key names and move traits to DETAIL_ALL#14064
[web_server] Fix water_heater JSON key names and move traits to DETAIL_ALL#14064
Conversation
Move min/max temperature and step traits into DETAIL_ALL block so they are only sent once on initial connection instead of on every state update. Rename keys from min_temperature/max_temperature to min_temp/max_temp to match what the frontend expects. Discovered while reviewing #14061.
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#14064
components: [web_server]
refresh: 1h(Added by the PR bot) |
Memory Impact AnalysisComponents:
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #14064 +/- ##
=======================================
Coverage 74.11% 74.11%
=======================================
Files 55 55
Lines 11588 11589 +1
Branches 1577 1578 +1
=======================================
+ Hits 8588 8589 +1
Misses 2598 2598
Partials 402 402 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes two bugs in the water_heater web server JSON implementation. First, it corrects the JSON key names from min_temperature/max_temperature to min_temp/max_temp to match what the frontend expects (consistent with the climate entity pattern). Second, it moves these static traits into the DETAIL_ALL block so they're only sent during initial connection rather than with every state update, which reduces unnecessary data transfer since the frontend merges updates using Object.assign() and traits persist automatically.
Changes:
- Fixed JSON key names for water_heater min/max temperature to match frontend expectations
- Moved static traits (min_temp, max_temp, step) to DETAIL_ALL block to avoid sending them on every state update
|
thanks |
What does this implement/fix?
Fixes two issues with the water_heater web server JSON, discovered while reviewing #14061:
Wrong JSON key names: The backend sent
min_temperature/max_temperaturebut the frontend expectsmin_temp/max_temp, so slider range limits never worked for water_heater entities.Static traits sent on every state update:
min_temp,max_temp, andstepare static traits that never change at runtime. They were being included in everyDETAIL_STATESSE event instead of only in the initialDETAIL_ALLevent. The frontend usesObject.assign()to merge SSE updates, so traits from the initial connection persist automatically. Other entity types (number, select, light) already correctly gate their traits behindDETAIL_ALL.Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).Existing web_server component tests pass on all 4 platforms (esp32-ard, esp32-idf, esp8266-ard, rp2040-ard).