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

Code before:
            dhw_config is not None
            and dhw_config.reduced_setpoint is not None
            and dhw_config.reduced_setpoint.value is not None
        ):
            self._attr_min_temp = dhw_config.reduced_setpoint.value
        else:
            self._attr_min_temp = 10.0  # Default minimum

        # For max_temp: Use nominal_setpoint_max from config data (slow polling)
        if (
            dhw_config is not None
            and dhw_config.nominal_setpoint_max is not None
            and dhw_config.nominal_setpoint_max.value is not None
        ):
            self._attr_max_temp = dhw_config.nominal_setpoint_max.value
        else:
            self._attr_max_temp = 65.0  # Default maximum

    @property
    def current_operation(self) -> str | None:
        """Return current operation."""
        if (operating_mode := self.coordinator.data.dhw.operating_mode) is None:
            return None
        if operating_mode.value is None:
            return None
        return BSBLAN_TO_HA_OPERATION_MODE.get(operating_mode.value)

    @property
    def current_temperature(self) -> float | None:
        """Return the current temperature."""
        if (
            current_temp := self.coordinator.data.dhw.dhw_actual_value_top_temperature
        ) is None:
            return None
        return current_temp.value

    @property
    def target_temperature(self) -> float | None:
        """Return the temperature we try to reach."""
        if (target_temp := self.coordinator.data.dhw.nominal_setpoint) is None:
            return None
        return target_temp.value

    async def async_set_temperature(self, **kwargs: Any) -> None:
        """Set new target temperature."""
        temperature = kwargs.get(ATTR_TEMPERATURE)
        try:
            await self.coordinator.client.set_hot_water(
                SetHotWaterParam(nominal_setpoint=temperature)
            )
        except BSBLANError as err:

Review comment (suggestion):
```suggestion
      return BSBLAN_TO_HA_OPERATION_MODE.get(getattr(operating_mode, "value", None))
```

This will safe you pain in writing tests and still does the same trick. :)

Code after:
            dhw_config is not None
            and dhw_config.reduced_setpoint is not None
            and dhw_config.reduced_setpoint.value is not None
        ):
            self._attr_min_temp = dhw_config.reduced_setpoint.value
        else:
            self._attr_min_temp = 10.0  # Default minimum

        # For max_temp: Use nominal_setpoint_max from config data (slow polling)
        if (
            dhw_config is not None
            and dhw_config.nominal_setpoint_max is not None
            and dhw_config.nominal_setpoint_max.value is not None
        ):
            self._attr_max_temp = dhw_config.nominal_setpoint_max.value
        else:
            self._attr_max_temp = 65.0  # Default maximum

    @property
    def current_operation(self) -> str | None:
        """Return current operation."""
        if (
            operating_mode := self.coordinator.data.dhw.operating_mode
        ) is None or operating_mode.value is None:
            return None
        return BSBLAN_TO_HA_OPERATION_MODE.get(operating_mode.value)

    @property
    def current_temperature(self) -> float | None:
        """Return the current temperature."""
        if (
            current_temp := self.coordinator.data.dhw.dhw_actual_value_top_temperature
        ) is None:
            return None
        return current_temp.value

    @property
    def target_temperature(self) -> float | None:
        """Return the temperature we try to reach."""
        if (target_temp := self.coordinator.data.dhw.nominal_setpoint) is None:
            return None
        return target_temp.value

    async def async_set_temperature(self, **kwargs: Any) -> None:
        """Set new target temperature."""
        temperature = kwargs.get(ATTR_TEMPERATURE)
        try:
            await self.coordinator.client.set_hot_water(
                SetHotWaterParam(nominal_setpoint=temperature)
            )
        except BSBLANError as err: