Strictly speaking, that relationship only works for a particle in free space without any sources of potential energy. In this specific case, you can do a pretty good job by assigning that component to the kinetic energy of the electron, and then adding in the (negative) potential energy, which is smaller for wider orbits.
If you want to do things correctly, though, you need to be solving the full time-independent Schrödinger equation, which tells you among other things that, in the presence of a potential, the wavelength changes from point to point, so things are a bit more complicated than in the naive calculation.