There is a blueprint for that. Wallpanel Battery Management - Blueprints Exchange - Home Assistant Community