🔋 Smart Charging for Smartphone

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

GitHub Gist

What problem does it solve?
Battery life is the number of charge-discharge cycles, and if you leave charging “overnight”, some smartphones will charge to 100% when the charge drops to 99%, which also slightly reduces the battery life, and to solve this problem I created this automation.

What it does
Automatically manages your phone’s charging by turning a smart plug on or off based on the battery level and a defined schedule. Ideal for preserving battery longevity and saving power. :battery:

Features

  • Turn on the socket when battery drops below a user-defined minimum (e.g., 20%)
  • Turn on during a time window (e.g., between 6:00–8:00) if battery is below a maximum threshold (e.g., 80%)
  • Turn off automatically when battery reaches 100%

Required devices

  • A smart plug configured as a switch in Home Assistant
  • A phone battery-level sensor from the HA companion app or another source

Inputs

Input Description
Charging Socket Select your smart plug (switch entity)
Phone Battery Level Sensor showing the phone’s battery (0–100%)
Minimum Battery Level Threshold (%) to trigger charging immediately
Maximum Battery Level Upper limit for scheduled charging
Scheduled Charging Start/Stop Time window during which charging is allowed if needed

How to use

  1. Go to Settings → Automations & Scenes → Blueprints, click Import Blueprint, and paste the GitHub or Gist URL after you publish the YAML.
  2. Once imported, select the blueprint and click Create Automation.
  3. Configure the required inputs (socket, battery sensor, thresholds, schedule), give your automation a name, and save.
  4. Reload automations if needed (via Settings → Server Controls).

Why you’ll love it

  • :electric_plug: Prevent overcharging: Automatically stops charging at 100%
  • :mantelpiece_clock: Smart scheduling: Only charges during a time window when plugged in
  • :gear: Highly customizable: Adjust thresholds and time window to your needs
  • :hammer_and_wrench: Reusable: Easy to import and tweak for multiple devices

Thank you for clarifying that it is advisable to keep your smartphone charged at 20-80%. It is true that it is better to keep the smartphone at 20-80% during the day if you have a phone that is often sitting down, but that is not the whole issue.

Battery life is the number of charge-discharge cycles, and if you leave charging “overnight”, some smartphones will charge to 100% when the charge drops to 99%, which also slightly reduces the battery life, and to solve this problem I created this automation.

I agree with what you are saying, but don’t repost AI words in here like that…

I have had posts flagged and deleted for doing this exact thing, quoting the google AI.

I will add my answer 100% is not evil for smartphones, most manufacturers put a reserve in advance in order not to overcharge the battery. Charging it 100% is normal, it is an additional 1-2 hours of work

That is the top result you get from Google.
Even if that was not there, the next real result would have said the same.

This “AI” is based on facts that has been proven from years of empirical data.
In my opinion, calling it “AI” is a far stretch.
But sure.

While in this case the AI answer is definitely the consensus, I’ve seen it make terrible mistakes more then once. Google even says so below in tiny letters: “AI responses may include mistakes”. It is in the forum rules that you can not use AI to answer questions for this reason. So please answer in your own words from your own knowledge. We can all Google or use a LLM if we want to.

1 Like