I have been using https://mods.factorio.com/mod/electric-trains?from=updated for my trains and their battery design is works really well where you build the battery's on assemblers and then have a special building to charge them that seems to draw the power needed to charge them from electrical network correctly. You can also have the battery sort of decay if you want. Sadly their battery can only be used in trains and does not have a way to power the grid like yours but their cycle feels a little better in using electricity to charge the battery vs parts.