protect battery on thinkpad T490 - Ubuntu 18.04

I have a thinkpad T490 on Ubuntu 18.04. I want to protect my battery (the tlp stuff with max charge 80 and start charge 75).

However, it looks like I have some problems:

~$ sudo tlp setcharge START_CHARGE 70
Error: ThinkPad battery features not available.

I think this is due to problems with tp-sampi and / or tpacpi-bat:

~$ sudo tlp stat
...
+++ ThinkPad Battery Features
tp-smapi   = inactive (kernel module 'tp_smapi' load error)
tpacpi-bat = inactive (kernel module 'acpi_call' load error)

After googling, it seems that tp-smapi does not work on thinkpads from versions *30 and over and tpacpi-bat should be the solution to use instead. I cannot find more help about if / how I should set up tpacpi-bat. Any tips / instructions? :)


Solution 1:

After a discussion with the package author and maintainer (many thanks to him for his patience with my n00bness), the solution was to update to the PPA version 1.2.2 (I guess newer may work as well):

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update 
sudo apt-get upgrade
sudo apt-get install tp-smapi-dkms acpi-call-dkms tlp

After that things start to work:

~$ sudo tlp-stat
--- TLP 1.2.2 --------------------------------------------
...

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = active (data, thresholds)
tpacpi-bat = inactive (kernel module 'acpi_call' load error)
tp-smapi   = inactive (ThinkPad not supported)
...

and the battery levels can be updated:

~$ sudo tlp setcharge 70 80
Setting temporary charge thresholds for BAT0:
  start =  70 (no change)
  stop  =  80 (no change)

leading to:

~$ sudo tlp-stat
...
/sys/class/power_supply/BAT0/charge_start_threshold         =     70 [%]
/sys/class/power_supply/BAT0/charge_stop_threshold          =     80 [%]
...

Note that if you want the update to survive reboot, you need to update the configuration file at /etc/default/tlp by uncommenting / modifying the lines 355-356 (you will need to open as root and overwrite readonly protection, for example in vim you need :w! ):

350 # Battery charge thresholds (ThinkPad only, tp-smapi or acpi-call kernel module
351 # required). Charging starts when the remaining capacity falls below the
352 # START_CHARGE_THRESH value and stops when exceeding the STOP_CHARGE_THRESH value.
353 # Main / Internal battery (values in %)
354 # Default: <none>
355 START_CHARGE_THRESH_BAT0=70                                                                                         
356 STOP_CHARGE_THRESH_BAT0=80
357 # Ultrabay / Slice / Replaceable battery (values in %)
358 # Default: <none>
359 #START_CHARGE_THRESH_BAT1=75
360 #STOP_CHARGE_THRESH_BAT1=80

For more details:

https://linrunner.de/en/tlp/docs/tlp-configuration.html#chargethresholds

Solution 2:

For THINKPAD E14 default threshold :

/sys/class/power_supply/BAT0/charge_start_threshold = 20 [%] /sys/class/power_supply/BAT0/charge_stop_threshold = 20 [%]

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update 
sudo apt-get upgrade 
sudo apt-get install tp-smapi-dkms acpi-call-dkms tlp

we can change threshold to 60/80 by sudo tlp setcharge 60 80

Can check by sudo tlp-stat