awake_stats

How long the board is awake between two status reports.

Accumulated in the RTC state before every deep sleep and published with the status (see hamqtt), to tell whether the wakes or the sleep current dominate the battery drain.

Attributes

Functions

fresh(now_s)

Start a new counting period at now_s (seconds).

add_wake(stats, awake_ms, now_s)

stats (or a fresh count) plus one wake of awake_ms.

summary(stats, now_s)

Summarise a counting period for reporting.

Module Contents

awake_stats.BOOT_OVERHEAD_MS = 300
awake_stats.fresh(now_s)

Start a new counting period at now_s (seconds).

awake_stats.add_wake(stats, awake_ms, now_s)

stats (or a fresh count) plus one wake of awake_ms.

awake_stats.summary(stats, now_s)

Summarise a counting period for reporting.

Parameters:
  • stats – The counted wakes (see add_wake), or None.

  • now_s – The current time in seconds.

Returns:

A dict with “awake_share” (%), “wakes_per_hour” and “awake_per_wake” (s), or None if there is no usable period.