Skip to content

battery maintain with voltage not working #286

@neoeleatic

Description

@neoeleatic

The logic to check for voltages in "battery maintain" is slightly broken, resulting in the feature not working.

❯ battery maintain 11.4V
06/28/24-17:39:03 - Called with 11.4 maintain
06/28/24-17:39:03 - Error: 11.4 is not a valid setting for battery maintain. Please use a number between 0 and 100, or an action keyword like 'stop' or 'recover'.

Parts of #224 got rewritten in a subsequent merge, introducing the problem.

This is a quick fix:

--- a/battery.sh
+++ b/battery.sh
@@ -672,10 +672,9 @@ if [[ "$action" == "maintain" ]]; then
        fi
 
        is_voltage=true
-   fi
 
    # Check if setting is value between 0 and 100
-   if ! valid_percentage "$setting"; then
+   elif ! valid_percentage "$setting"; then
        log "Called with $setting $action"
        # If non 0-100 setting is not a special keyword, exit with an error.
        if ! { [[ "$setting" == "stop" ]] || [[ "$setting" == "recover" ]]; }; then

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions