Android already does that, no AI required. Some fairly simple math is enough.
The device first charges to 80% and holds there. It also calculates how long it will need to charge from there to full and when it will need to resume charging so that it will hit 100% just before the next alarm goes off. Then it does that.
Copy of Outlook Final (2) (new)