predict

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package predict estimates the next unplug time from the recorded history. It is a faithful port of the awk model of the bash policy this binary replaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Next

func Next(entries []history.Entry, at history.Entry, minSamples int) (int, bool)

Next returns the minute of day the charger is expected to come out, and whether a prediction could be made at all.

Only strictly future times count: once the usual unplug minute has passed, the manager holds the base thresholds overnight instead of chasing a stale prediction. Times from the same weekday are preferred; every weekday fills in until enough same-day samples exist. With fewer than minSamples usable records there is no prediction.

func NextChange

func NextChange(entries []history.Entry, at history.Entry, minSamples, window int) (int, bool)

NextChange returns the first minute later on the same day at which TopUp flips, and false when it holds until midnight.

Next is constant between consecutive recorded unplug minutes, since a record only drops out of the pool once its minute is reached. Within each such stretch TopUp can only turn on, exactly when the window opens; it can only turn off where the prediction itself jumps. So the recorded minutes and one window opening per stretch are the only candidates, instead of every minute of the day.

func TopUp

func TopUp(entries []history.Entry, at history.Entry, minSamples, window int) bool

TopUp reports whether the charge ceiling belongs at full at the given time: an unplug is predicted within window minutes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL