How to set battery charging thresholds on laptop...

When the laptop is charged to 95%, I want to stop charging...

Code:
# hwstat
                    Current                Unit
[Coretemp]
    CPU0:                Cannot get temperature
    CPU1:                Cannot get temperature
    CPU2:                Cannot get temperature
    CPU3:                Cannot get temperature
    CPU4:                Cannot get temperature
    CPU5:                Cannot get temperature
    CPU6:                Cannot get temperature
    CPU7:                Cannot get temperature

[ACPI Thermal]
    tz0:                56.1                C

[ACPI Battery (sysctl)]
    Cap remain:            75                percents
    Life time:            148                Min(s)
    State:                1
    Units:                2

[battery0]
    Present:            yes
    Design capacity:        21330                mWh
    Last full capacity:        22930                mWh
    Technology:            secondary (rechargeable)
    Design voltage            11400                mV
    Capacity (warn):        1146                mWh
    Capacity (low):            200                mWh
    Low/warn granularity:        -1                mWh
    Warn/full granularity:        -1                mWh
    Model number:            00HW022
    Serial number:             1020
    Type:                LiP
    OEM info:            LGC
    State:                discharging
    Remaining capacity:        37                percent
    Remaining time:            0:29
    Present rate:            17566                mW
    Voltage:            11097                mV

[battery1]
    Present:            yes
    Design capacity:        71100                mWh
    Last full capacity:        35020                mWh
    Technology:            secondary (rechargeable)
    Design voltage            11250                mV
    Capacity (warn):        1751                mWh
    Capacity (low):            200                mWh
    Low/warn granularity:        -1                mWh
    Warn/full granularity:        -1                mWh
    Model number:            01AV492
    Serial number:              852
    Type:                LION
    OEM info:            LGC
    State:                high
    Remaining capacity:        100                percent
    Remaining time:            1:59
    Present rate:            0                mW
    Voltage:            12307                mV

Code:
# uname -a
FreeBSD bleakwind.xxx.com 12.2-RELEASE-p6 FreeBSD 12.2-RELEASE-p6 GENERIC  amd64

Code:
# dmidecode -t 1
System Information
    Manufacturer: LENOVO
    Product Name: 20L5A01UHH
    Version: ThinkPad T480
 
Hi,

T430 here.

What works for me to set charge start threshold to 80% and stop charge threshold to 95% :

Get battery acpi handle :

sysctl dev.acpi_ibm.0.%location
dev.acpi_ibm.0.%location: handle=\_SB_.PCI0.LPC_.EC__.HKEY

Use it to set the start charge threshold :
acpi_call -p '\_SB_.PCI0.LPC_.EC__.HKEY.BCCS' -i 80

and set the stop charge threshold :
acpi_call -p '\_SB_.PCI0.LPC_.EC__.HKEY.BCSS' -i 95

Quite close to what was described in the Reddit post.
Don't know if it works on a T480.
Good luck.
 
Seems to be working great in X1 Gen1, thanks, Fuzzbox !
Currently at 96% and AC plugged in:
Code:
% acpiconf -i0 | grep State
State:            high
which means it's not charging!
 
Looks like it doesn't works on mine T495 with FreeBSD 13.0-RELEASE:
Code:
 acpi_call -v -p '_SB_.PCI0.LPC0.EC.HKEY.BCCS' -i 99
Path: _SB_.PCI0.LPC0.EC.HKEY.BCSS
Number of arguments: 1
Argument 1 type: Integer
Argument 1 value: 99
Status: 4097
Result: Unknown object type '0'

Code:
acpi_call -v -p '_SB_.PCI0.LPC0.EC0_.HKEY.BCSS' -i 15
Path: _SB_.PCI0.LPC0.EC0_.HKEY.BCCS
Number of arguments: 1
Argument 1 type: Integer
Argument 1 value: 15
Status: 4097
Result: Unknown object type '0'
Code:
sysctl dev.acpi_ibm.0.%location
dev.acpi_ibm.0.%location: handle=\-SB_.PCI0.LPC0.ECO_.HKEY

Thank you.
 
You really have to write '\-SB_.PCI0.LPC0.ECO_.HKEY' , with the \ at the beginning.
acpi_call -p '\_SB_.PCI0.LPC0.ECO_.HKEY.BCCS' -i 15
Now I got for both "0" and when I checked both if are they runing:
Code:
 acpi_call -v -p '\_SB.PCI0.LPC0.EC0_.HKEY.BCSG' -i 1 -v
Path: \_SB.PCI0.LPC0.EC0_.HKEY.BCSG
Number of arguments: 1
Argument 1 type: Integer
Argument 1 value: 1
Status: 0
Result: 867
acpi_call -v -p '\_SB.PCI0.LPC0.EC0_.HKEY.BCTG' -i 1 -v
Path: \_SB.PCI0.LPC0.EC0_.HKEY.BCTG
Number of arguments: 1
Argument 1 type: Integer
Argument 1 value: 1
Status: 0
Result: 783

Is it look okay, please? Should I put both in /etc/rc.conf?

Thank you.
 
Now unplug the AC adapter and see how the charging behaves.
If it works and the thresholds are ok, the battery controller should keep them in memory until you change them again, or until you plug out / plug back in the battery from its compartment.
 
Now unplug the AC adapter and see how the charging behaves.
If it works and the thresholds are ok, the battery controller should keep them in memory until you change them again, or until you plug out / plug back in the battery from its compartment.
Thank you. I will try. I external monitor connected with USB-C and it also charge a laptop. I will try to connect with HDMI and carged laptop with regular charger. For now hwstat shows:
Code:
[Coretemp]
    CPU0:                48.0                C
    CPU1:                48.0                C
    CPU2:                48.0                C
    CPU3:                48.0                C
    CPU4:                48.0                C
    CPU5:                48.0                C
    CPU6:                48.0                C
    CPU7:                48.0                C

[ACPI Battery (sysctl)]
    Cap remain:            89                percents
    Time remain:            On AC
    State:                0
    Units:                1

[battery0]
    Present:            yes
    Design capacity:        50450                mWh
    Last full capacity:        49150                mWh
    Technology:            secondary (rechargeable)
    Design voltage            11520                mV
    Capacity (warn):        2457                mWh
    Capacity (low):            200                mWh
    Low/warn granularity:        -1                mWh
    Warn/full granularity:        -1                mWh
    Model number:            5B10W139
    Serial number:             4773
    Type:                LiP
    OEM info:            SMP
    State:                high
    Remaining capacity:        89                percent
    Remaining time:            unknown
    Present rate:            0                mW
    Voltage:            12642                mV
 
Hm... it's a good sign, since the remaining capacity is not 100%.
If you have set start at 15% and stop at 95%, it should not start charging again until your battery reaches a level lower than 15% (which is a bit low imho, something like 30% could be better for the health of the battery). Then it will charge from 15% to 95%, unless you unplug the AC adapter in between.
 
I am not sure if it works because I have 89% almost one hour now. The light is orange but...and hwstat shows
Code:
[ACPI Battery (sysctl)]
    Cap remain:            89                percents
    Time remain:            On AC
    State:                0
    Units:                1

[battery0]
    Present:            yes
    Design capacity:        50450                mWh
    Last full capacity:        49150                mWh
    Technology:            secondary (rechargeable)
    Design voltage            11520                mV
    Capacity (warn):        2457                mWh
    Capacity (low):            200                mWh
    Low/warn granularity:        -1                mWh
    Warn/full granularity:        -1                mWh
    Model number:            5B10W139
    Serial number:             4773
    Type:                LiP
    OEM info:            SMP
    State:                high
    Remaining capacity:        89                percent
    Remaining time:            unknown
    Present rate:            0                mW
    Voltage:            12649                mV
and sysctl -a | grep battery
Code:
hw.acpi.battery.info_expire: 5
hw.acpi.battery.units: 1
hw.acpi.battery.state: 0
hw.acpi.battery.rate: 0
hw.acpi.battery.time: -1
hw.acpi.battery.life: 89
dev.battery.0.%parent: acpi0
dev.battery.0.%pnpinfo: _HID=PNP0C0A _UID=0 _CID=none
dev.battery.0.%location: handle=\_SB_.PCI0.LPC0.EC0_.BAT0
dev.battery.0.%driver: battery
dev.battery.0.%desc: ACPI Control Method Battery
dev.battery.%parent:
 
Read my previous post again :)

Charge stop threshold : the threshold your battery won't exceed when it's charging.
Charge start threshold : the threshold you have to reach before your battery starts charging again.

So, with a power source connected to you laptop, the battery will stay at 89% for now.
Disconnect the power source, you battery will discharge.
Connect the power source again : if the remaining capacity is higher than 15%, it won't charge; if it's lower than 15% it will charge, up to 95%.

So, if you want your laptop to be "almost charged all the time but not 100%", you should set a start charge threshold higher, like 85% for instance, and a stop charge threshold at 95%. But if you use it almost always connected to a power source, something like 30% / 75% is enough.

I hope that's clearer :)
 
You don't *need* it, since you can get the same data from other tools, but you can install it as a package or from ports ( /sysutils). It only displays CPU and battery infos.
 
I've just installed sysutils/hwstat and this is what it outputs:-
Code:
[Coretemp]
    CPU0:                Cannot get temperature
    CPU1:                Cannot get temperature
    CPU2:                Cannot get temperature
    CPU3:                Cannot get temperature

[ACPI Thermal]
    tz0:                48.1                C

