-
-
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
base: dev
Are you sure you want to change the base?
Changes from 6 commits
d333329
4c5d595
c52b56e
32d39b4
362921b
20491e3
d530d0b
9acdea7
95b24f1
54d066b
d098f2c
28e6032
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 @@ | |
| ): | ||
| """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.get(static_info.temperature_unit, UnitOfTemperature.CELSIUS) | ||
|
Check failure on line 62 in homeassistant/components/esphome/water_heater.py
|
||
|
||
| 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 | ||
|
|
||
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.