Skip to content

Add temperature unit for climate and water heater#168261

Closed
jhenkens wants to merge 1 commit intohome-assistant:devfrom
jhenkens:dev
Closed

Add temperature unit for climate and water heater#168261
jhenkens wants to merge 1 commit intohome-assistant:devfrom
jhenkens:dev

Conversation

@jhenkens
Copy link
Copy Markdown
Contributor

@jhenkens jhenkens commented Apr 15, 2026

Breaking change

Proposed change

Exposes temperature unit for climate and water_heater, with corresponding changes in home-assistant/core, aioesphome, esphome, and esphome-docs, to enable native Fahrenheit measurements on those entities. Usecase is to enable accurate temperature settings on a Fahrenheit hot tub, controlled via RS485-UART. Rather than round tripped from F -> C -> C, with various floating point errors and weirdnesses, this just makes it stay F the entire way and work much more reliably.

Tests still need to be added where appropriate - that's on the todo - but the code has been validated.

When esphome is updated, but core is not, as long as you do not set the temperature unit on a climate/water heater, everything works the same as it currently is. If you do set it, you will convert from F -> "F", as home assistant will think the incoming value from ESPHome is C, without reading the UOM. If ESPHome does not have F specified, it continues to default to C.

When HA is updated, but ESPHome is on an old version, it maintains legacy behavior of treating all climate/water_heaters as using C.

There are still some todo's, namely adding tests in every repo, and some other PR workitems, but the code is working and ready for early review.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

#168261
esphome/aioesphomeapi#1586
esphome/esphome#15740
esphome/esphome-docs#6463

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings April 15, 2026 01:14
@home-assistant home-assistant Bot added cla-signed integration: esphome new-feature small-pr PRs with less than 30 lines. Top 100 Integration is ranked within the top 100 by usage Top 200 Integration is ranked within the top 200 by usage Top 50 Integration is ranked within the top 50 by usage labels Apr 15, 2026
@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of esphome can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign esphome Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

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 updates the ESPHome integration’s Climate and Water Heater platforms to respect a temperature unit provided by ESPHome, enabling entities to operate natively in Fahrenheit (and other units) instead of assuming Celsius.

Changes:

  • Add a temperature-unit mapping for ESPHome climate entities and apply it during static info updates.
  • Add a temperature-unit mapping for ESPHome water heater entities and apply it during static info updates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
homeassistant/components/esphome/climate.py Map ESPHome-reported climate temperature unit to HA UnitOfTemperature and set _attr_temperature_unit.
homeassistant/components/esphome/water_heater.py Map ESPHome-reported water heater temperature unit to HA UnitOfTemperature and set _attr_temperature_unit.

Comment on lines +71 to 76
self._attr_temperature_unit = _WATER_HEATER_TEMPERATURE_UNIT_MAP[
static_info.temperature_unit
]
self._attr_min_temp = static_info.min_temperature
self._attr_max_temp = static_info.max_temperature
self._attr_target_temperature_step = static_info.target_temperature_step
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Derive precision from the reported temperature step/unit so Fahrenheit water heaters don’t get rounded and displayed at tenths by default. With _attr_temperature_unit now potentially set to Fahrenheit/Kelvin, keeping _attr_precision = PRECISION_TENTHS can cause values like 100 to be displayed as 100.0 and may not match the device’s supported increments; consider setting _attr_precision in _on_static_info_update based on static_info.target_temperature_step (e.g., whole/halves/tenths) or based on the mapped temperature unit.

Copilot uses AI. Check for mistakes.
@jhenkens
Copy link
Copy Markdown
Contributor Author

Closing in favor of #168747 due to branch name.

@jhenkens jhenkens closed this Apr 22, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed integration: esphome new-feature Quality Scale: platinum small-pr PRs with less than 30 lines. Top 50 Integration is ranked within the top 50 by usage Top 100 Integration is ranked within the top 100 by usage Top 200 Integration is ranked within the top 200 by usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants