battery_forecast

Discharge rate and runtime forecast from Home Assistant’s history.

uv run tools/battery_forecast.py [–since 2026-09-27T08:12] [–hours 72]

Takes the battery level recorded since the board last stopped charging (sensor.epaper_ladezustand), or since –since (local time), fits a line through it and projects when the levels that change the update pace are reached.

Attributes

Functions

parse_time(text)

Parse an ISO time from Home Assistant, including a "Z" suffix.

discharge_start(states)

Find when the board last stopped charging.

fit(points)

Least-squares line through [(hours, percent)]: (slope %/h, intercept).

forecast(levels, start, now)

Rate and projections from [(time, percent)] since start.

history(entity_ids, since, until)

Load the state history of entity_ids from Home Assistant.

main()

Run the command line tool.

Module Contents

battery_forecast.CHARGE_STATE = 'sensor.epaper_ladezustand'
battery_forecast.parse_time(text)

Parse an ISO time from Home Assistant, including a “Z” suffix.

battery_forecast.discharge_start(states)

Find when the board last stopped charging.

From [(time, state)] this is the first report after the last “charging”, or the first report at all if none was charging; None if it is charging now. (On battery the board mostly reports “stable”: the discharge in the deep-sleep cycle is below the gauge’s resolution.)

battery_forecast.fit(points)

Least-squares line through [(hours, percent)]: (slope %/h, intercept).

battery_forecast.forecast(levels, start, now)

Rate and projections from [(time, percent)] since start.

battery_forecast.history(entity_ids, since, until)

Load the state history of entity_ids from Home Assistant.

battery_forecast.main()

Run the command line tool.