Achieving energy resilience through smart storage of solar electricity at dwelling and community level