Skip to content

microgrid.cli.sources.read

The inputs as they stand now, read from the configured sources (microgrid now).

Each input is read from its source once, at now: a forecast is one issue received now; a measured value is the value in force, from when it changed. An input whose source is not configured, or cannot be read, is left out and the reason kept (Read.problems): the valuation then names it as a cause, as it would any input it cannot use. Nothing is guessed in its place.

Read dataclass

Read(
    inputs: Inputs,
    sources: dict[str, str] = dict(),
    problems: dict[str, str] = dict(),
    entries: dict[str, Entry] = dict(),
)

The inputs read now, where each came from, and why any is missing.

inputs instance-attribute

inputs: Inputs

sources class-attribute instance-attribute

sources: dict[str, str] = field(default_factory=dict)

Each input read, and its source (prices: tariffkit).

problems class-attribute instance-attribute

problems: dict[str, str] = field(default_factory=dict)

Each input not read, and why (not configured, or the source's error).

entries class-attribute instance-attribute

entries: dict[str, Entry] = field(default_factory=dict)

The inputs as a dataset's entries, to keep or re-run offline.

read_now async

read_now(
    sources: Sources,
    plant: Plant,
    engine: EngineConfig,
    now: datetime,
    *,
    client: HaClient | None = None,
    lots_run_in: timedelta = LOTS_RUN_IN,
    limits: Limits | None = None,
) -> Read

Every configured input as it stands at now (UTC), and for a plant with a battery its lots: the ledger over the lots_run_in before now, from what the [measured] entities recorded, the record judged by limits. client: Home Assistant's, else one made from sources (and closed here).