This is a neat project that uses a scriptable (in lua) USB power meter / PD trigger to charge lithium batteries.