I need help with my Automations please

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