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.
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
- Go to Settings → Automations & Scenes → Blueprints, click Import Blueprint, and paste the GitHub or Gist URL after you publish the YAML.
- Once imported, select the blueprint and click Create Automation.
- Configure the required inputs (socket, battery sensor, thresholds, schedule), give your automation a name, and save.
- Reload automations if needed (via Settings → Server Controls).
Why you’ll love it
Prevent overcharging: Automatically stops charging at 100%
Smart scheduling: Only charges during a time window when plugged in
Highly customizable: Adjust thresholds and time window to your needs
Reusable: Easy to import and tweak for multiple devices