We look inside a simple, mechanical float switch. I have used these on solar powered systems to pump water up to tanks.
https://www.youtube.com/watch?v=lN2MO99D-Ms
WARNING: Working with electricity always carries the risk of shock, electrocution, burns and fire. If you don't know, learn first or do not do it.