[ACPI Battery (sysctl)]
    Cap remain:            100                percents
    Time remain:            On AC
    State:                0
    Units:                1

[battery0]
    Present:            yes
    Design capacity:        47520                mWh
    Last full capacity:        46390                mWh
    Technology:            secondary (rechargeable)
    Design voltage            10800                mV
    Capacity (warn):        2319                mWh
    Capacity (low):            200                mWh
    Low/warn granularity:        1                mWh
    Warn/full granularity:        1                mWh
    Model number:            45N1005
    Serial number:            32534
    Type:                LION
    OEM info:            LGC
    State:                high
    Remaining capacity:        100                percent
    Remaining time:            unknown
    Present rate:            0                mW
    Voltage:            12168                mV

Seems odd that no CPU temperature is displayed... apart from that do things appear to be normal?
 
Hm... do you have the coretemp module loaded ? I have
Code:
coretemp_load="YES"
in my /boot/loader.conf.
Btw, your battery is in very good health.
 
Hi,

T430 here.

What works for me to set charge start threshold to 80% and stop charge threshold to 95% :

Get battery acpi handle :

sysctl dev.acpi_ibm.0.%location
dev.acpi_ibm.0.%location: handle=\_SB_.PCI0.LPC_.EC__.HKEY

Use it to set the start charge threshold :
acpi_call -p '\_SB_.PCI0.LPC_.EC__.HKEY.BCCS' -i 80

and set the stop charge threshold :
acpi_call -p '\_SB_.PCI0.LPC_.EC__.HKEY.BCSS' -i 95

Quite close to what was described in the Reddit post.
Don't know if it works on a T480.
Good luck.

Thanks for your help.
My computer is Thinkpad T480.
Code:
# sysctl -a | grep dev.acpi_ | grep EC
dev.acpi_acad.0.%location: handle=\_SB_.PCI0.LPCB.EC__.AC__
dev.acpi_ec.0.%location: handle=\_SB_.PCI0.LPCB.EC__
dev.acpi_ec.0.%desc: Embedded Controller: GPE 0x16, ECDT

Is my locations is this?
Code:
dev.acpi_ec.0.%location: handle=\_SB_.PCI0.LPCB.EC__

and this?
Code:
acpi_call -p '\_SB_.PCI0.LPCB.EC__.HKEY.BCCS' -i 80
acpi_call -p '\_SB_.PCI0.LPCB.EC__.HKEY.BCSS' -i 95

Is it work for other brand laptop?
 
Yes, I've just checked, and the "%location" I get from dev.acpi_ibm... and dev.acpi_acad... is the same.
So the acpi_call commands above are supposed to work.

As far as I know, it's not a common feature on laptops, even if exists for ages on Thinkpads. I *think* some Dell and Sony computers implement it, of course probably in a different way.
 
Yes, I've just checked, and the "%location" I get from dev.acpi_ibm... and dev.acpi_acad... is the same.
So the acpi_call commands above are supposed to work.

As far as I know, it's not a common feature on laptops, even if exists for ages on Thinkpads. I *think* some Dell and Sony computers implement it, of course probably in a different way.

Clould you post this output? Thanks...

Code:
# sysctl -a | grep \_SB_.PCI0.LPCB.
 
Sure :
Code:
sysctl -a|grep \_SB_.PCI0.LPC

dev.acpi_ibm.0.%location: handle=\_SB_.PCI0.LPC_.EC__.HKEY
dev.acpi_acad.0.%location: handle=\_SB_.PCI0.LPC_.EC__.AC__
dev.battery.0.%location: handle=\_SB_.PCI0.LPC_.EC__.BAT0
dev.psmcpnp.0.%location: handle=\_SB_.PCI0.LPC_.MOU_
dev.atkbdc.0.%location: handle=\_SB_.PCI0.LPC_.KBD_
dev.fpupnp.0.%location: handle=\_SB_.PCI0.LPC_.FPU_
dev.atdma.0.%location: handle=\_SB_.PCI0.LPC_.DMAC
dev.isab.0.%location: slot=31 function=0 dbsf=pci0:0:31:0 handle=\_SB_.PCI0.LPC_
dev.atrtc.0.%location: handle=\_SB_.PCI0.LPC_.RTC_
dev.hpet.0.%location: handle=\_SB_.PCI0.LPC_.HPET
dev.attimer.0.%location: handle=\_SB_.PCI0.LPC_.TIMR
dev.acpi_sysresource.1.%location: handle=\_SB_.PCI0.LPC_.SIO_
dev.acpi_ec.0.%location: handle=\_SB_.PCI0.LPC_.EC__
 
Now unplug the AC adapter and see how the charging behaves.
If it works and the thresholds are ok, the battery controller should keep them in memory until you change them again, or until you plug out / plug back in the battery from its compartment.
"... or until you plug out / plug back in the battery from its compartment."

Why is that?
 
Back
Top