This is a feature on many new electric vehicles (such as the Kia EV 9). The obstacle is often the power company, which may require modifying your system to enable this.