Care for your phone’s battery with home automation

Birgit Lexa
4 min readMar 18, 2023

--

Example setup (Image supplied by author)

This article refers to Home Assistant used in combination with an Android phone, but the same principle could work with other home automation systems that have a way to monitor or receive a mobile device’s current battery level, potentially even with other mobile platforms.

In times like these, with inflation soaring and an uncertain future ahead, it is imperative to make sure that unexpected expenses are minimized as much as possible. With the mobile phone being one of the most important items in many people’s everyday life, having to buy a new phone because the battery just won’t hold a charge anymore is something that is an undesirable outcome for many right now.

To make sure we take the best care possible of our phones, we first have to understand what is bad for the battery. The top battery killers are as follows:

  • Charging to full capacity
  • Discharging to a very low capacity
  • High temperatures

Of course we can’t just stop using and charging our phones, so it really has to be a compromise between battery capacity on any given day and battery lifetime overall. Combining learnings from research data with our personal requirements can give us a guideline on how to optimize charging cycles to not stress the battery more than necessary.

For example, if you need approximately 60% of your phone’s battery capacity every day, then according to this article from Battery University it is better to only charge the phone to 85% and then recharge it when it reaches 25%, rather than charging it to full and then letting it discharge to 40%.

Source: Battery University https://batteryuniversity.com/article/bu-808-how-to-prolong-lithium-based-batteries

Some phones already have an optional setting that stops the charging cycle prematurely when the battery reaches 80%, but for phones without this feature or when more fine-grained control is desired, home automation can help with that. With a simple script and a smart plug controllable via home automation software, you can control exactly¹ when the plugged in phone will start and stop being charged.

Hardware / Software setup

  • Phone: Xiaomi Mi Note 10 Lite
  • Phone charger: Generic 10W Model (plugged into the smart plug)
  • Smart plug: Xiaomi Zigbee Smart Plug² (plugged into a power outlet)
  • Battery data tracker: Home Assistant companion app on the phone to act as the device tracker sending the battery data
  • Home Automation Software: Home Assistant (All of the below code can be clicked together in the UI alternatively)

I always plug my phone in when going to sleep and these scripts will take care of charging the phone only when needed and only as long as it’s needed. With the smart plug being turned off after the finished charge cycle, the phone will also not continue receiving a trickle charge while being plugged in.

Automation 1: Turn on phone charger

This automation is responsible for turning on the charger if the phone battery falls below 50% (20% would also be a good choice if you just want to follow the 80/20 rule).

Automation 2: Turn off phone charger

This automation is responsible for turning off the phone charger once the phone reaches 80% battery charge. For simplicity I am ignoring if the phone is connected to this charger or somewhere else, I just want to make sure that I can plug the phone in at my bedside table knowing it will not continue charging if the phone is full enough already.

Automation in action

On the screenshot you can see that after the phone charge drops below 50%, the charger turns on, charges the phone for about 1.5 hours, and is then turned off once 80% is reached.¹

Bonus tip:

Temperatures above 30°C (86°F) have a negative effect on the lifetime of Li-Ion batteries. I have noticed that my phone gets very warm while being on a fast charging cycle. When the phone is noticeably warm to the touch on the outside, I think you can safely assume that the internal temperature of the device is high enough to be detrimental for the lifetime of the battery. This is why I decided to set up my system with on of my older chargers which delivers a lower wattage than the modern 20–45W fast chargers. This keeps the phone at a very moderate temperature, and during the night there is plenty of time to charge even at the slowest speed.

[1]: depending on how often the battery data is polled, I have noticed a variation of the trigger time of up to 4% battery charge

[2]: when I built this setup, this was the only affordable Zigbee smart plug available on the European market.

--

--