Repository: home-assistant/core
File: homeassistant/components/esphome/water_heater.py (Python)

Code before:
                mode.ELECTRIC: "electric",
                mode.PERFORMANCE: "performance",
                mode.HIGH_DEMAND: "high_demand",
                mode.HEAT_PUMP: "heat_pump",
                mode.GAS: "gas",
            }
        )

    @property
    def supported_features(self) -> WaterHeaterEntityFeature:
        """Return the list of supported features."""
        features = WaterHeaterEntityFeature.TARGET_TEMPERATURE
        if self._static_info.supported_modes:
            features |= WaterHeaterEntityFeature.OPERATION_MODE
        return features

    @property
    def min_temp(self) -> float:
        """Return the minimum temperature."""
        return self._static_info.min_temperature

    @property
    def max_temp(self) -> float:
        """Return the maximum temperature."""
        return self._static_info.max_temperature

    @property
    def operation_list(self) -> list[str] | None:
        """Return the list of available operation modes."""
        if not self._static_info.supported_modes:
            return None
        return [
            self._mode_selector.from_esphome(mode)
            for mode in self._static_info.supported_modes
        ]

    @property
    @esphome_float_state_property
    def current_temperature(self) -> float | None:
        """Return the current temperature."""
        return self._state.current_temperature

    @property
    @esphome_float_state_property
    def target_temperature(self) -> float | None:
        """Return the temperature we try to reach."""
        return self._state.target_temperature

    @property
    @esphome_state_property
    def current_operation(self) -> str | None:

Review comment (suggestion):
this could be set as `_attr_` values like the other entities when we get the callback that the entity info has changed

Code after:
    @property
    @esphome_float_state_property
    def current_temperature(self) -> float | None:
        """Return the current temperature."""
        return self._state.current_temperature

    @property
    @esphome_float_state_property
    def target_temperature(self) -> float | None:
        """Return the temperature we try to reach."""
        return self._state.target_temperature

    @property
    @esphome_state_property
    def current_operation(self) -> str | None:
        """Return current operation mode."""
        return _WATER_HEATER_MODES.from_esphome(self._state.mode)

    @convert_api_error_ha_error
    async def async_set_temperature(self, **kwargs: Any) -> None:
        """Set new target temperature."""
        self._client.water_heater_command(
            key=self._key,
            target_temperature=kwargs[ATTR_TEMPERATURE],
            device_id=self._static_info.device_id,
        )

    @convert_api_error_ha_error
    async def async_set_operation_mode(self, operation_mode: str) -> None:
        """Set new operation mode."""
        self._client.water_heater_command(
            key=self._key,
            mode=_WATER_HEATER_MODES.from_hass(operation_mode),
            device_id=self._static_info.device_id,
        )


async_setup_entry = partial(
    platform_async_setup_entry,
    info_type=WaterHeaterInfo,
    entity_type=EsphomeWaterHeater,
    state_type=WaterHeaterState,
)