Not the solution you’re asking for but I’ve used the ACC magisk module to do this on devices for years. If you’re willing to install magisk and then ignore it this is a very mature solution.
Otherwise, like others have said, run home assistant on your network somewhere and have tasker call to HA to switch the charger plug off when you hit your target charge level. That should be pretty straightforward.