3

Just as the OP asked in the other question, I would like to have a battery threshold.

However, for me, when I type into the terminal

echo 80 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

I get a message in the terminal saying "Permission denied", even when I type "sudo" before "echo".

How can I still do it?

EDIT: I use Ubuntu 20.04 on a Dell Latitude 7390.

That's why I get in the terminal when I go to /sys/class/power_supply/

enter image description here

When I go into the folder BAT0, this is what I get:

enter image description here

Edit:

This is what I get when running smbios-battery-ctl --set-charging-mode custom.

enter image description here

Anonymous5638
  • 661
  • 1
  • 9
  • 17

3 Answers3

4
  1. Download Dell Command Configure for Ubuntu 20.04 from here. Download link.

  2. Install according to this article

tar -xvzf command-configure_4.4.0-<Build Number>.<Ubuntu Version>_<architecture>.tar.gz

sudo dpkg -i srvadmin-hapi_9.3.0_amd64.deb

If the installation fails due to dependency problems, then run the following command to install all dependent packages from the Ubuntu repository: apt-get -f install

sudo dpkg -i command-configure_4.4.0-<Build Number>.<Ubuntu Version>_<architecture>.deb
  1. Enter the installed directory. cd /opt/dell/dcc

  2. Run sudo ./cctk --PrimaryBattChargeCfg=Custom:low-high (example: sudo ./cctk --PrimaryBattChargeCfg=Custom:50-70

Documentation on options

Anonymous5638
  • 661
  • 1
  • 9
  • 17
VidathD
  • 2,829
3

Please read through the entire post. I am giving two possible solutions, plus one possible solution route (to be explored further if needed).

Solution 1

This thread mentions application cctk (Client Configuration Toolkit) specific for Dell.
Command cctk --PrimaryBattChargeCfg=Custom:50-70 might work.
CCTK was likely superseded by Dell Command | Configure, I am not sure if CCTK still works in some systems.

Solution 2

This thread refers to interaction between TLP and Dell. But official documentation shows battery thresholds for Dell cannot be controlled with TLP. At the bottom of the thread, it is shown that libsmbios could help, via
smbios-battery-ctl --set-custom-charge-interval low high
(with smbios-battery-ctl --set-charging-mode custom).

Another possible route

In my Lenovo, I have charge_start_threshold and charge_stop_threshold, not charge_control_start_threshold and charge_control_end_threshold. in /sys/class/power_supply/BAT0.

This old answer shows files start_charge_thresh and stop_charge_thresh in directory /sys/devices/platform/smapi/BAT0/ for a Lenovo.

So chances are the file names and/or directory should be different in your Dell. You might try all the same but with file names as charge_end_threshold, charge_stop_threshold, charge_control_stop_threshold instead, and follow up on the OP you linked.

Extra info

  1. This old thread mentions that if you set the thresholds in Windows, Linux will abide by them, although there is no way to change them from within Linux. I don't know if this workaround is useful for you, and the info is possibly outdated anyway.

  2. This mentions that
    For maximum lifespan when rarely using the battery, set Custom charge thresholds to start charging at 40% capacity and stop at 50%, and keep the ThinkPad cool. The thresholds can be adjusted in the Battery Maintenance settings of Lenovo Power Manager.
    If the battery is used somewhat frequently, set the start threshold at around 85% and stop at 90%. This will still give a good lifespan benefit over keeping the battery charged to 100%.

0

With the help of a bunch of extra data and the Dell Latitude 7390 Owner's Manual, it looks like the BIOS is not configured to allow your battery to make use of some Advanced Power Management features such as charge_control_end_threshold and charge_stop_threshold.

The first clue was from the Permission denied error when setting charge_control_end_threshold, as we cannot add anything to /sys/class/ that does not already exist. When this same error appeared for charge_stop_threshold, it forced a rethink to determine whether the battery was called BAT0, BATT, or BATC (or BAT1 on a couple of Acer models). However, the final confirmation is seen with the output of the /sys/class/power_supply/BAT0/ pseudo-directory. These "files" are API interfaces when working with the battery, which is why we cannot add (or remove) any of them.

Unfortunately I do not have a Dell nearby to test this with but, according to the owner's manual, it may be possible to activate the features needed by tweaking a couple of settings in the BIOS.

Let's try this:

  1. Reboot the machine

  2. Enter the BIOS

    ⇢ Press F12 key when the Dell logo appears to access a boot menu with a list of the valid devices. Choose "Other Options" then enter "BIOS Setup"

  3. Find "Power Management"

  4. Find "Primary Battery Charge Configuration" and change the value to "Custom". As per the documentation:

    If Custom Charge is selected, you can also configure Custom Charge Start and Custom Charge Stop.

  5. Save the settings and boot back into Ubuntu

With this done, so long as your battery supports the ability to set (and display) charge thresholds, you should see charge_control_end_threshold and/or charge_stop_threshold in the /sys/class/power_supply/BAT0 location.

Hope this gives you what you're looking for