Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion homeassistant/components/esphome/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from homeassistant.core import callback
from homeassistant.exceptions import ServiceValidationError

from .const import DOMAIN
from .const import DOMAIN, TEMPERATURE_UNIT_MAP
from .entity import (
EsphomeEntity,
convert_api_error_ha_error,
Expand Down Expand Up @@ -145,6 +145,7 @@
self._feature_flags = ClimateFeature(
static_info.supported_feature_flags_compat(self._api_version)
)
self._attr_temperature_unit = TEMPERATURE_UNIT_MAP[static_info.temperature_unit]

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

View workflow job for this annotation

GitHub Actions / Check mypy

Invalid index type "TemperatureUnit | None" for "dict[TemperatureUnit, UnitOfTemperature]"; expected type "TemperatureUnit" [index]
Copy link

Copilot AI Apr 22, 2026

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_unit in ClimateInfo (e.g., Fahrenheit) and asserts the entity reports the correct temperature unit and that service calls pass the raw temperature values without unintended conversion.

Copilot uses AI. Check for mistakes.
self._attr_precision = self._get_precision()
self._attr_hvac_modes = [
_CLIMATE_MODES.from_esphome(mode) for mode in static_info.supported_modes
Expand Down
9 changes: 9 additions & 0 deletions homeassistant/components/esphome/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

from typing import Final

from aioesphomeapi import TemperatureUnit
from awesomeversion import AwesomeVersion

from homeassistant.const import UnitOfTemperature

DOMAIN = "esphome"

CONF_ALLOW_SERVICE_CALLS = "allow_service_calls"
Expand All @@ -30,3 +33,9 @@

WAKE_WORDS_DIR_NAME = "custom_wake_words"
WAKE_WORDS_API_PATH = "/api/esphome/wake_words"

TEMPERATURE_UNIT_MAP: dict[TemperatureUnit, UnitOfTemperature] = {
TemperatureUnit.CELSIUS: UnitOfTemperature.CELSIUS,
TemperatureUnit.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT,
TemperatureUnit.KELVIN: UnitOfTemperature.KELVIN,
}
2 changes: 2 additions & 0 deletions homeassistant/components/esphome/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature
from homeassistant.core import callback

from .const import TEMPERATURE_UNIT_MAP
from .entity import (
EsphomeEntity,
convert_api_error_ha_error,
Expand Down Expand Up @@ -59,6 +60,7 @@
"""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]

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

View workflow job for this annotation

GitHub Actions / Check mypy

Invalid index type "TemperatureUnit | None" for "dict[TemperatureUnit, UnitOfTemperature]"; expected type "TemperatureUnit" [index]
Copy link

Copilot AI Apr 22, 2026

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_unit in WaterHeaterInfo (e.g., Fahrenheit) and asserts the entity exposes the correct temperature unit and that async_set_temperature forwards the intended value in that unit.

Copilot uses AI. Check for mistakes.
Comment thread
jhenkens marked this conversation as resolved.
Outdated
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
Expand Down
Loading