Tesla CEO Elon Musk is trying to steer his electric car company’s battery technology into homes and businesses as part of an elaborate plan to reshape the power grid with millions of small power plants made of solar panels on roofs and batteries in garages.