Your heater may be wired incorrectly. It sounds like the solar system is also running during the night, (you can listen to the pump after the sun goes down). If this is happening, then the pump is sending your hot water up to the solar panels and during the night, they radiate the heat and cool the water down. The electric and solar systems are essentially separate, so there is no other reason for the water not to be hot if the heater has power going to the electrical circuits.