Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions homeassistant/components/esphome/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from math import isfinite
from typing import Any, cast

from aioesphomeapi import (

Check failure on line 9 in homeassistant/components/esphome/climate.py

View workflow job for this annotation

GitHub Actions / Check pylint

E0611: No name 'ClimateTemperatureUnit' in module 'aioesphomeapi' (no-name-in-module)

Check failure on line 9 in homeassistant/components/esphome/climate.py

View workflow job for this annotation

GitHub Actions / Check mypy

Module "aioesphomeapi" has no attribute "ClimateTemperatureUnit" [attr-defined]
ClimateAction,
ClimateFanMode,
ClimateFeature,
Expand All @@ -15,6 +15,7 @@
ClimatePreset,
ClimateState,
ClimateSwingMode,
ClimateTemperatureUnit,
EntityInfo,
)

Expand Down Expand Up @@ -128,6 +129,12 @@
ClimatePreset.ACTIVITY: PRESET_ACTIVITY,
}
)
_CLIMATE_TEMPERATURE_UNIT_MAP: dict[ClimateTemperatureUnit, UnitOfTemperature] = {
ClimateTemperatureUnit.UNSET: UnitOfTemperature.CELSIUS,
ClimateTemperatureUnit.CELSIUS: UnitOfTemperature.CELSIUS,
ClimateTemperatureUnit.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT,
ClimateTemperatureUnit.KELVIN: UnitOfTemperature.KELVIN,
}


class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEntity):
Expand All @@ -145,6 +152,9 @@
self._feature_flags = ClimateFeature(
static_info.supported_feature_flags_compat(self._api_version)
)
self._attr_temperature_unit = _CLIMATE_TEMPERATURE_UNIT_MAP[
static_info.temperature_unit

Check failure on line 156 in homeassistant/components/esphome/climate.py

View workflow job for this annotation

GitHub Actions / Check mypy

"ClimateInfo" has no attribute "temperature_unit" [attr-defined]
]
self._attr_precision = self._get_precision()
self._attr_hvac_modes = [
_CLIMATE_MODES.from_esphome(mode) for mode in static_info.supported_modes
Expand Down
13 changes: 13 additions & 0 deletions homeassistant/components/esphome/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from functools import partial
from typing import Any

from aioesphomeapi import (

Check failure on line 8 in homeassistant/components/esphome/water_heater.py

View workflow job for this annotation

GitHub Actions / Check pylint

E0611: No name 'WaterHeaterTemperatureUnit' in module 'aioesphomeapi' (no-name-in-module)

Check failure on line 8 in homeassistant/components/esphome/water_heater.py

View workflow job for this annotation

GitHub Actions / Check mypy

Module "aioesphomeapi" has no attribute "WaterHeaterTemperatureUnit" [attr-defined]
EntityInfo,
WaterHeaterFeature,
WaterHeaterInfo,
WaterHeaterMode,
WaterHeaterState,
WaterHeaterTemperatureUnit,
)

from homeassistant.components.water_heater import (
Expand Down Expand Up @@ -44,6 +45,15 @@
}
)

_WATER_HEATER_TEMPERATURE_UNIT_MAP: dict[
WaterHeaterTemperatureUnit, UnitOfTemperature
] = {
WaterHeaterTemperatureUnit.UNSET: UnitOfTemperature.CELSIUS,
WaterHeaterTemperatureUnit.CELSIUS: UnitOfTemperature.CELSIUS,
WaterHeaterTemperatureUnit.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT,
WaterHeaterTemperatureUnit.KELVIN: UnitOfTemperature.KELVIN,
}


class EsphomeWaterHeater(
EsphomeEntity[WaterHeaterInfo, WaterHeaterState], WaterHeaterEntity
Expand All @@ -58,6 +68,9 @@
"""Set attrs from static info."""
super()._on_static_info_update(static_info)
static_info = self._static_info
self._attr_temperature_unit = _WATER_HEATER_TEMPERATURE_UNIT_MAP[
static_info.temperature_unit

Check failure on line 72 in homeassistant/components/esphome/water_heater.py

View workflow job for this annotation

GitHub Actions / Check mypy

"WaterHeaterInfo" has no attribute "temperature_unit" [attr-defined]
]
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
Comment on lines +71 to 76
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.
Expand Down
Loading