mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-15 10:31:57 +00:00
Port the locally backed-up measurement extensions to main async storage and PR #1256 device maps. Preserve runtime capacity estimates across #1305 bulk updates. Confirm JSON singleton restore defect on unchanged main and add regression. No production configuration or measurements included. Co-authored-by: Andreas <drbacke@gmx.de>
25 lines
832 B
Python
25 lines
832 B
Python
"""Optional quality information on raw measurement samples."""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field
|
|
|
|
|
|
class SampleQuality(BaseModel):
|
|
"""Reset marks the first reading after a reset; generation identifies a meter."""
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
status: Literal["measured", "estimated", "invalid", "unavailable"] = "measured"
|
|
reset: bool = False
|
|
generation: str | None = Field(default=None, max_length=128)
|
|
|
|
|
|
class MeasurementSample(BaseModel):
|
|
"""Complete replacement of one key/timestamp, including its quality."""
|
|
|
|
model_config = ConfigDict(extra="forbid", allow_inf_nan=False)
|
|
date_time: AwareDatetime
|
|
key: str
|
|
value: float | None = Field(strict=True)
|
|
quality: SampleQuality = Field(default_factory=SampleQuality)
|