Stop charging as root

I’d like to use Tasker to stop my phone from charging (I have root access). However I can’t get it to work. I’ve tried echo 0 > /sys/class/power_supply/battery_charging_enabled which changes the value but has no other effect and echo 0 > /sys/class/power_supply/usb/online which does not change the value (I do have permission to write). Does anyone here have another idea?

P.S. Please don’t tell me that charging my battery fully doesn’t affect its lifetime (as this seems to happen under most post I found regarding this topic).

Have you tried If that one works, you can take a look at the code if you want to redo it in Tasker.