0xless / battmngr

Battery manager to handle system performance modes and charge modes through acpi_calls (for ideapad 15are05/14are05/14alc05).
GNU General Public License v3.0
18 stars 3 forks source link

Support Lenovo IdeaPad Flex 5 14ALC05 #3

Open rhysperry111 opened 2 years ago

rhysperry111 commented 2 years ago

Setting the performance mode appears to be the same, however I cannot read the states back.

zenitraM commented 2 years ago

Can you try with this version? with this changes it worked on my non-Flex 14ALC05

https://github.com/zenitraM/battmngr/blob/dd5d691596a10e1c812d615ecfccb2cbe3a1d6b0/battmngr

rhysperry111 commented 2 years ago

That version cannot read the states either

MarcKaplan19 commented 1 year ago

Not working on my Ideapad flex 5 14ALC05... If you could please give me a hint where to find the acpi_call magic codes for this model, I could fix the script...

0xless commented 1 year ago

Not working on my Ideapad flex 5 14ALC05... If you could please give me a hint where to find the acpi_call magic codes for this model, I could fix the script...

Please try using the experimental support branch as it has configuration files capable of supporting a couple of models including some 14ALC05.

MarcKaplan19 commented 1 year ago

Tx for very fast response. I will try the experimental version when I have a chance and report back here.

MarcKaplan19 commented 1 year ago

(nevermind -- just used the git checkout command )

rhysperry111 commented 1 year ago

I've just built from the new branch, and I can't seem to control, or read the battery states. Reading charging states also reports the same error (unrecognised mode), but I have no way of verifying if setting it works right now.

I doubt it does though, as trying to set either the battery or charge mode gives this error:

/usr/bin/battmngr: line 188: ((: Error: AE_TYPE ==  : syntax error in expression (error token is ": AE_TYPE ==  ")
MarcKaplan19 commented 1 year ago

(No joy yet.) On the experimental branch, with the little json database. To get going I had to add install jq. Then I added an echo of the model which was 82HU, which doesn't appear in the .json file... So I hacked the json file so 82HU selects the codes you already had for 14ALC05 and the result is:

root@marcFlex:/home/makaplan/ideapad/battmngr# ./battmngr.x -r model=82HU 14are05/14alc05 Unrecognized battery mode, please retry

diffs for my hacked in debugging.... (hmmm try triple backticks for the following)

--- battmngr    2022-07-17 16:14:21.432349528 -0400
+++ battmngr.x  2022-07-18 09:32:41.964199037 -0400
@@ -1,6 +1,6 @@
 #!/bin/bash

-config_file="configs.json"
+config_file="configs.json.x"

 #
 # Read/Set battery modes in lenovo ideapad 15are05 using acpi_call kernel module
@@ -169,6 +169,8 @@
 function setup(){
    modprobe acpi_call
    model=`sudo dmidecode -s system-product-name`
+   echo "model=$model"
+       echo `cat $config_file | jq -r '.'\"$model\"'."model"'`     
 }

--- configs.json    2022-07-17 16:14:21.432349528 -0400
+++ configs.json.x  2022-07-18 09:20:31.182978597 -0400
@@ -51,7 +51,7 @@
     }
   },

-  "82LM": 
+  "82HU": 
   {
     "model":"14are05/14alc05",

NICE script.... which I'd be happy to fix up for 82HU aka "Ideapad flex 5 14ALC05" Now brings us back to the question... How do we discover the correct ACPI codes to set battery charging parameters for my model? I'd be happy to work with you, more debugs/echos, try some other codes, etc. Thanks!

MarcKaplan19 commented 1 year ago

Hmm...we should also fix the script to self diagnose when a model designator is not found in config.json. Probably just a matter of checking the checking the jq output or return code.

0xless commented 1 year ago

Hi @MarcKaplan19, as I mentioned around the issues of this repo, not every ACPI call is known for every supported model. Your best bet is to check on archwiki and hope that they have ACPI calls working for your model (that's where the calls used in this project come from).

If you want to experiment, you can try to sniff ACPI calls on windows while using the lenovo vantage software. I haven't tried this yet, but feel free to report back if you succeed!

MarcKaplan19 commented 1 year ago

I found a few other, but less sophisticated scripts that do power and bat mgmt for ideapads, I will try adding any different codes to your script or json file.

Still seems nuts to me that different models use different codes or commands for the same functions. Why not just copy what works? Remember the old AT modem codes? Especially shameful that even within the Lenovo brand to be needlessly different.

rhysperry111 commented 1 year ago

I've found that, at least on my laptop, the ACPI codes documented in this wiki page work perfectly :)

rhysperry111 commented 1 year ago

I've found that, at least on my laptop, the ACPI codes documented in this wiki page work perfectly :)

Just a bump in case this got lost in the void of notifications. You might wanna test the above linked ACPI calls on your system @MarcKaplan19