if you wanna complex heating example (which may work for hot water as well), you can take a look here
and adjust what you need for your specific case.