Rooftop solar photovoltaic generation provides the most direct and so cheapest energy, with sunlight converted directly into electricity at voltages and currents that our home and business appliances can use. A home battery involves additional steps into and out of energy storage, with the effect of holding the energy from the time it is captured from the sun to the time we want to use it (typically early evening),
Large scale solar photovoltaic or wind generation provide electricity generation direct from the sun or the sun's impact on the planet's atmosphere. These generation sources are connected to our homes and businesses through transmission and distribution systems - more steps that add losses. Again, batteries add energy storage - steps where losses are offset by the services provided to the system.
Hydro generation that converts some of the gravitational energy as water falls from high dams is a renewable environmental energy resource, but taps into the more complicated water cycle (evaporation and rain). Like wave power and geothermal power, these resources are more removed from direct sunlight, and therefore struggle more to compete with the economics of solar and wind even before tapping into the transmission and distribution system.
Hydrogen is not a fuel or a source of energy. Electrical energy can be stored as chemical energy in the bond between the two hydrogen atoms making up H2. So even with renewable electricity generation, hydrogen adds a number of steps to the physical supply chain.
The first is chemical composition of H2. Electrolysis provides a direct method of combining electricity and water to create hydrogen and oxygen gases.
As the lightest molecule, H2 at standard atmospheric pressure has a low density (and hence low energy density). So for storage and transportation H2 must be compressed and possibly cooled. A complication is H2. is highly corrosive, so the containers must be high quality as well as high pressure. So any H2 infrastructure distribution system will pretty much have to be built from scratch for uses that don't exist already.
These two steps must be reversed to get back to electrical energy for use by home and business appliances.
These additional steps are why hydrogen will not beat batteries as an electrical energy storage mechanism in any but the rarest new applications.
Just for completeness, fossil fuels come from the sun too.
They've just had millions of years since they were first converted to stored chemical energy by plant's photosynthesis, including being subject to extremely high subterranean pressures and temperatures to be reduced to the most basic chemical compounds of carbon.
We then had to dig them up from under the ground, transport them, process and refine them, before finally burning them and losing most of the energy in terms of lost heat.
We cheat a bit when we compare the cost of energy sources - even if we properly account for the costs of extraction and processing fossil fuels, we don't include the monetary value of the earth systems creating "black gold" out of trees and algae (even though we could).
But in a way it doesn't matter - fossil fuels don't compete economically because there are too many steps, and each step costs money.
Particularly compared to snatching the sun off your roof.