-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add unit_of_measurement to climate and water_heater #168747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jhenkens
wants to merge
12
commits into
home-assistant:dev
Choose a base branch
from
jhenkens:add-temperature-unit-to-climate-and-water-heater
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d333329
Add unit_of_measurement to climate and water_heater
jhenkens 4c5d595
Move map to const
jhenkens c52b56e
Merge branch 'dev' into add-temperature-unit-to-climate-and-water-heater
bdraco 32d39b4
Add basic tests
jhenkens 362921b
Not sure how prek missed this one line
jhenkens 20491e3
Add dictionary .get fallback
jhenkens d530d0b
Remove None from const
jhenkens 9acdea7
Make lookups safer
jhenkens 95b24f1
Merge branch 'dev' into add-temperature-unit-to-climate-and-water-heater
jhenkens 54d066b
Merge remote-tracking branch 'upstream/dev' into add-temperature-unit…
jhenkens d098f2c
Merge remote-tracking branch 'origin/add-temperature-unit-to-climate-…
jhenkens 28e6032
Make copilot happy with new comments
jhenkens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,10 @@ | |
| WaterHeaterEntity, | ||
| WaterHeaterEntityFeature, | ||
| ) | ||
| from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature | ||
| from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS | ||
| from homeassistant.core import callback | ||
|
|
||
| from .const import TEMPERATURE_UNIT_MAP | ||
| from .entity import ( | ||
| EsphomeEntity, | ||
| convert_api_error_ha_error, | ||
|
|
@@ -51,14 +52,14 @@ class EsphomeWaterHeater( | |
| ): | ||
| """A water heater implementation for ESPHome.""" | ||
|
|
||
| _attr_temperature_unit = UnitOfTemperature.CELSIUS | ||
| _attr_precision = PRECISION_TENTHS | ||
|
|
||
| @callback | ||
| def _on_static_info_update(self, static_info: EntityInfo) -> None: | ||
| """Set attrs from static info.""" | ||
| super()._on_static_info_update(static_info) | ||
| static_info = self._static_info | ||
| self._attr_temperature_unit = 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 | ||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test coverage that sets
temperature_unitinClimateInfo(e.g., Fahrenheit) and asserts the entity reports the correct temperature unit and that service calls pass the raw temperature values without unintended conversion.