How I auto-charge my Macbook using Broadlink smart plug, Power Manager and IFTTT app
Not long before, my laptop drains on battery pretty badly. Moreover, thể battery issue got even worse, the bottom surface is swollen.
This is because of me not paying enough intention for the battery charging, I should have unplugged the charging cable after my laptop is fully charged. I know many people are living this bad habit too, we tend to leave the charging cable even when the green light is on.
And during my smart home setup process, I was determined to solve this problem automatically without me wasting time and will power for this small action (unplug the cable). I will cut the chase and go straight to the point right ahead ^^
The automatic charging process could be described by words like this: when the laptop battery is under 10%, trigger an action to start charging. When the laptop battery is 100%, trigger an action to stop charging. As simple as that, but the execution would cost you some bucks for the pursuit of smart devices.
Things to prepare:
- Sign up for IFFT service and register your webhooks. You can look at this article for detail of the process: https://medium.com/measuring-the-great-indoors/linking-ifttt-processing-with-webhooks-6b20c6ed722d. I define 2 events to start and stop charging the battery. For start_charge
- Install the DSSW Power Manager app for your macOS here: https://www.dssw.co.uk/powermanager/. After installing the Power Manager, create an action “when the battery drops to x %”. You can find the detailed tutorial here, although not exactly the same. https://www.dssw.co.uk/blog/2011-07-12-how-to-run-a-command-when-switching-to-battery-power/.
- In my case, I will choose 10% is the limit before I start the charging on
In the script, you have to make a request to trigger the web hook you have defined. Fill in this blank the following pieces of code
- Use this command to make a request to start charging:
curl -X POST https://maker.ifttt.com/trigger/charge_macbook/with/key/{your_webhook_key}
- The same flow could be created for the “battery level reaching 100%” case. Use this command to make a request to stop charging:
curl -X POST https://maker.ifttt.com/trigger/stop_charge_macbook/with/key/{your_webhook_key}
Everything is already set up, when the MacBook battery drops to 10%, the electric current would be activated, red light on the cable is on, and when the battery reaches 100%, the electric current would be stopped, green light on a cable is off. You don’t have to move a finger during this whole charging process. This would save your will power for something else more important while keeping your battery in good condition.