flexmeasures.data.models.automations

Automations: recurring forecasting or scheduling tasks defined per asset.

Functions

flexmeasures.data.models.automations.get_default_automation_timezone() str

Return the timezone to snapshot when an automation is created.

flexmeasures.data.models.automations.get_initial_cursor() datetime

Return a cursor which keeps the automation’s creation minute eligible.

Classes

class flexmeasures.data.models.automations.Automation(**kwargs)

A recurring task on an asset, such as computing forecasts.

The recurrence is defined by a cron string. Every automation has a data generator, linked through a data source: a forecaster and its configuration for a forecast automation, and a scheduler and the flex config it computes under for a schedule automation. A forecast automation’s generator is chosen when it is created. A schedule automation’s is assembled from the trigger message and what its asset stores, so the runner puts it together afresh on every run.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

property input_sensors: list

The sensors that this automation reads data from on each run, as far as they can be worked out.

Reports no sensors if they cannot be, so do not use this to decide whether something is permitted; see resolve_automation_sensors for that.

property output_sensors: list

The sensors that this automation writes data to on each run. See input_sensors.

query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

validate_timezone(key: str, timezone: str) str

Require an exact timezone name from the IANA timezone database.