Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to automatically switch to Conservation mode when a certain percentage of charge is reached #14

Open
webdevs-pro opened this issue Jul 2, 2023 · 5 comments

Comments

@webdevs-pro
Copy link

Hey @reagcz Thanks for useful app. Only one thing I really need is ability to automatically switch to Conservation mode for example on 80%. Or maybe it is possible to change Conservation mode rate from 60% to 80%?

@reagcz
Copy link
Owner

reagcz commented Aug 10, 2023

Sorry for taking so long to respond. Since the conservation mode is a firmware feature, changing the percentage it kicks in is not possible. You CAN change the max percentage in Lenovo Vantage, but this feature is only available on ThinkPads, not our puny IdeaPads.

As for the automatic switch, there's no way my program can tell when the battery reaches past a certain charge level. All I can do is to check the current percentage every few minutes. That would theoretically work without much of a performance impact and would be easy to implement.

The issue is, it would keep switching the charging on and off constantly, and I'm not sure that's good for the battery. But it's doable. Would this be an acceptable implementation @webdevs-pro?

@mightytry
Copy link

I think it would be enough to just switch it on at 80%. Because when I charge mine and turn protection on at 80% it keeps the current charge and is not discharging the battery, insted using the connected external power.

@idwowrack
Copy link

@webdevs-pro
you could make a simple script to notify your self about the battery level limit (the bash code snippet).
if it reached the top threshold battery level, then manually you switch mode to the conservative one.

`#!/bin/bash

TOP_THRESHOLD=84
BOTTOM_THRESHOLD=36
STABILITY_DURATION=3 # Number of consecutive checks to consider battery level as stable (adjust as needed)
NOTIFIED=false

while true; do
charger_status=$(WMIC Path Win32_Battery Get BatteryStatus | grep -oE '[0-9]+')

# 1 means discharging, 2 means charging, 3 means fully charged, 4 means low
if [ "$charger_status" -eq 1 ] || [ "$charger_status" -eq 2 ]; then
    battery_level=$(WMIC Path Win32_Battery Get EstimatedChargeRemaining | grep -oE '[0-9]+')

    if [ "$battery_level" -ge "$TOP_THRESHOLD" ] && [ "$charger_status" -eq 2 ]; then
        if [ "$NOTIFIED" = false ]; then
            NOTIFIED=true
            initial_level=$battery_level
            stability_counter=0
            powershell.exe -ExecutionPolicy Bypass -File "./notify.ps1" -Title "Battery Level" -Message "Battery level has reached at the top threshold and please enable the conservative mode via Lenovo Vantage >> Device: Power menu." -AppLogoPath "C:\Users\LENOVO\OneDrive\Pictures\is-it-legal.png"
        fi

`

@webdevs-pro
Copy link
Author

webdevs-pro commented Aug 28, 2023

Hey @idwowrack, thanks!
I made similar thing but using AutoHotKey script and PowerBattery.dll. If charge reached 75% then script will switch mode to conservation and if battery level is below 70% it will switch to normal.

SetTimer, Tick, 10000
return

Tick() {
   batteryLevel := GetBatteryLevel()
   mode := GetMode()

   if (batteryLevel > 75 && mode != "Conservation") {
      RunWait, powershell.exe -Command "Set-Location -Path '%A_ScriptDir%'; Set-LenovoChargingMode Conservation",, Hide
      ShowBatteryStatus()
   } else if (batteryLevel <= 70 && mode != "Normal" && mode != "Rapid" ) {
      RunWait, powershell.exe -Command "Set-Location -Path '%A_ScriptDir%'; Set-LenovoChargingMode Normal",, Hide
      ShowBatteryStatus()
   }
}

This is part of my script

@chikatambun
Copy link

Looks like more promising using AHK for auto mode switching, @webdevs-pro
Could you gist the step by step for using the autoscript ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants