Refining home battery charge levels from solar power forecast

I have a Solax inverter, PV panels and batteries. For a while now I’ve been using forecast solar to estimate tomorrow’s PV yield and using this to set a charge level for my batteries using cheap rate overnight grid power. I also have an EV so get very low cost power from Octopus energy between 11:30 and 5:00. I just have several crude automations to do this set ‘by hand’ like this:

This works well, but I would like to refine it by having min and max charge levels vs Solar forecast (based on historical data I now have) and interpolate everything in between. I ‘think’ this would just be linear? Problem is, I don’t know how to do this! Eg. 17kW solar tomorrow = 37% charge. I’m happy with the mechanics of setting the values, talking to the Solax API etc as I’m doing that now, it’s the calculation bit I’m lacking. Any ideas folks? Thanks in advance.