Sunlight generates electricity when it hits a photovoltaic cell. There is a “photoelectric” reaction in which light energy from the sun (photons) hits semi conducting materials that cause the photons to lose an electron. This creates a direct electric current (DC) which is converted by an inverter to an alternating current (AC) that can power your home.