How do I set battery charge min-max range to make it degrade with time less? As far as I know, LiIon batteries should be kept in about 40%-80% range in order to degrade more slowly.

On my laptop I use the following commands to make it change battery conditionally, only when it's lower than 45% and up to 90% instead of to 100%:

tpacpi-bat -v -s ST 1 45
tpacpi-bat -v -s SP 1 90


How do I do the same for Android? I can control the charger from software, so it should be definitely possible.

Device: Huawei Honor 6 (H60-L04)
I managed to do it for the same device cutting off charging at am upper level.
 How do I override charging current on Huawei Honor 6?
Surely something on those lines can be implemented for lower l level maybe a macro to shutdown the phone ( too drastic) or sound alarms and send text messages or mails if you are not close to the phone
Hope this helps