I have an unrooted GrapheneOS phone. I was surprised that it doesn’t offer a native option to limit battery charging to a specific upper limit (e.g., 80%) to preserve battery health and prolong the battery's life.
To work around this, I decided to implement a charging limit feature using automation software and a Wi-Fi-controllable plug. After some research, I bought a Shelly Plug S for this purpose. I'm trying to keep things open-source, so I avoid Google Play apps when possible. The closest Tasker alternative I found on F-Droid is Easer. Unfortunately, Easer seems to lack some crucial features that would make this process easier, such as switching Wi-Fi networks or starting external apps.
Here’s my plan so far:
- My phone’s charger is plugged into the Shelly Plug S, which is connected to my Wi-Fi network.
- I want to use Easer to automate the process: It would turn on the plug when the charger is connected, monitor the battery level, and, once it reaches 80%, turn off the Shelly Plug S by making an HTTP call to its local web interface (or an API call).
- I prefer to block the Shelly Plug from accessing the Internet entirely (to avoid leaking data to the cloud) by setting up firewall rules that restrict its access to only my local network.
However, Easer seems to have some limitations that make this more challenging than expected:
- Easer cannot switch Wi-Fi networks: I was hoping to use the Shelly Plug’s local access point (AP mode) for a more portable solution, but since Easer doesn’t have permission to switch networks, I'm restricted to my home network.
- Easer cannot start external apps: It also can’t trigger external apps that might help with network switching or more advanced controls.
At the moment, I’m stuck with these limitations and was wondering if anyone has experience with similar setups or has already written code to implement something like this. Specifically:
Has anyone written or seen code to automate switching off a Shelly Plug once a certain battery level is reached? Are there any workarounds for Easer’s limitations, or should I consider switching to a different automation tool that fits my FOSS preference?
I would greatly appreciate any tips, code snippets, or discussions around best practices for this type of setup. Ideally, I'd love to make this work while keeping the setup local and portable, but I’m open to suggestions!
Thanks in advance for your help!
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.
Well I like magisk but he could try shizuku or grant perminission over adb and stay without root
Yeah, shizuku could work I'm just not aware of any shizuku enabled charge control software
You can ignore my answer. To set a limit when recharging probably does not work with shizuku. root is unfortunately mandatory if not implemented in the system. That's sad
Yeah, that's about what I expected unfortunately
https://discuss.grapheneos.org/d/9017-how-can-i-limit-battery-charge-to-80/34 Seems like they will implement that feature.
Anyway that's interesting too. https://akc3n.page/posts/battery-management/