flexmeasures.data.schemas.forecasting.references
Sensor references a forecaster’s config can hold, including one for the sensor being forecast.
Module Attributes
Functions
- flexmeasures.data.schemas.forecasting.references.validate_target_qualifiers(qualifiers: dict[str, Any]) None
Refuse a qualifier the sensor being forecast cannot be read with, while its config is being accepted.
Only the unit check has to wait for that sensor, as a bound is read in the sensor’s own unit. Key names and value shapes do not: a typo such as
lowr, a source filter that is not a list, or a bound that is no quantity at all is refused here rather than on every run of a stored automation.- Parameters:
qualifiers – The entry’s keys other than
sensor, as given.- Raises:
ValidationError – naming the qualifiers that cannot be read.
Classes
- class flexmeasures.data.schemas.forecasting.references.AutoSensorReference(qualifiers: dict[str, ~typing.Any]=<factory>)
A reference to the sensor being forecast, before that sensor is known.
A forecaster’s config is written once and used for whichever sensor a forecast names, so a config that wants to say something about that sensor writes
"auto"in place of its ID. The reference holds the qualifiers it was given, and turns into an ordinary sensor reference once the target is known.- resolve(target_sensor: Sensor) Sensor | SensorReference
Return what this reference means for the sensor being forecast.
- Parameters:
target_sensor – The sensor the forecast is made for.
- Returns:
A plain
Sensorwhen no qualifiers were given, and aSensorReferenceotherwise.
- class flexmeasures.data.schemas.forecasting.references.ForecastInputField(*args, **kwargs)
A sensor a forecaster reads from: a sensor ID, a sensor reference, or
"auto"."auto"names the sensor being forecast, which a config cannot name by ID without being tied to one target. It may be written on its own, or as thesensorof a reference that qualifies it, as in{"sensor": "auto", "lower": "0 kW"}.- __init__(*args, **kwargs)
- _deserialize(value: Any, attr, data, **kwargs) Sensor | SensorReference | AutoSensorReference
Deserialize value. Concrete
Fieldclasses should implement this method.- Parameters:
value – The value to be deserialized.
attr – The attribute/key in data to be deserialized.
data – The raw input data passed to the Schema.load <marshmallow.Schema.load>.
kwargs – Field-specific keyword arguments.
- Raises:
ValidationError – In case of formatting or validation failure.
- Returns:
The deserialized value.
Changed in version 3.0.0: Added
**kwargsto signature.
- _serialize(value: Sensor | SensorReference | AutoSensorReference, attr, obj, **kwargs) Any
Serialize a sensor, a reference, or the sentinel naming the sensor being forecast.