Skip to content

Instantly share code, notes, and snippets.

@linrunner
Last active October 29, 2024 02:31
Show Gist options
  • Save linrunner/4a6876648765fac5e141f15d0582a945 to your computer and use it in GitHub Desktop.
Save linrunner/4a6876648765fac5e141f15d0582a945 to your computer and use it in GitHub Desktop.

TLP 1.4 Test: Battery Care for Lenovo Laptops (non-ThinkPad series)

Read the overview document first.

Supported Features

Lenovo laptop series using the ideapad_laptop driver have a feature called 'battery conservation mode', basically a fixed stop charge threshold at 60%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold

  2. If the charge level is higher than the stop threshold, the battery will not discharge automatically; it will only be discharged when the charger is removed i.e. the laptop runs on battery

When suitable hardware has been detected, tlp-stat -b shows:

+++ Battery Care
Plugin: ideapad
Supported features: charge threshold
Driver usage:
* vendor (ideapad_wmi) = active (charge threshold)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0: 0(off)..1(on) -- battery conservation mode

/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode = 1

How it works

Battery charging is a process not controlled by TLP itself, but by the laptop's embedded controller (EC). This makes the process work even when switched off or no operating system is running. You cannot change the basic behavior, it is hard-coded into the EC firmware by the vendor. TLP just writes the charge threshold into the EC with the help of the kernel driver, the EC takes care of the rest.

Installation

Packages are provided at the download page.

Linux kernel 4.14 or higher required.

Test Cases

Important: please provide all terminal input and output from the test cases via an individual Gist and link it in your post below.

1. Configure and enable battery conservation mode

Edit /etc/tlp.conf (or a config file of your choice under /etc/tlp.d/):

STOP_CHARGE_THRESH_BAT0="1"

Note: 0=conservation mode off/1=conservation mode on

Connect the charger.

Enter the following commands in a terminal (as root or with sudo):

tlp start
tlp-stat -s -c -b

Verify that conservation_mode = 1.

2. Verify the charging process

  1. Let the laptop run on battery power until the charge level falls below at least 50%
  2. Connect the charger and see if charging starts
  3. Verify that charging stops at 60%

Enter the command (as root or with sudo):

tlp-stat -b

3. Disable battery conservation mode and return to full charge

Edit the config file used above:

STOP_CHARGE_THRESH_BAT0="0"

Enter the commands (as root or with sudo):

tlp fullcharge
tlp-stat -b

Verify that conservation_mode = 0 and the battery gets fully charged.

What else should I check?

  • Please report if the conservation mode takes effect at a value other than 60%
  • Are there Lenovo laptops with more than one battery (tlp-stat -b should show)?
@kejioz
Copy link

kejioz commented Apr 20, 2023

Works on Ideapad5. Btw, do you know what's the purpose of this feature? Why should keeping the threshold to 60% optimize battery life?

@Serphentas
Copy link

@kejioz It prevents the battery cells from being under stress, which in turns yields a greater cycle count. Other variables and battery management methods impact this number, but this should give you an idea of why it's better to not fully charge unless you need the extra power.

@Droxt1
Copy link

Droxt1 commented Jul 21, 2023

After running these commands sudo tlp start && sudo tlp-stat -s -c -b the conservation mode remain a 0 and didn't change till I rebooted, but this command works just fine without any errors echo 1 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode or echo 0 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode

@caius-iulius
Copy link

Works perfectly, thanks! The only difference is that my threshold is hard-set on 80%

here are the logs

@3ri4nG0ld
Copy link

3ri4nG0ld commented Nov 4, 2023

Nope. Either the hardware or the kernel driver don't support it.

I don't understand why TLP can't handle this.
Wouldn't it be as easy as monitoring the battery until it reaches the indicated percentage, and if it does, then activating "Conservation Mode"?
And when the battery drops below the indicated threshold it is turned off again.
Obviously it has a limitation, since you couldn't specify percentages below 60%, but at least it could give users more options.

@zamoosh
Copy link

zamoosh commented Aug 2, 2024

Thanks a lot! setting STOP_CHARGE_THRESH_BAT0="0", just fixed my problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment