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)?
@linrunner
Copy link
Author

Great. Thanks for your participation.

@stavros-k
Copy link

@linrunner
Copy link
Author

linrunner commented Aug 22, 2021

@stavros-k: thank you for your detailed report.

@rduttshukla
Copy link

Works great on Lenovo Ideapad V130-14IKB even when powered off. Ready to reduce e-waste ✊🏼✊🏼

Threshold: 60%

@linrunner
Copy link
Author

Beta 2 is out. Enjoy!

@wojexe
Copy link

wojexe commented Sep 11, 2021

Working properly on Lenovo IdeaPad Gaming 3 15ARH05 82EY! 😄
https://gist.github.com/wojexe/e99d2a1dbf591f87d62f41fd257a22bc

@linrunner
Copy link
Author

@wojexe: thank you.

@fsheidaiee
Copy link

Hi
Can I use this app with wsl2 on windows 10?

@linrunner
Copy link
Author

linrunner commented Sep 19, 2021

@fsheidaiee : no.

@bLd75
Copy link

bLd75 commented Sep 21, 2021

LENOVO Legion Y540 on Debian 11 Bullseye : everything works great, love it! ❤️
https://gist.github.com/bLd75/26c2380d6c591b6ae65eaf4e18d62198

@linrunner
Copy link
Author

TLP 1.4 is released. Have fun!

@bLd75 : thanks.

@103sbavert
Copy link

I understand that with this I can enable or disable battery conservation mode (from Lenovo Vantage) but I am still not sure how to enable/disable quick charge with TLP because enabling battery conservation mode in Lenovo Vantage disables quick charge and vice-versa. I assume enabling battery conservation mode with TLP also disables quick charge but how do I enable it?

@linrunner
Copy link
Author

linrunner commented Jan 2, 2022

@sbeve72 : there is no Linux kernel interface (sysfs node) for quick charge, therefore TLP can neither disable nor enable it.

@103sbavert
Copy link

@linrunner Thamk you for the response. I understand TLP can neither disable nor enable fast charge. Does this mean ​when enabling conservation mode with TLP, quick charge wouldn't disable? Or does this mean quick charge would disable but it won't turn back on after disabling conservation mode? Or do you not have any way to find that out?

@linrunner
Copy link
Author

@sbeve72 : without kernel interface you cannot find out of course.

@103sbavert
Copy link

I reinstalled KDE Neon and I have forgot how I configured tlp. So far I have done this:

sudo apt install tlp
sudo tlp start

and the output of tlp-stat -b gives me this:

# tlp-stat -b
--- TLP 1.3.1 --------------------------------------------

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = inactive (laptop not supported)
tpacpi-bat = inactive (laptop not supported)
tp-smapi   = inactive (laptop not supported)

+++ Battery Status: BAT0
/sys/class/power_supply/BAT0/manufacturer                   = SMP
/sys/class/power_supply/BAT0/model_name                     = L19M3PF6
/sys/class/power_supply/BAT0/cycle_count                    =     29
/sys/class/power_supply/BAT0/energy_full_design             =  57000 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  59410 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  35390 [mWh]
/sys/class/power_supply/BAT0/power_now                      =      0 [mW]
/sys/class/power_supply/BAT0/status                         = Unknown

Charge                                                      =   59.6 [%]
Capacity                                                    =  104.2 [%]

I remember conservation mode worked perfectly on my device previously, but it doesn't anymore

System Info:

Operating System: KDE neon 5.25
KDE Plasma Version: 5.25.2
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.5
Kernel Version: 5.13.0-52-generic (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 82FG
System Version: IdeaPad 5 15ITL05 Ua

TLP version = TLP 1.3.1

@stavros-k
Copy link

TLP version = TLP 1.3.1

Uhm.. Install 1.4?

@103sbavert
Copy link

sorry I am dumb. that worked.

@ch3ll0v3k
Copy link

image

AMD Ryzen 7 5800H with Radeon Graphics 2021 model (i think)
Threshold: 60%

@Ahmed00010
Copy link

Working perfectly
thank you so much (: +1:
my system
Operating System: Debian GNU/Linux KDE Plasma Version: 5.26.4 KDE Frameworks Version: 5.101.0 Qt Version: 5.15.7 Kernel Version: 6.0.0-6-amd64 (64-bit) Graphics Platform: X11 Processors: 4 × Intel® Core™ i3-5005U CPU @ 2.00GHz Memory: 3.8 GiB of RAM Graphics Processor: Mesa Intel® HD Graphics 5500 Manufacturer: LENOVO Product Name: 80QQ System Version: Lenovo ideapad 100-15IBD

@Johan-Liebert1
Copy link

This works as intended. Is there a parameter I can set so that the threshold is at 80% instead of 60%

@linrunner
Copy link
Author

linrunner commented Jan 14, 2023

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

@firepainting
Copy link

Seems to be working!

Hardware: Lenovo ideapad 330-14IKB 81G2
Threshold: 60%

Please check out my Gist:
https://gist.github.com/firepainting/dae5ac11a396a03a99f24e7571cc4099

Thank you and thank you especially for this "Conservation Mode" feature in TLP! :)

@ssreddy555
Copy link

ssreddy555 commented Apr 14, 2023

Working well on Lenovo YOGA 320.

When set, the charge stopped at 59% but later on, decreased to 57% even though the device is connected to the AC power.

Screenshot_2023-04-14_09-47-34

Screenshot_2023-04-14_17-43-49

@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